Skip to content

Let's use AI to Earn!

报错处理

daoyian488f35f01a29
diff --git a/electron/main/api/taskApi.ts b/electron/main/api/taskApi.ts
new file mode 100644
index 00000000..ee18bea6
--- /dev/null
+++ b/electron/main/api/taskApi.ts
@@ -0,0 +1,28 @@
+import * as fs from 'fs'; // 新增文件系统导入
+import netRequest from '.';
+import FormData from 'form-data';
+
+
+export class TaskApi {
+ // 获取活动任务
+ async getActivityTask() {
+ const res = await netRequest({
+ method: 'GET',
+ url: 'tasks/list?page=1&pageSize=20&totalCount=0&type=interaction',
+ body: {},
+ isToken: true,
+ });
+ const {
+ status,
+ data: { data, code },
+ } = res;
+ // console.log('---- getActivityTask ----', data);
+ if (status !== 200 && status !== 201) return '';
+ if (!!code) return '';
+ return data;
+ }
+
+
+}
+
+export const taskApi = new TaskApi();
diff --git a/electron/main/interaction/controller.ts b/electron/main/interaction/controller.ts
index ba727dc3..2b266a0c 100644
--- a/electron/main/interaction/controller.ts
+++ b/electron/main/interaction/controller.ts
@@ -9,7 +9,7 @@ import windowOperate from '../../util/windowOperate';
import { AutoRunModel, AutoRunType } from '../../db/models/autoRun';
import { AccountService } from '../account/service';
import { AutoRunService } from '../autoRun/service';
-import { Controller, Et, Icp, Inject } from '../core/decorators';
+import { Controller, Et, Icp, Inject, Scheduled } from '../core/decorators';
import { InteractionService } from './service';
import { SendChannelEnum } from '../../../commont/UtilsEnum';
import type { WorkData } from '../plat/plat.type';
@@ -18,6 +18,7 @@ import { AutoInteractionCache } from './cacheData';
import { getUserInfo } from '../user/comment';
import type { CorrectQuery } from '../../global/table';
import { AccountType } from '../../../commont/AccountEnum';
+import { taskApi } from '../api/taskApi';
@Controller()
export class InteractionController {
@@ -177,4 +178,41 @@ export class InteractionController {
): Promise<any | null> {
return AutoInteractionCache.getInfo();
}
+
+
+
+ // 自动互动, 每10秒进行
+ @Scheduled('0 * * * * *', 'autoHudong')
+ async zidongHudong() {
+ console.log('自动互动 ing ...');
+ const res = await taskApi.getActivityTask();
+ // console.log('---- zidongHudong ----', res);
+ const userList = await this.interactionService.getUserList();
+ // console.log('---- userList ----', userList);
+ const accountList = await this.interactionService.getAccountList(userList[1].id);
+ // console.log('---- accountList ----', accountList);
+ if (res.items.length > 0) {
+ for (const item of res.items) {
+ item.accountTypes.forEach((accountType: any) => {
+ let myAccountTypeList = [];
+ for (const account of accountList) {
+ if (account.type === accountType) {
+ myAccountTypeList.push(account);
+ }
+ }
+ console.log('---- myAccountTypeList ----', myAccountTypeList);
+
+ for (const account of myAccountTypeList) {
+ console.log('---- account ----', account);
+ const autorInteractionList = this.interactionService.getAutorInteractionList(account, [{
+ workId: item.workId,
+ }], {
+ accountType: accountType,
+ });
+ console.log('---- autorInteractionList ----', autorInteractionList);
+ }
+ });
+ }
+ }
+ }
}
diff --git a/electron/main/interaction/service.ts b/electron/main/interaction/service.ts
index 05cde465..256669d5 100644
--- a/electron/main/interaction/service.ts
+++ b/electron/main/interaction/service.ts
@@ -23,8 +23,11 @@ import { WorkData } from '../plat/plat.type';
import { AutoInteractionCache } from './cacheData';
import { backPageData, CorrectQuery } from '../../global/table';
import { AccountType } from '../../../commont/AccountEnum';
+import { AccountService } from '../account/service';
+import { UserService } from '../user/service';
// import { ReplyController } from '../reply/controller';
+
@Injectable()
export class InteractionService {
interactionQueue: PQueue;
@@ -475,4 +478,49 @@ export class InteractionService {
status: 1,
};
}
+
+
+
+
+
+
+
+ // 自动互动
+ @Inject(UserService)
+ private readonly userService!: UserService;
+ @Inject(AccountService)
+ private readonly accountService!: AccountService;
+
+ // 获取用户列表
+ async getUserList() {
+ return await this.userService.getUsers();
+ }
+
+ // 获取账户列表
+ async getAccountList(userId: string) {
+ return await this.accountService.getAccounts(userId);
+ }
+
+ // 获取自动互动列表
+ async getAutorInteractionList(account: any, worksList: any, option: any) {
+ return await this.autorInteraction(
+ account,
+ worksList,
+ {
+ commentContent: option.commentContent || null,
+ platform: option.accountType, // 平台
+ likeProb: 100, // 点赞概率
+ collectProb: 100, // 收藏概率
+ commentProb: 100, // 评论概率
+ commentType: 'ai', // 评论类型
+ },
+ (e: {
+ tag: AutorWorksInteractionScheduleEvent;
+ status: -1 | 0 | 1;
+ error?: any;
+ }) => {
+ console.log('------ e', e);
+ },
+ );
+ }
}
diff --git a/electron/main/tools/controller.ts b/electron/main/tools/controller.ts
index f8ac29ec..a985842d 100644
--- a/electron/main/tools/controller.ts
+++ b/electron/main/tools/controller.ts
@@ -74,36 +74,5 @@ export class ToolsController {
clearOldLogs();
}
- // 自动互动, 每10秒进行
- @Scheduled('0 * * * * *', 'autoHudong')
- async zidongHudong() {
- console.log('自动互动 ing ...');
- const res = await toolsApi.getActivityTask();
- // console.log('---- zidongHudong ----', res);
- const userList = await this.toolsService.getUserList();
- // console.log('---- userList ----', userList);
- const accountList = await this.toolsService.getAccountList(userList[1].id);
- // console.log('---- accountList ----', accountList);
- if (res.items.length > 0) {
- for (const item of res.items) {
- item.accountTypes.forEach((accountType: any) => {
- let myAccountTypeList = [];
- for (const account of accountList) {
- if (account.type === accountType) {
- myAccountTypeList.push(account);
- }
- }
- console.log('---- myAccountTypeList ----', myAccountTypeList);
- for (const account of myAccountTypeList) {
- console.log('---- account ----', account);
- const autorInteractionList = this.toolsService.getAutorInteractionList(account, item.worksList, {
- accountType: accountType,
- });
- console.log('---- autorInteractionList ----', autorInteractionList);
- }
- });
- }
- }
- }
}
diff --git a/electron/main/tools/service.ts b/electron/main/tools/service.ts
index 95bd2c82..59f7cdc4 100644
--- a/electron/main/tools/service.ts
+++ b/electron/main/tools/service.ts
@@ -5,43 +5,8 @@
* @Description: 工具箱
*/
import { Inject, Injectable } from '../core/decorators';
-import { UserService } from '../user/service';
-import { AccountService } from '../account/service';
-import { InteractionService } from '../interaction/service';
+
@Injectable()
export class ToolsService {
- @Inject(UserService)
- private readonly userService!: UserService;
- @Inject(AccountService)
- private readonly accountService!: AccountService;
- @Inject(InteractionService)
- private readonly interactionService!: InteractionService;
-
- // 获取用户列表
- async getUserList() {
- return await this.userService.getUsers();
- }
-
- // 获取账户列表
- async getAccountList(userId: string) {
- return await this.accountService.getAccounts(userId);
- }
-
- // 获取自动互动列表
- async getAutorInteractionList(account: any, worksList: any, option: any) {
- return await this.interactionService.autorInteraction(
- account,
- worksList,
- {
- commentContent: option.commentContent || null,
- platform: option.accountType, // 平台
- likeProb: 100, // 点赞概率
- collectProb: 100, // 收藏概率
- commentProb: 100, // 评论概率
- commentType: 'ai', // 评论类型
- }
-
- );
- }
}