Skip to content

Let's use AI to Earn!

feat: 创建自动评论脚本

yikaJasonMic71fa624b70ab
diff --git a/electron/main/reply/controller.ts b/electron/main/reply/controller.ts
index 73f7de05..68531b91 100644
--- a/electron/main/reply/controller.ts
+++ b/electron/main/reply/controller.ts
@@ -1,13 +1,14 @@
/*
* @Author: nevin
* @Date: 2025-01-20 22:02:54
- * @LastEditTime: 2025-03-19 17:28:02
+ * @LastEditTime: 2025-03-20 22:38:17
* @LastEditors: nevin
* @Description: reply Reply
*/
-import { AutoRunModel } from '../../db/models/autoRun';
+import { AutoRunModel, AutoRunType } from '../../db/models/autoRun';
import { AccountService } from '../account/service';
import { toolsApi } from '../api/tools';
+import { AutoRunService } from '../autoRun/service';
import { Controller, Et, Icp, Inject } from '../core/decorators';
import platController from '../plat';
import type { CommentData } from '../plat/plat.type';
@@ -21,6 +22,9 @@ export class ReplyController {
@Inject(AccountService)
private readonly accountService!: AccountService;
+ @Inject(AutoRunService)
+ private readonly autoRunService!: AutoRunService;
+
/**
* 作品列表
*/
@@ -151,6 +155,30 @@ export class ReplyController {
return res;
}
+ /**
+ * 创建自动一键评论任务
+ */
+ @Icp('ICP_AUTO_RUN_CREATE_REPLY')
+ async createReplyCommentAutoRun(
+ event: Electron.IpcMainInvokeEvent,
+ accountId: number,
+ dataId: string,
+ cycleType: string,
+ ): Promise<AutoRunModel | null> {
+ const account = await this.accountService.getAccountById(accountId);
+ if (!account) return null;
+
+ const res = await this.autoRunService.createAutoRun({
+ accountId,
+ cycleType,
+ type: AutoRunType.ReplyComment,
+ userId: account.uid,
+ dataId,
+ });
+
+ return res;
+ }
+
// 运行自动任务
@Et('ET_AUTO_RUN_REPLY_COMMENT')
async runAutoReplyComment(autoRunData: AutoRunModel): Promise<any> {
diff --git a/electron/main/reply/module.ts b/electron/main/reply/module.ts
index d3498eb8..e51af513 100644
--- a/electron/main/reply/module.ts
+++ b/electron/main/reply/module.ts
@@ -1,17 +1,18 @@
/*
* @Author: nevin
* @Date: 2025-01-24 16:35:59
- * @LastEditTime: 2025-02-06 19:14:24
+ * @LastEditTime: 2025-03-20 22:26:30
* @LastEditors: nevin
* @Description: reply Reply 评论
*/
import { AccountModule } from '../account/module';
+import { AutoRunModule } from '../autoRun/module';
import { Module } from '../core/decorators';
import { ReplyController } from './controller';
import { ReplyService } from './service';
@Module({
- imports: [AccountModule],
+ imports: [AccountModule, AutoRunModule],
controllers: [ReplyController],
providers: [ReplyService],
})
diff --git a/src/icp/reply.ts b/src/icp/reply.ts
index eed85484..285f3513 100644
--- a/src/icp/reply.ts
+++ b/src/icp/reply.ts
@@ -1,7 +1,7 @@
/*
* @Author: nevin
* @Date: 2025-01-23 15:48:14
- * @LastEditTime: 2025-03-20 21:28:10
+ * @LastEditTime: 2025-03-20 22:39:03
* @LastEditors: nevin
* @Description:
*/
diff --git a/src/views/reply/components/addAutoRun.tsx b/src/views/reply/components/addAutoRun.tsx
index 793fb3b3..5f44ecf2 100644
--- a/src/views/reply/components/addAutoRun.tsx
+++ b/src/views/reply/components/addAutoRun.tsx
@@ -1,7 +1,7 @@
/*
* @Author: nevin
* @Date: 2025-03-18 21:02:38
- * @LastEditTime: 2025-03-20 20:38:47
+ * @LastEditTime: 2025-03-20 22:38:42
* @LastEditors: nevin
* @Description: 添加自动运行
*/