From 18331b4e408bedd5037a8a51258cc92db49553dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=AE=87=E9=9D=96?= <545641826@qq.com> Date: Mon, 19 Jul 2021 10:05:49 -0400 Subject: [PATCH 01/11] Introduce the dotenv module; update package.json; --- .gitignore | 1 + bin/matrix-appservice-wechaty.ts | 2 ++ package.json | 5 ++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4cf3f3f..c1ce237 100644 --- a/.gitignore +++ b/.gitignore @@ -66,3 +66,4 @@ t/ .DS_Store .idea +config.yaml diff --git a/bin/matrix-appservice-wechaty.ts b/bin/matrix-appservice-wechaty.ts index d56ae30..00402ea 100644 --- a/bin/matrix-appservice-wechaty.ts +++ b/bin/matrix-appservice-wechaty.ts @@ -6,7 +6,9 @@ import { log, VERSION, } from '../src/' +import dotenv from 'dotenv' +dotenv.config() async function main () { if (process.env.LOG_LEVEL) { log.level(process.env.LOG_LEVEL as any) diff --git a/package.json b/package.json index e2c624c..930a259 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,8 @@ "lint:es": "eslint --ignore-pattern tests/fixtures/ '{bin,src,tests}/**/*.ts' ", "lint:ts": "tsc --noEmit", "dev": "LOG_LEVEL=silly ts-node bin/matrix-appservice-wechaty.ts", + "dev:genarate-registration": "ts-node bin/matrix-appservice-wechaty.ts --config config.yaml --url http://localhost:8788 --generate-registration", + "dev:service": "ts-node bin/matrix-appservice-wechaty.ts --config config.yaml --file wechaty-registration.yaml", "dev:watch": "LOG_LEVEL=silly npx nodemon --watch '{bin,src,tests}/**/*.ts' --exec './node_modules/.bin/ts-node' bin/matrix-appservice-wechaty.ts", "pack": "npm pack", "sloc": "sloc bin scripts src tests --details --format cli-table --keys total,source,comment && sloc bin scripts src tests", @@ -40,10 +42,11 @@ "homepage": "https://github.com/huan/matrix-appservice-wechaty#readme", "dependencies": { "cuid": "^2.1.8", + "dotenv": "^10.0.0", "matrix-appservice-bridge": "^2.4.1", "read-pkg-up": "^7.0.1", "update-notifier": "^5.1.0", - "wechaty": "^0.62.2" + "wechaty": "^0.62.3" }, "devDependencies": { "@chatie/eslint-config": "^0.12.3", From ea138f1dd569bf23939fde22c40305a61660ce9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=AE=87=E9=9D=96?= <545641826@qq.com> Date: Mon, 19 Jul 2021 10:14:03 -0400 Subject: [PATCH 02/11] 0.8.29 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 930a259..d236196 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-appservice-wechaty", - "version": "0.8.28", + "version": "0.8.29", "description": "Matrix Application Services Bridge for Wechat", "main": "dist/src/index.js", "typings": "dist/src/index.d.ts", From 907df4bcb65bdec1a6b60cb9c6c40b4552b1c7cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=AE=87=E9=9D=96?= <545641826@qq.com> Date: Mon, 19 Jul 2021 11:44:51 -0400 Subject: [PATCH 03/11] support receive image in both padlocal and web protocol --- src/appservice-manager.ts | 56 ++++++++++++++++++++++++++++++++------- src/middle-manager.ts | 11 +++++--- src/wechaty-manager.ts | 2 +- 3 files changed, 54 insertions(+), 15 deletions(-) diff --git a/src/appservice-manager.ts b/src/appservice-manager.ts index 3c65a9f..177196d 100644 --- a/src/appservice-manager.ts +++ b/src/appservice-manager.ts @@ -9,6 +9,9 @@ import { AppServiceRegistration, } from 'matrix-appservice-bridge' +import { Message } from 'wechaty' +import { MessageType } from 'wechaty-puppet' + import { log, } from './config' @@ -108,12 +111,13 @@ export class AppserviceManager extends Manager { } public async sendMessage ( - withText : string, + message : string | Message, inRoom : MatrixRoom, fromUser? : MatrixUser, ) { + const text = typeof (message) === 'string' ? message : message.text() log.verbose('AppserviceManager', 'sendMessage(%s%s%s)', - withText.substr(0, 100), + text.substr(0, 100), inRoom ? ', ' + inRoom.getId() : '', @@ -122,18 +126,50 @@ export class AppserviceManager extends Manager { : '', ) - try { - let matrixUserId - - if (fromUser) { - matrixUserId = fromUser && fromUser.getId() + const intent = this.bridge.getIntent(fromUser && fromUser.getId()) + + if (typeof (message) !== 'string') { + switch (message.type()) { + case MessageType.Unknown: + break + case MessageType.Attachment: + break + case MessageType.Audio: + break + case MessageType.Contact: // image in ipad protocol is Emoticon + break + case MessageType.Emoticon: case MessageType.Image: + // image in web protocol is Image, in ipad protocol is Emoticon + try { + const file = await message.toFileBox() + const buffer = await file.toBuffer() + // XXX It is recommended to use a digital summary to construct the file name to avoid repeated uploads. + // digital summary consuming too much computing resources, use the url to lable it is better. + const url = await intent.uploadContent(buffer, { + name: file.name, + type: file.mimeType === 'emoticon' ? 'image/gif' : file.mimeType, + }) + await intent.sendMessage( + inRoom.getId(), + { + body: 'Image', + info: {}, + msgtype: 'm.image', + url: url, + } + ) + } catch (e) { + log.error(`AppserviceManager', 'sendMessage() rejection from ${fromUser ? fromUser.getId() : 'BOT'} to room ${inRoom.getId()}`) + throw e + } + return } + } - const intent = this.bridge.getIntent(matrixUserId) - + try { await intent.sendText( inRoom.getId(), - withText, + text, ) } catch (e) { log.error(`AppserviceManager', 'sendMessage() rejection from ${fromUser ? fromUser.getId() : 'BOT'} to room ${inRoom.getId()}`) diff --git a/src/middle-manager.ts b/src/middle-manager.ts index 9e869c2..1f1b956 100644 --- a/src/middle-manager.ts +++ b/src/middle-manager.ts @@ -2,6 +2,7 @@ import { Room as WechatyRoom, Contact as WechatyUser, Wechaty, + Message, } from 'wechaty' import { @@ -461,16 +462,18 @@ export class MiddleManager extends Manager { /** * Send message from service bot to the bridge consumer */ - public async directMessageToMatrixConsumer (text: string, from: Wechaty): Promise + public async directMessageToMatrixConsumer (message: string, from: Wechaty): Promise /** * Send message from user to the bridge consumer */ - public async directMessageToMatrixConsumer (text: string, from: WechatyUser): Promise + public async directMessageToMatrixConsumer (message: string, from: WechatyUser): Promise + public async directMessageToMatrixConsumer (message: Message, from: WechatyUser): Promise public async directMessageToMatrixConsumer ( - text: string, + message: string | Message, from: WechatyUser | Wechaty, ): Promise { + const text = typeof (message) === 'string' ? message : message.text() log.verbose('MiddleManager', 'directMessageToMatrixConsumer("%s", "%s")', text, from @@ -494,7 +497,7 @@ export class MiddleManager extends Manager { } await this.appserviceManager.sendMessage( - text, + message, matrixRoom, matrixUser, ) diff --git a/src/wechaty-manager.ts b/src/wechaty-manager.ts index 3d0e75f..6a13da2 100644 --- a/src/wechaty-manager.ts +++ b/src/wechaty-manager.ts @@ -308,7 +308,7 @@ export class WechatyManager extends Manager { throw new Error('can not found from contact for wechat message') } - await this.middleManager.directMessageToMatrixConsumer(onWechatyMessage.text(), from) + await this.middleManager.directMessageToMatrixConsumer(onWechatyMessage, from) } async processRoomMessage ( From 88b1d64cf53018a537397defd596f55447e9080a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=AE=87=E9=9D=96?= <545641826@qq.com> Date: Thu, 22 Jul 2021 04:02:59 -0400 Subject: [PATCH 04/11] rebase and fix deprecated warn --- src/wechaty-manager.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wechaty-manager.ts b/src/wechaty-manager.ts index 6a13da2..dd45750 100644 --- a/src/wechaty-manager.ts +++ b/src/wechaty-manager.ts @@ -269,8 +269,8 @@ export class WechatyManager extends Manager { ): Promise { log.verbose('WechatyManager', 'onMessage("%s") from "%s" to "%s" with age "%s" (timestamp: "%s")', message, - message.from()!.id, - message.to()!.id, + message.talker()!.id, + (message.to() || message.room())!.id, message.age(), (message as any).payload.timestamp, ) @@ -303,7 +303,7 @@ export class WechatyManager extends Manager { // forMatrixConsumer.getId(), ) - const from = onWechatyMessage.from() + const from = onWechatyMessage.talker() if (!from) { throw new Error('can not found from contact for wechat message') } @@ -322,7 +322,7 @@ export class WechatyManager extends Manager { if (!room) { throw new Error('no room') } - const from = onWechatyMessage.from() + const from = onWechatyMessage.talker() if (!from) { throw new Error('no from') } From e6683faa47691f040a0bcc8db9384d3b0f477e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=AE=87=E9=9D=96?= <545641826@qq.com> Date: Fri, 23 Jul 2021 02:30:17 -0400 Subject: [PATCH 05/11] Merge branch 'wechaty-master' into support-image-message --- package.json | 4 ++-- src/appservice-manager.ts | 19 +++++++++++++++++++ src/middle-manager.ts | 22 ++++++++++++++++++++-- src/wechaty-manager.ts | 6 ++++++ 4 files changed, 47 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index d236196..dcd8bac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-appservice-wechaty", - "version": "0.8.29", + "version": "0.8.30", "description": "Matrix Application Services Bridge for Wechat", "main": "dist/src/index.js", "typings": "dist/src/index.d.ts", @@ -43,7 +43,7 @@ "dependencies": { "cuid": "^2.1.8", "dotenv": "^10.0.0", - "matrix-appservice-bridge": "^2.4.1", + "matrix-appservice-bridge": "^2.7.0", "read-pkg-up": "^7.0.1", "update-notifier": "^5.1.0", "wechaty": "^0.62.3" diff --git a/src/appservice-manager.ts b/src/appservice-manager.ts index 177196d..fed196b 100644 --- a/src/appservice-manager.ts +++ b/src/appservice-manager.ts @@ -1,4 +1,5 @@ import cuid from 'cuid' +import { ReadStream } from 'fs' import { Bridge, @@ -7,6 +8,7 @@ import { UserBridgeStore, MatrixRoom, AppServiceRegistration, + FileUploadOpts, } from 'matrix-appservice-bridge' import { Message } from 'wechaty' @@ -246,6 +248,9 @@ export class AppserviceManager extends Manager { }) const matrixRoom = new MatrixRoom(roomInfo.room_id) + for await (const userId of userIdList.slice(1)) { + await this.bridge.getIntent(userId).join(matrixRoom.getId()) + } return matrixRoom } @@ -268,4 +273,18 @@ export class AppserviceManager extends Manager { return Object.keys(result.joined) } + public async setProfile (userId: string, avataUrl: string, displayName: string): Promise { + const intent = this.bridge.getIntent(userId) + await intent.setAvatarUrl(avataUrl) + await intent.setDisplayName(displayName) + } + + public async uploadContent ( + content: string | Buffer | ReadStream, + userId?: string, + opts?: FileUploadOpts | undefined + ): Promise { + return this.bridge.getIntent(userId).uploadContent(content, opts) + } + } diff --git a/src/middle-manager.ts b/src/middle-manager.ts index 1f1b956..7679da7 100644 --- a/src/middle-manager.ts +++ b/src/middle-manager.ts @@ -265,12 +265,29 @@ export class MiddleManager extends Manager { ) const matrixUserId = this.appserviceManager.generateVirtualUserId() - const matrixUser = new MatrixUser(matrixUserId) + + const avatarFile = await wechatyUser.avatar() + const avatarBuffer = await avatarFile.toBuffer() + const avatarUrl = await this.appserviceManager.uploadContent( + avatarBuffer, + matrixUserId, + { type: avatarFile.mimeType }, + ) + + const matrixUser = new MatrixUser(matrixUserId, { + avatarUrl, + displayName: wechatyUser.name(), + }) // userData.name = wechatyUser.name() + APPSERVICE_NAME_POSTFIX matrixUser.set(WECHATY_USER_DATA_KEY, userData) await this.appserviceManager.userStore.setMatrixUser(matrixUser) + void this.appserviceManager.setProfile( + matrixUserId, + avatarUrl, + wechatyUser.name() + ) return matrixUser } @@ -301,7 +318,8 @@ export class MiddleManager extends Manager { roomName = await wechatyRoomOrUser.topic() for await (const member of wechatyRoomOrUser) { const matrixUser = await this.matrixUser(member) - inviteeIdList.push(matrixUser.getId()) + this.wechatyManager.ifSelfWechaty(member.id) + || inviteeIdList.push(matrixUser.getId()) } } else if (wechatyRoomOrUser instanceof WechatyUser) { // User: direct message diff --git a/src/wechaty-manager.ts b/src/wechaty-manager.ts index dd45750..d60abc5 100644 --- a/src/wechaty-manager.ts +++ b/src/wechaty-manager.ts @@ -19,6 +19,7 @@ export class WechatyManager extends Manager { protected matrixWechatyDict: Map protected wechatyMatrixDict: WeakMap + protected selfWechaty: Wechaty | undefined public appserviceManager!: AppserviceManager public middleManager!: MiddleManager @@ -237,6 +238,7 @@ export class WechatyManager extends Manager { wechatyContact: Contact, ): Promise { log.verbose('WechatyManager', 'onLogin(%s)', wechatyContact) + this.selfWechaty = wechatyContact.wechaty const text = 'You are now logged in to Wechat. Your user name is: ' + wechatyContact.name() @@ -350,4 +352,8 @@ export class WechatyManager extends Manager { // ) } + public ifSelfWechaty (wechatyId:string):boolean { + return this.selfWechaty!.puppet.selfId() === wechatyId + } + } From ab7c9e1d82ae98d5bb3d4f99e3b68f5af4c8f9df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=AE=87=E9=9D=96?= <545641826@qq.com> Date: Fri, 23 Jul 2021 22:56:01 -0400 Subject: [PATCH 06/11] support send image in user contact. --- src/appservice-manager.ts | 7 +++++++ src/matrix-handler.ts | 26 +++++++++++++++++++++++--- src/middle-manager.ts | 8 ++------ 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/appservice-manager.ts b/src/appservice-manager.ts index fed196b..fa98441 100644 --- a/src/appservice-manager.ts +++ b/src/appservice-manager.ts @@ -287,4 +287,11 @@ export class AppserviceManager extends Manager { return this.bridge.getIntent(userId).uploadContent(content, opts) } + public async mxcUrlToHttp ( + mxcUrl: string, + ): Promise { + // also can use getHttpUriForMxc(this.baseUrl, mxcUrl, width, height, resizeMethod, allowDirectLinks); + return this.bridge.getIntent().client.mxcUrlToHttp(mxcUrl) + } + } diff --git a/src/matrix-handler.ts b/src/matrix-handler.ts index 2c5d43b..0c9861a 100644 --- a/src/matrix-handler.ts +++ b/src/matrix-handler.ts @@ -18,6 +18,7 @@ import { DialogManager } from './dialog-manager' import { MiddleManager } from './middle-manager' import { WechatyManager } from './wechaty-manager' import { UserManager } from './user-manager' +import { Contact, FileBox, Message, MiniProgram, UrlLink } from 'wechaty' export class MatrixHandler { @@ -326,9 +327,28 @@ export class MatrixHandler { const contact = await this.middleManager.wechatyUser(service) // const contact = await this.wechatyManager // .wechatyContact(service, user) - - const text = superEvent.event.content!.body - await contact.say(text + '') + const content = superEvent.event.content! + let mxcUrl = '' + let httpsUrl = '' + const body = superEvent.text() + let message : string|number|Message|Contact|FileBox|MiniProgram|UrlLink + = body + switch (content.msgtype) { + case 'm.text': + break + case 'm.image': case 'm.file': + mxcUrl = content.url as string + httpsUrl = await this.appserviceManager.mxcUrlToHttp(mxcUrl) + // XXX can't show Animation well in wechat. + message = FileBox.fromUrl( + httpsUrl, + body.indexOf('.') > -1 || content.msgtype !== 'm.image' + ? body + : `${mxcUrl.split('/').pop()}.gif`, + ) + } + // XXX removing the overload declarations may be a better choice. + await contact.say(message as any) } } diff --git a/src/middle-manager.ts b/src/middle-manager.ts index 7679da7..2cd56ad 100644 --- a/src/middle-manager.ts +++ b/src/middle-manager.ts @@ -479,14 +479,8 @@ export class MiddleManager extends Manager { /** * Send message from service bot to the bridge consumer - */ - public async directMessageToMatrixConsumer (message: string, from: Wechaty): Promise - /** * Send message from user to the bridge consumer */ - public async directMessageToMatrixConsumer (message: string, from: WechatyUser): Promise - public async directMessageToMatrixConsumer (message: Message, from: WechatyUser): Promise - public async directMessageToMatrixConsumer ( message: string | Message, from: WechatyUser | Wechaty, @@ -501,11 +495,13 @@ export class MiddleManager extends Manager { let matrixUser if (from instanceof WechatyUser) { + // receive message (in user side) matrixRoom = await this.matrixRoom(from) matrixUser = await this.matrixUser(from) } else if (from instanceof Wechaty) { + // send message (in user side) const consumerId = this.wechatyManager.matrixConsumerId(from) matrixRoom = await this.adminRoom(consumerId) From 86e830de1c5c250cbf7b91dadf581aa384f92360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=AE=87=E9=9D=96?= <545641826@qq.com> Date: Sat, 24 Jul 2021 04:01:27 -0400 Subject: [PATCH 07/11] can receive files in user contact, but have a problem: --- src/appservice-manager.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/appservice-manager.ts b/src/appservice-manager.ts index fa98441..f23d606 100644 --- a/src/appservice-manager.ts +++ b/src/appservice-manager.ts @@ -134,13 +134,11 @@ export class AppserviceManager extends Manager { switch (message.type()) { case MessageType.Unknown: break - case MessageType.Attachment: - break case MessageType.Audio: break case MessageType.Contact: // image in ipad protocol is Emoticon break - case MessageType.Emoticon: case MessageType.Image: + case MessageType.Emoticon: case MessageType.Image: case MessageType.Attachment: // image in web protocol is Image, in ipad protocol is Emoticon try { const file = await message.toFileBox() @@ -154,9 +152,9 @@ export class AppserviceManager extends Manager { await intent.sendMessage( inRoom.getId(), { - body: 'Image', + body: file.name, info: {}, - msgtype: 'm.image', + msgtype: message.type() === MessageType.Attachment ? 'm.file' : 'm.image', url: url, } ) From 7b1a1d980896705e798006be7a901db3d8208411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=AE=87=E9=9D=96?= <545641826@qq.com> Date: Sat, 24 Jul 2021 06:44:04 -0400 Subject: [PATCH 08/11] supports image and file messages for groups. --- src/matrix-handler.ts | 16 +++++++++++++--- src/wechaty-manager.ts | 4 +--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/matrix-handler.ts b/src/matrix-handler.ts index 0c9861a..06d9592 100644 --- a/src/matrix-handler.ts +++ b/src/matrix-handler.ts @@ -307,7 +307,9 @@ export class MatrixHandler { // superEvent.sender(), // FIXME: should be consumer // ) - await wechatyRoom.say(superEvent.event.content!.body as string || 'undefined') + const message = await this.superEvent2Message(superEvent) + // XXX removing the overload declarations may be a better choice. + await wechatyRoom.say(message as any) } catch (e) { log.error('MatrixHandler', 'processGroupMessage() rejection: %s', e.message) @@ -327,6 +329,15 @@ export class MatrixHandler { const contact = await this.middleManager.wechatyUser(service) // const contact = await this.wechatyManager // .wechatyContact(service, user) + + const message = await this.superEvent2Message(superEvent) + // XXX removing the overload declarations may be a better choice. + await contact.say(message as any) + } + + protected async superEvent2Message ( + superEvent: SuperEvent, + ):Promise { const content = superEvent.event.content! let mxcUrl = '' let httpsUrl = '' @@ -347,8 +358,7 @@ export class MatrixHandler { : `${mxcUrl.split('/').pop()}.gif`, ) } - // XXX removing the overload declarations may be a better choice. - await contact.say(message as any) + return message } } diff --git a/src/wechaty-manager.ts b/src/wechaty-manager.ts index d60abc5..94b97d6 100644 --- a/src/wechaty-manager.ts +++ b/src/wechaty-manager.ts @@ -329,13 +329,11 @@ export class WechatyManager extends Manager { throw new Error('no from') } - const text = onWechatyMessage.text() - const matrixRoom = await this.middleManager.matrixRoom(room) const matrixUser = await this.middleManager.matrixUser(from) await this.appserviceManager.sendMessage( - text, + onWechatyMessage, matrixRoom, matrixUser, ) From 22b1eb63f1bcd769cd0c4d83e2edcc5433bb5e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=AE=87=E9=9D=96?= <545641826@qq.com> Date: Sat, 24 Jul 2021 06:44:48 -0400 Subject: [PATCH 09/11] 0.8.31 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dcd8bac..cfb969a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-appservice-wechaty", - "version": "0.8.30", + "version": "0.8.31", "description": "Matrix Application Services Bridge for Wechat", "main": "dist/src/index.js", "typings": "dist/src/index.d.ts", From abcdbc9d4353d9ede350b45174bd63e69420718c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=AE=87=E9=9D=96?= <545641826@qq.com> Date: Tue, 27 Jul 2021 02:55:48 -0400 Subject: [PATCH 10/11] 0.8.32 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cfb969a..0447f63 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-appservice-wechaty", - "version": "0.8.31", + "version": "0.8.32", "description": "Matrix Application Services Bridge for Wechat", "main": "dist/src/index.js", "typings": "dist/src/index.d.ts", From 8de2664329f327f51f3cbb57858ea4e9aee10cfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=AE=87=E9=9D=96?= <545641826@qq.com> Date: Tue, 27 Jul 2021 10:58:23 -0400 Subject: [PATCH 11/11] more appropriate comments --- src/middle-manager.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/middle-manager.ts b/src/middle-manager.ts index 2cd56ad..3d67ed5 100644 --- a/src/middle-manager.ts +++ b/src/middle-manager.ts @@ -495,13 +495,13 @@ export class MiddleManager extends Manager { let matrixUser if (from instanceof WechatyUser) { - // receive message (in user side) + // receive messages from wecahty users(your friends) matrixRoom = await this.matrixRoom(from) matrixUser = await this.matrixUser(from) } else if (from instanceof Wechaty) { - // send message (in user side) + // xxx This block will not be called on the code now, send message (the messages said by your self on other device) const consumerId = this.wechatyManager.matrixConsumerId(from) matrixRoom = await this.adminRoom(consumerId)