From 64289d45b5f5a3e9466589c4489e70a454ff562a Mon Sep 17 00:00:00 2001 From: su-chang Date: Mon, 30 Aug 2021 17:25:39 +0800 Subject: [PATCH 01/12] feat: add new message type for channels message --- src/schemas/message.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/schemas/message.ts b/src/schemas/message.ts index 75a0e461..759555c2 100644 --- a/src/schemas/message.ts +++ b/src/schemas/message.ts @@ -16,6 +16,7 @@ export enum MessageType { Recalled = 13, // Recalled(10002) Url = 14, // Url(5) Video = 15, // Video(4), Video(43) + Channels = 16, // Channels(141) } /** From feeb8c7f9ab5e32153feb50b847de27b0c8e11e1 Mon Sep 17 00:00:00 2001 From: su-chang Date: Mon, 30 Aug 2021 17:25:49 +0800 Subject: [PATCH 02/12] 0.43.11 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 90b34722..bd363a15 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-puppet", - "version": "0.43.10", + "version": "0.43.11", "description": "Abstract Puppet for Wechaty", "type": "module", "exports": { From 3dfaed1cc651188707c08ea76cdbf9596053eb12 Mon Sep 17 00:00:00 2001 From: su-chang Date: Mon, 30 Aug 2021 20:33:49 +0800 Subject: [PATCH 03/12] feat: add ChannelsPayload --- src/mod.ts | 3 +++ src/schemas/channels.ts | 7 +++++++ 2 files changed, 10 insertions(+) create mode 100644 src/schemas/channels.ts diff --git a/src/mod.ts b/src/mod.ts index cc16ffad..7e06226c 100644 --- a/src/mod.ts +++ b/src/mod.ts @@ -74,6 +74,9 @@ export { export { MiniProgramPayload, } from './schemas/mini-program.js' +export { + ChannelsPayload, +} from './schemas/channels.js' export { throwUnsupportedError, diff --git a/src/schemas/channels.ts b/src/schemas/channels.ts new file mode 100644 index 00000000..0cb3c577 --- /dev/null +++ b/src/schemas/channels.ts @@ -0,0 +1,7 @@ +export interface ChannelsPayload { + authorAvatar: string, + authorNickname: string, + coverageUrl: string, + title: string, + videoUrl: string, +} From 05b2dd321f345e2079a933eb17661c0175c92bc9 Mon Sep 17 00:00:00 2001 From: su-chang Date: Wed, 1 Sep 2021 17:14:26 +0800 Subject: [PATCH 04/12] fix: add comment for channels message introduction --- src/schemas/channels.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/schemas/channels.ts b/src/schemas/channels.ts index 0cb3c577..b485a7e4 100644 --- a/src/schemas/channels.ts +++ b/src/schemas/channels.ts @@ -1,3 +1,6 @@ +/** + * Channels introduction, see: https://wechatwiki.com/wechat-resources/wechat-channels-short-video-feature-complete-guide/ + */ export interface ChannelsPayload { authorAvatar: string, authorNickname: string, From 31966578c246aa7032837c132da1d6d6d03f9a2b Mon Sep 17 00:00:00 2001 From: su-chang Date: Wed, 8 Sep 2021 19:37:32 +0800 Subject: [PATCH 05/12] fix: rename channels to video post --- src/schemas/channels.ts | 10 ---------- src/schemas/message.ts | 2 +- src/schemas/video-post.ts | 9 +++++++++ 3 files changed, 10 insertions(+), 11 deletions(-) delete mode 100644 src/schemas/channels.ts create mode 100644 src/schemas/video-post.ts diff --git a/src/schemas/channels.ts b/src/schemas/channels.ts deleted file mode 100644 index b485a7e4..00000000 --- a/src/schemas/channels.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Channels introduction, see: https://wechatwiki.com/wechat-resources/wechat-channels-short-video-feature-complete-guide/ - */ -export interface ChannelsPayload { - authorAvatar: string, - authorNickname: string, - coverageUrl: string, - title: string, - videoUrl: string, -} diff --git a/src/schemas/message.ts b/src/schemas/message.ts index 759555c2..ddaf8781 100644 --- a/src/schemas/message.ts +++ b/src/schemas/message.ts @@ -16,7 +16,7 @@ export enum MessageType { Recalled = 13, // Recalled(10002) Url = 14, // Url(5) Video = 15, // Video(4), Video(43) - Channels = 16, // Channels(141) + VideoPost = 16, // VideoPost(141) } /** diff --git a/src/schemas/video-post.ts b/src/schemas/video-post.ts new file mode 100644 index 00000000..f01647b9 --- /dev/null +++ b/src/schemas/video-post.ts @@ -0,0 +1,9 @@ +/** + * weixin VideoPost(Channels) introduction, see: https://wechatwiki.com/wechat-resources/wechat-channels-short-video-feature-complete-guide/ + */ +export interface VideoPostPayload { + authorId?: string, + coverageUrl?: string, + title: string, + videoUrl: string, +} From fce66d02d126b0bc53bfc44af8d31b27f1f3145f Mon Sep 17 00:00:00 2001 From: su-chang Date: Wed, 8 Sep 2021 19:42:50 +0800 Subject: [PATCH 06/12] 0.43.14 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1897199a..c3ffefa1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-puppet", - "version": "0.43.13", + "version": "0.43.14", "description": "Abstract Puppet for Wechaty", "type": "module", "exports": { From 5272bc35691b8cb271a19ed6aa7d74265a43e1dd Mon Sep 17 00:00:00 2001 From: su-chang Date: Wed, 8 Sep 2021 19:44:12 +0800 Subject: [PATCH 07/12] fix: style --- src/schemas/video-post.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/schemas/video-post.ts b/src/schemas/video-post.ts index f01647b9..b7cd6469 100644 --- a/src/schemas/video-post.ts +++ b/src/schemas/video-post.ts @@ -2,8 +2,8 @@ * weixin VideoPost(Channels) introduction, see: https://wechatwiki.com/wechat-resources/wechat-channels-short-video-feature-complete-guide/ */ export interface VideoPostPayload { - authorId?: string, - coverageUrl?: string, - title: string, - videoUrl: string, + authorId? : string, + coverageUrl? : string, + title : string, + videoUrl : string, } From 2c4744dda7aa2ad16c07a0fe3d14c88ab83780c0 Mon Sep 17 00:00:00 2001 From: su-chang Date: Wed, 8 Sep 2021 19:51:50 +0800 Subject: [PATCH 08/12] fix: export bug --- src/mod.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mod.ts b/src/mod.ts index ba846532..bb2a9ebd 100644 --- a/src/mod.ts +++ b/src/mod.ts @@ -98,9 +98,9 @@ import type { import type { MiniProgramPayload, } from './schemas/mini-program.js' -export { - ChannelsPayload, -} from './schemas/channels.js' +import type { + VideoPostPayload, +} from './schemas/video-post.js' import type { PuppetOptions, @@ -162,6 +162,7 @@ export type { RoomPayload, RoomQueryFilter, UrlLinkPayload, + VideoPostPayload, } export { From def40e1a9f6e42a7b42c602f705d30cb0d6dcb33 Mon Sep 17 00:00:00 2001 From: su-chang Date: Wed, 8 Sep 2021 21:06:22 +0800 Subject: [PATCH 09/12] feat: add comment and list related method and interface --- src/mod.ts | 8 ++++++++ src/puppet.ts | 25 +++++++++++++++++++++-- src/schemas/comment.ts | 7 +++++++ src/schemas/list.ts | 4 ++++ tests/fixtures/puppet-test/puppet-test.ts | 21 +++++++++++++++++++ tests/fixtures/smoke-testing.ts | 22 ++++++++++++++++++++ 6 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 src/schemas/comment.ts create mode 100644 src/schemas/list.ts diff --git a/src/mod.ts b/src/mod.ts index b1a372a3..7224ed38 100644 --- a/src/mod.ts +++ b/src/mod.ts @@ -98,6 +98,12 @@ import type { import type { MiniProgramPayload, } from './schemas/mini-program.js' +import type { + CommentPayload, +} from './schemas/comment.js' +import type { + ListOption, +} from './schemas/list.js' import type { PuppetOptions, @@ -159,6 +165,8 @@ export type { RoomPayload, RoomQueryFilter, UrlLinkPayload, + CommentPayload, + ListOption, } export { diff --git a/src/puppet.ts b/src/puppet.ts index 46fcba1f..9c5d0a97 100644 --- a/src/puppet.ts +++ b/src/puppet.ts @@ -82,9 +82,11 @@ import { PuppetOptions, YOU, } from './schemas/puppet.js' -import { PayloadType } from './schemas/payload.js' +import { PayloadType } from './schemas/payload.js' -import { PuppetEventEmitter } from './events.js' +import { PuppetEventEmitter } from './events.js' +import { ListOption } from './schemas/list.js' +import { CommentPayload } from './schemas/comment.js' const DEFAULT_WATCHDOG_TIMEOUT = 60 let PUPPET_COUNTER = 0 @@ -504,6 +506,25 @@ export abstract class Puppet extends PuppetEventEmitter { abstract tagContactList () : Promise abstract tagContactRemove (tagId: string, contactId: string) : Promise + /** + * + * Comment + * + */ + abstract comment (messageId: string, content: string) : Promise + abstract replyComment (commentId: string, content: string) : Promise + abstract revokeComment (commentId: string) : Promise + abstract listComments (messageId: string, option: ListOption) : Promise + + /** + * + * Like + * + */ + abstract like (messageId: string) : Promise + abstract cancel (messageId: string) : Promise + abstract listLikes (messageId: string, option: ListOption) : Promise + /** * * Contact diff --git a/src/schemas/comment.ts b/src/schemas/comment.ts new file mode 100644 index 00000000..4a366b90 --- /dev/null +++ b/src/schemas/comment.ts @@ -0,0 +1,7 @@ +export interface CommentPayload { + id? : string, + content : string, + creatorId : string, + messageId : string, + replyId? : string, // replied comment id +} diff --git a/src/schemas/list.ts b/src/schemas/list.ts new file mode 100644 index 00000000..8355c912 --- /dev/null +++ b/src/schemas/list.ts @@ -0,0 +1,4 @@ +export interface ListOption { + pageSize: number, + currentPage: number, +} diff --git a/tests/fixtures/puppet-test/puppet-test.ts b/tests/fixtures/puppet-test/puppet-test.ts index c1062e8c..4d6d77eb 100644 --- a/tests/fixtures/puppet-test/puppet-test.ts +++ b/tests/fixtures/puppet-test/puppet-test.ts @@ -13,6 +13,8 @@ import { RoomMemberPayload, RoomQueryFilter, ContactQueryFilter, + CommentPayload, + ListOption, } from '../../../src/mod.js' /** @@ -126,6 +128,25 @@ class PuppetTest extends Puppet { */ override async conversationReadMark (conversationId: string, hasRead?: boolean): Promise { void { conversationId, hasRead } } + /** + * + * Comment + * + */ + override async comment (messageId: string, content: string) : Promise { return { messageId, content} as any } + override async replyComment (commentId: string, content: string) : Promise { return { commentId, content} as any } + override async revokeComment (commentId: string) : Promise { return { commentId } as any } + override async listComments (messageId: string, option: ListOption) : Promise { return { messageId, option} as any } + + /** + * + * Like + * + */ + override async like (messageId: string) : Promise { return { messageId } as any} + override async cancel (messageId: string) : Promise { return { messageId } as any} + override async listLikes (messageId: string, option: ListOption) : Promise { return { messageId, option } as any} + /** * * Room Invitation diff --git a/tests/fixtures/smoke-testing.ts b/tests/fixtures/smoke-testing.ts index 4c16a28e..b4b82675 100644 --- a/tests/fixtures/smoke-testing.ts +++ b/tests/fixtures/smoke-testing.ts @@ -23,6 +23,8 @@ import { UrlLinkPayload, MiniProgramPayload, + CommentPayload, + ListOption, VERSION, } from 'wechaty-puppet' @@ -121,6 +123,26 @@ class PuppetTest extends Puppet { */ override async conversationReadMark (conversationId: string, hasRead?: boolean) : Promise { void conversationId, void hasRead } + /** + * + * Comment + * + */ + override async comment (messageId: string, content: string) : Promise { return { messageId, content} as any } + override async replyComment (commentId: string, content: string) : Promise { return { commentId, content} as any } + override async revokeComment (commentId: string) : Promise { return { commentId } as any } + override async listComments (messageId: string, option: ListOption) : Promise { return { messageId, option} as any } + + /** + * + * Like + * + */ + override async like (messageId: string) : Promise { return { messageId } as any} + override async cancel (messageId: string) : Promise { return { messageId } as any} + override async listLikes (messageId: string, option: ListOption) : Promise { return { messageId, option } as any} + + /** * * Room Invitation From e11408716a826905f1ff15f516c5d24238345365 Mon Sep 17 00:00:00 2001 From: su-chang Date: Thu, 9 Sep 2021 09:47:11 +0800 Subject: [PATCH 10/12] fix: style --- src/puppet.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/puppet.ts b/src/puppet.ts index 9c5d0a97..b66e236b 100644 --- a/src/puppet.ts +++ b/src/puppet.ts @@ -78,6 +78,12 @@ import type { import type { MiniProgramPayload, } from './schemas/mini-program.js' +import type { + ListOption, +} from './schemas/list.js' +import type { + CommentPayload, +} from './schemas/comment.js' import { PuppetOptions, YOU, @@ -85,8 +91,6 @@ import { import { PayloadType } from './schemas/payload.js' import { PuppetEventEmitter } from './events.js' -import { ListOption } from './schemas/list.js' -import { CommentPayload } from './schemas/comment.js' const DEFAULT_WATCHDOG_TIMEOUT = 60 let PUPPET_COUNTER = 0 From 6115166dc1faf79306e5e7ecd265a47b700f80d6 Mon Sep 17 00:00:00 2001 From: su-chang Date: Thu, 9 Sep 2021 11:26:16 +0800 Subject: [PATCH 11/12] fix: add messageVideoPost and messageSendVideoPost --- src/puppet.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/puppet.ts b/src/puppet.ts index 46fcba1f..3cc705be 100644 --- a/src/puppet.ts +++ b/src/puppet.ts @@ -78,6 +78,9 @@ import type { import type { MiniProgramPayload, } from './schemas/mini-program.js' +import type { + VideoPostPayload, +} from './schemas/video-post.js' import { PuppetOptions, YOU, @@ -840,6 +843,7 @@ export abstract class Puppet extends PuppetEventEmitter { abstract messageImage (messageId: string, imageType: ImageType) : Promise abstract messageMiniProgram (messageId: string) : Promise abstract messageUrl (messageId: string) : Promise + abstract messageVideoPost (messageId: string) : Promise abstract messageForward (conversationId: string, messageId: string,) : Promise abstract messageSendContact (conversationId: string, contactId: string) : Promise @@ -847,6 +851,7 @@ export abstract class Puppet extends PuppetEventEmitter { abstract messageSendMiniProgram (conversationId: string, miniProgramPayload: MiniProgramPayload) : Promise abstract messageSendText (conversationId: string, text: string, mentionIdList?: string[]) : Promise abstract messageSendUrl (conversationId: string, urlLinkPayload: UrlLinkPayload) : Promise + abstract messageSendVideoPost (conversationId: string, videoPostPayload: VideoPostPayload) : Promise abstract messageRecall (messageId: string) : Promise From 1a5a4f99f4c894e696ffebd3454e5e244407ca90 Mon Sep 17 00:00:00 2001 From: su-chang Date: Fri, 10 Sep 2021 15:43:04 +0800 Subject: [PATCH 12/12] fix: discard comment payload, rename some methods --- src/mod.ts | 4 --- src/puppet.ts | 41 +++++++++++------------ src/schemas/comment.ts | 7 ---- src/schemas/message.ts | 8 +++++ src/schemas/video-post.ts | 2 +- tests/fixtures/puppet-test/puppet-test.ts | 15 ++++----- tests/fixtures/smoke-testing.ts | 15 ++++----- 7 files changed, 42 insertions(+), 50 deletions(-) delete mode 100644 src/schemas/comment.ts diff --git a/src/mod.ts b/src/mod.ts index f603ea57..af08bcc2 100644 --- a/src/mod.ts +++ b/src/mod.ts @@ -101,9 +101,6 @@ import type { import type { VideoPostPayload, } from './schemas/video-post.js' -import type { - CommentPayload, -} from './schemas/comment.js' import type { ListOption, } from './schemas/list.js' @@ -169,7 +166,6 @@ export type { RoomQueryFilter, UrlLinkPayload, VideoPostPayload, - CommentPayload, ListOption, } diff --git a/src/puppet.ts b/src/puppet.ts index e107d4fe..83fc0242 100644 --- a/src/puppet.ts +++ b/src/puppet.ts @@ -84,9 +84,6 @@ import type { import type { ListOption, } from './schemas/list.js' -import type { - CommentPayload, -} from './schemas/comment.js' import { PuppetOptions, YOU, @@ -513,25 +510,6 @@ export abstract class Puppet extends PuppetEventEmitter { abstract tagContactList () : Promise abstract tagContactRemove (tagId: string, contactId: string) : Promise - /** - * - * Comment - * - */ - abstract comment (messageId: string, content: string) : Promise - abstract replyComment (commentId: string, content: string) : Promise - abstract revokeComment (commentId: string) : Promise - abstract listComments (messageId: string, option: ListOption) : Promise - - /** - * - * Like - * - */ - abstract like (messageId: string) : Promise - abstract cancel (messageId: string) : Promise - abstract listLikes (messageId: string, option: ListOption) : Promise - /** * * Contact @@ -858,6 +836,25 @@ export abstract class Puppet extends PuppetEventEmitter { */ abstract conversationReadMark (conversationId: string, hasRead?: boolean) : Promise + /** + * + * Like + * + */ + abstract likeThis (messageId: string) : Promise + abstract likeCancel (messageId: string) : Promise + abstract likeList (messageId: string, option: ListOption) : Promise + + /** + * + * Comment + * + */ + abstract commentContent (messageId: string, content: string) : Promise + abstract commentReply (commentId: string, content: string) : Promise + abstract commentRevoke (commentId: string) : Promise + abstract commentList (messageId: string, option: ListOption) : Promise + /** * * Message diff --git a/src/schemas/comment.ts b/src/schemas/comment.ts deleted file mode 100644 index 4a366b90..00000000 --- a/src/schemas/comment.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface CommentPayload { - id? : string, - content : string, - creatorId : string, - messageId : string, - replyId? : string, // replied comment id -} diff --git a/src/schemas/message.ts b/src/schemas/message.ts index ddaf8781..035ca75c 100644 --- a/src/schemas/message.ts +++ b/src/schemas/message.ts @@ -82,6 +82,7 @@ export interface MessagePayloadBase { // contactId? : string, // Contact ShareCard filename? : string, + quoteId? : string, text? : string, timestamp : number, // Huan(202001): we support both seconds & milliseconds in Wechaty now. type : MessageType, @@ -100,11 +101,18 @@ export interface MessagePayloadTo { roomId? : string, toId : string, // if to is not set, then room must be set } +/** @hidden */ +export interface MessagePayloadComment { + fromId : string, + parentId : string, + toId? : string, +} export type MessagePayload = MessagePayloadBase & ( MessagePayloadRoom | MessagePayloadTo + | MessagePayloadComment ) export interface MessageQueryFilter { diff --git a/src/schemas/video-post.ts b/src/schemas/video-post.ts index b7cd6469..bb947810 100644 --- a/src/schemas/video-post.ts +++ b/src/schemas/video-post.ts @@ -3,7 +3,7 @@ */ export interface VideoPostPayload { authorId? : string, - coverageUrl? : string, + coverUrl? : string, title : string, videoUrl : string, } diff --git a/tests/fixtures/puppet-test/puppet-test.ts b/tests/fixtures/puppet-test/puppet-test.ts index 4d6d77eb..0338c668 100644 --- a/tests/fixtures/puppet-test/puppet-test.ts +++ b/tests/fixtures/puppet-test/puppet-test.ts @@ -13,7 +13,6 @@ import { RoomMemberPayload, RoomQueryFilter, ContactQueryFilter, - CommentPayload, ListOption, } from '../../../src/mod.js' @@ -133,19 +132,19 @@ class PuppetTest extends Puppet { * Comment * */ - override async comment (messageId: string, content: string) : Promise { return { messageId, content} as any } - override async replyComment (commentId: string, content: string) : Promise { return { commentId, content} as any } - override async revokeComment (commentId: string) : Promise { return { commentId } as any } - override async listComments (messageId: string, option: ListOption) : Promise { return { messageId, option} as any } + override async commentContent (messageId: string, content: string) : Promise { return { messageId, content} as any } + override async commentReply (commentId: string, content: string) : Promise { return { commentId, content} as any } + override async commentRevoke (commentId: string) : Promise { return { commentId } as any } + override async commentList (messageId: string, option: ListOption) : Promise { return { messageId, option} as any } /** * * Like * */ - override async like (messageId: string) : Promise { return { messageId } as any} - override async cancel (messageId: string) : Promise { return { messageId } as any} - override async listLikes (messageId: string, option: ListOption) : Promise { return { messageId, option } as any} + override async likeThis (messageId: string) : Promise { return { messageId } as any} + override async likeCancel (messageId: string) : Promise { return { messageId } as any} + override async likeList (messageId: string, option: ListOption) : Promise { return { messageId, option } as any} /** * diff --git a/tests/fixtures/smoke-testing.ts b/tests/fixtures/smoke-testing.ts index b4b82675..4592bf08 100644 --- a/tests/fixtures/smoke-testing.ts +++ b/tests/fixtures/smoke-testing.ts @@ -128,20 +128,19 @@ class PuppetTest extends Puppet { * Comment * */ - override async comment (messageId: string, content: string) : Promise { return { messageId, content} as any } - override async replyComment (commentId: string, content: string) : Promise { return { commentId, content} as any } - override async revokeComment (commentId: string) : Promise { return { commentId } as any } - override async listComments (messageId: string, option: ListOption) : Promise { return { messageId, option} as any } + override async commentContent (messageId: string, content: string) : Promise { return { messageId, content} as any } + override async commentReply (commentId: string, content: string) : Promise { return { commentId, content} as any } + override async commentRevoke (commentId: string) : Promise { return { commentId } as any } + override async commentList (messageId: string, option: ListOption) : Promise { return { messageId, option} as any } /** * * Like * */ - override async like (messageId: string) : Promise { return { messageId } as any} - override async cancel (messageId: string) : Promise { return { messageId } as any} - override async listLikes (messageId: string, option: ListOption) : Promise { return { messageId, option } as any} - + override async likeThis (messageId: string) : Promise { return { messageId } as any} + override async likeCancel (messageId: string) : Promise { return { messageId } as any} + override async likeList (messageId: string, option: ListOption) : Promise { return { messageId, option } as any} /** *