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..b66e236b 100644 --- a/src/puppet.ts +++ b/src/puppet.ts @@ -78,13 +78,19 @@ 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, } 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' const DEFAULT_WATCHDOG_TIMEOUT = 60 let PUPPET_COUNTER = 0 @@ -504,6 +510,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