Skip to content

Let's use AI to Earn!

feat: 评论和回复评论

牛文政80e8e949a60d
diff --git a/electron/main/plat/PlatformBase.ts b/electron/main/plat/PlatformBase.ts
index 1a0ef90e..3b7a6025 100644
--- a/electron/main/plat/PlatformBase.ts
+++ b/electron/main/plat/PlatformBase.ts
@@ -104,6 +104,28 @@ export abstract class PlatformBase {
count: number;
}>;
+ /**
+ * 创建评论
+ */
+ abstract createComment(
+ account: AccountModel,
+ dataId: string, // 作品ID
+ content: string,
+ ): Promise<boolean>;
+
+ /**
+ * 回复评论
+ */
+ abstract replyComment(
+ account: AccountModel,
+ commentId: string,
+ content: string,
+ option: {
+ dataId?: string; // 作品ID
+ data: any; // 辅助数据,原数据
+ },
+ ): Promise<boolean>;
+
/**
* 在该平台发布视频
*/
diff --git a/electron/main/plat/platforms/Kwai/index.ts b/electron/main/plat/platforms/Kwai/index.ts
index e4455e51..d28b8670 100644
--- a/electron/main/plat/platforms/Kwai/index.ts
+++ b/electron/main/plat/platforms/Kwai/index.ts
@@ -177,6 +177,26 @@ export class Kwai extends PlatformBase {
};
}
+ async createComment(
+ account: AccountModel,
+ dataId: string, // 作品ID
+ content: string,
+ ) {
+ return false;
+ }
+
+ async replyComment(
+ account: AccountModel,
+ commentId: string,
+ content: string,
+ option: {
+ dataId?: string; // 作品ID
+ data: any; // 辅助数据,原数据
+ },
+ ) {
+ return false;
+ }
+
async loginCheck(account: AccountModel): Promise<boolean> {
const res = await kwaiPub.getAccountInfo(JSON.parse(account.loginCookie));
return !(res.status !== 200 || !res.data.data.userName);
diff --git a/electron/main/plat/platforms/douyin/index.ts b/electron/main/plat/platforms/douyin/index.ts
index 7d1a367f..3fd99892 100644
--- a/electron/main/plat/platforms/douyin/index.ts
+++ b/electron/main/plat/platforms/douyin/index.ts
@@ -160,6 +160,26 @@ export class Douyin extends PlatformBase {
};
}
+ async createComment(
+ account: AccountModel,
+ dataId: string, // 作品ID
+ content: string,
+ ) {
+ return false;
+ }
+
+ async replyComment(
+ account: AccountModel,
+ commentId: string,
+ content: string,
+ option: {
+ dataId?: string; // 作品ID
+ data: any; // 辅助数据,原数据
+ },
+ ) {
+ return false;
+ }
+
async videoPublish(
params: IVideoPublishParams,
callback: VideoCallbackType,
diff --git a/electron/main/plat/platforms/wxSph/index.ts b/electron/main/plat/platforms/wxSph/index.ts
index d8404629..c8bccdf5 100644
--- a/electron/main/plat/platforms/wxSph/index.ts
+++ b/electron/main/plat/platforms/wxSph/index.ts
@@ -23,6 +23,7 @@ import { PublishVideoResult } from '../../module';
import { shipinhaoService } from '../../../../plat/shipinhao';
import { AccountType } from '../../../../../commont/AccountEnum';
import { AccountModel } from '../../../../db/models/account';
+import { CommentInfo } from '../../../../plat/shipinhao/wxShp.type';
export class WxSph extends PlatformBase {
constructor() {
@@ -162,7 +163,7 @@ export class WxSph extends PlatformBase {
const cookie: CookiesType = JSON.parse(account.loginCookie);
const res = await shipinhaoService.getCommentList(cookie, dataId);
- const dataList = res.data.data.comment.map((item) => {
+ const dataList = res.comment.map((item) => {
return {
dataId: item.commentId,
commentId: item.commentId,
@@ -175,10 +176,40 @@ export class WxSph extends PlatformBase {
return {
list: dataList,
- count: res.data.data.commentCount,
+ count: res.commentCount,
};
}
+ async createComment(
+ account: AccountModel,
+ dataId: string, // 作品ID
+ content: string,
+ ) {
+ const cookie: CookiesType = JSON.parse(account.loginCookie);
+ const res = await shipinhaoService.createComment(cookie, dataId, content);
+
+ return false;
+ }
+
+ async replyComment(
+ account: AccountModel,
+ commentId: string,
+ content: string,
+ option: {
+ dataId: string; // 作品ID
+ data: CommentInfo; // 辅助数据,原数据
+ },
+ ) {
+ const cookie: CookiesType = JSON.parse(account.loginCookie);
+ const res = await shipinhaoService.createComment(
+ cookie,
+ option.dataId,
+ content,
+ option.data,
+ );
+ return false;
+ }
+
async getUsers(params: IGetUsersParams) {
const usersRes = await shipinhaoService.getUsers(
JSON.parse(params.account.loginCookie),
diff --git a/electron/main/plat/platforms/xhs/index.ts b/electron/main/plat/platforms/xhs/index.ts
index d67f9bcd..f8a4c0bd 100644
--- a/electron/main/plat/platforms/xhs/index.ts
+++ b/electron/main/plat/platforms/xhs/index.ts
@@ -155,7 +155,30 @@ export class Xhs extends PlatformBase {
async getCommentList(account: AccountModel, dataId: string) {
const cookie: CookiesType = JSON.parse(account.loginCookie);
- return [];
+ return {
+ list: [],
+ count: 0,
+ };
+ }
+
+ async createComment(
+ account: AccountModel,
+ dataId: string, // 作品ID
+ content: string,
+ ) {
+ return false;
+ }
+
+ async replyComment(
+ account: AccountModel,
+ commentId: string,
+ content: string,
+ option: {
+ dataId?: string; // 作品ID
+ data: any; // 辅助数据,原数据
+ },
+ ) {
+ return false;
}
/**
* @param params
diff --git a/electron/plat/shipinhao/index.ts b/electron/plat/shipinhao/index.ts
index 7d3d987f..20fc2ba6 100644
--- a/electron/plat/shipinhao/index.ts
+++ b/electron/plat/shipinhao/index.ts
@@ -5,6 +5,7 @@ import { FileUtils } from '../../util/file';
import { CookieToString, getFileContent } from '../utils';
import requestNet from '../requestNet';
import {
+ CommentInfo,
SphGetCommentListResponse,
SphGetPostListResponse,
WeChatLocationData,
@@ -1390,10 +1391,7 @@ export class ShipinhaoService {
});
const ret = res.data.data;
-
- console.log('----- ', ret.comment[0].levelTwoComment);
-
- return res;
+ return ret;
}
/**
@@ -1405,45 +1403,33 @@ export class ShipinhaoService {
*/
async createComment(
cookie: Electron.Cookie[],
- body: {
- comment: {
- // 空对象是直接回复作品
- commentContent: '可爱吧';
- commentCreatetime: '1741695959';
- commentHeadurl: 'https://wx.qlogo.cn/finderhead/Q3auHgzwzM5OEKzc5UdzOUJUbOsaCtSkcCctCb9ddrCKiag4ZibQ73oA/0';
- commentId: '14610404657143548189';
- commentLikeCount: 0;
- commentNickname: '义务之后是金钱';
- displayFlag: 2;
- levelTwoComment: [];
- replyContent: '';
- replyNickname: '';
- username: 'v2_060000231003b20faec8c5e38b10cbd6cb06ef3cb077ad5b14a8587570bc414e95c4b7e034ea@finder';
- visibleFlag: 1;
- };
- content: '可爱吧';
- exportId: 'export/UzFfAgtgekIEAQAAAAAAOhIpzVxlAQAAAAstQy6ubaLX4KHWvLEZgBPExKFQKCowfoSJzNPgMJrD53jJrD_NBzgU3Ncr3usg';
- pluginSessionId: null;
- rawKeyBuff: null;
- replyCommentId: '';
- reqScene: 7;
- rootCommentId: '';
- scene: 7;
- timestamp: '1741695962126';
- _log_finder_id: 'v2_060000231003b20faec8c5e38b10cbd6cb06ef3cb077ad5b14a8587570bc414e95c4b7e034ea@finder';
- _log_finder_uin: '';
- },
- rid: string,
+ exportId: string,
+ content: string,
+ comment: Partial<CommentInfo> = {},
) {
return await requestNet<WeChatVideoUserData>({
- url: `https://channels.weixin.qq.com/micro/interaction/cgi-bin/mmfinderassistant-bin/comment/create_comment?_rid=${rid}`,
+ url: `https://channels.weixin.qq.com/micro/interaction/cgi-bin/mmfinderassistant-bin/comment/create_comment?_rid=67d032a7-6c8f7126`,
headers: {
cookie: CookieToString(cookie),
},
method: 'POST',
body: {
clientId: this.getUniqueTaskId(),
- ...body,
+ body: {
+ comment,
+ content,
+ exportId,
+ pluginSessionId: null,
+ rawKeyBuff: null,
+ replyCommentId: '',
+ reqScene: 7,
+ rootCommentId: '',
+ scene: 7,
+ timestamp: Date.now() + '',
+ _log_finder_id:
+ 'v2_060000231003b20faec8c5e38b10cbd6cb06ef3cb077ad5b14a8587570bc414e95c4b7e034ea@finder',
+ _log_finder_uin: '',
+ },
},
});
}