diff --git a/package.json b/package.json index 11e8b55..5537f1f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-puppet-walnut", - "version": "1.11.8", + "version": "1.18.1", "description": "Puppet Walnut for Wechaty", "type": "module", "exports": { @@ -59,7 +59,7 @@ "@types/uuid": "^8.3.3" }, "peerDependencies": { - "wechaty-puppet": "^1.11.12" + "wechaty-puppet": "^1.18.3" }, "dependencies": { "axios": "^0.24.0", diff --git a/src/puppet-walnut.spec.ts b/src/puppet-walnut.spec.ts index 49efe51..36dd32c 100644 --- a/src/puppet-walnut.spec.ts +++ b/src/puppet-walnut.spec.ts @@ -53,9 +53,9 @@ test('message parser for text message', async t => { } const messagePayload = await puppet.messageRawPayloadParser(walnutMessagePayload as WalnutMessagePayload) t.ok( - messagePayload.toId === 'sip:106500@botplatform.rcs.domain.cn' + messagePayload.listenerId === 'sip:106500@botplatform.rcs.domain.cn' && messagePayload.roomId === undefined - && messagePayload.fromId === '17928222350' + && messagePayload.talkerId === '17928222350' && messagePayload.text === 'hello world' && messagePayload.type === PUPPET.types.Message.Text, ) @@ -95,9 +95,9 @@ test('message parser for image message', async t => { } const messagePayload = await puppet.messageRawPayloadParser(walnutMessagePayload as WalnutMessagePayload) t.ok( - messagePayload.toId === 'sip:106500@botplatform.rcs.domain.cn' + messagePayload.listenerId === 'sip:106500@botplatform.rcs.domain.cn' && messagePayload.roomId === undefined - && messagePayload.fromId === '17928222350' + && messagePayload.talkerId === '17928222350' && messagePayload.text === 'image' && messagePayload.type === PUPPET.types.Message.Image, ) @@ -137,9 +137,9 @@ test('message parser for file message', async t => { } const messagePayload = await puppet.messageRawPayloadParser(walnutMessagePayload as WalnutMessagePayload) t.ok( - messagePayload.toId === 'sip:106500@botplatform.rcs.domain.cn' + messagePayload.listenerId === 'sip:106500@botplatform.rcs.domain.cn' && messagePayload.roomId === undefined - && messagePayload.fromId === '17928222350' + && messagePayload.talkerId === '17928222350' && messagePayload.text === 'file' && messagePayload.type === PUPPET.types.Message.Attachment, ) diff --git a/src/puppet-walnut.ts b/src/puppet-walnut.ts index dbef760..f1c22a7 100644 --- a/src/puppet-walnut.ts +++ b/src/puppet-walnut.ts @@ -181,11 +181,11 @@ class PuppetWalnut extends PUPPET.Puppet { */ override async messageRawPayloadParser (rawPayload: WalnutMessagePayload): Promise { const res = { - fromId: rawPayload.senderAddress.replace('tel:+86', ''), id: rawPayload.messageId, + listenerId: rawPayload.destinationAddress, + talkerId: rawPayload.senderAddress.replace('tel:+86', ''), text: rawPayload.messageList[0]!.contentText.toString(), timestamp: Date.parse(rawPayload.dateTime), - toId: rawPayload.destinationAddress, type: PUPPET.types.Message.Text, } const file = rawPayload.messageList[0]?.contentText[0] as FileItem @@ -280,6 +280,43 @@ class PuppetWalnut extends PUPPET.Puppet { } } + /** + * + * Post + * + */ + override async postRawPayload (postId: string): Promise { + log.verbose('PuppetWalnut', 'postRawPayload(%s)', postId) + return { postId } as any + } + + override async postRawPayloadParser (rawPayload: any): Promise { + log.verbose('PuppetWalnut', 'postRawPayloadParser(%s)', rawPayload.id) + return rawPayload + } + + override async postPublish (payload: PUPPET.payloads.Post): Promise { + log.verbose('PuppetWalnut', 'postPublish({type: %s})', + PUPPET.types.Post[ + payload.type || PUPPET.types.Post.Unspecified + ], + ) + } + + override async postSearch ( + filter : PUPPET.filters.Post, + pagination? : PUPPET.filters.PaginationRequest, + ): Promise> { + log.verbose('PuppetWalnut', 'postSearch(%s, %s)', + JSON.stringify(filter), + JSON.stringify(pagination), + ) + return { + nextPageToken: undefined, + response: [], + } + } + } export default PuppetWalnut