room.say() 中参数类型为 TemplateStringsArray 时存在问题
Created by: SilentQianyi
Important:Please file the issue follow the template, or we won't help you to solve the problem.
0. Report Issue Guide
- Please run the following command and check whether the problem has been fixed:
rm -rf package-lock.json
rm -rf node_modules
npm install
-
Please search in FAQ List first, and make sure your problem has not been solved before.
-
Please search in the issue first, and make sure your problem had not been reported before
1. Versions
-
What is your wechaty version? Answer: 0.29.22
-
Which puppet are you using for wechaty? (padchat/puppeteer/padpro/...) Answer: wechaty-puppet-padplus
-
What is your wechaty-puppet-XXX(padchat/puppeteer/) version? Answer: 0.1.4
-
What is your node version? (run
node --version
) Answer: v10.17.0 -
What os are you using Answer: mac 10.12.6
2. Describe the bug
在群内通过 say() 方法 参数类型为 TemplateStringsArray 发送消息,当数组长度为1时报错
3. To Reproduce
bot.on('message', async msg => {
const room = msg.room()
if (room) {
const contact = msg.from()
const templateStringsArray = [`@${contact.name()} 123`] as any
target.say(templateStringsArray, contact)
}
})
.start()
4. Expected behavior
我希望当文本内存在@name的内容时,不会额外增加@name
// TODO(huan) 20191222 it seems the following code will not happen,
// becasue it's equal the mentionList.length === 0 situation?
//
// } else if (textList.length === 1) {
// /**
// * Constructed mention string, skip inserting @ signs
// */
// return this.puppet.messageSendText(
// receiver,
// textList[0],
// mentionList.map(c => c.id),
// )
这段代码就是处理这种问题的
5. Actual behavior
If applicable, add screenshots to help explain your problem. But do not paste log screenshots here.
6. Full Output Logs
Set env WECHATY_LOG=silly
in order to set log level to silly, then we can get the full log (If you dosen't set log env, log level is info as default, we cannot get the full log)
We need full log instead of log screenshot or log fragments!
18:33:02 ERR Config ########################### 18:33:02 ERR Config unhandledRejection: Error: Can not say message, invalid Tagged Template. [object Promise] 18:33:02 ERR Config ########################### 18:33:02 ERR Config process.on(unhandledRejection) promise.catch(Can not say message, invalid Tagged Template.) Config Error: Can not say message, invalid Tagged Template. at AnotherOriginalClass. (/Users/apple/Work/weChaty/wechaty/src/user/room.ts:578:15) at Generator.next () at /Users/apple/Work/weChaty/wechaty/dist/src/user/room.js:8:71 at new Promise () at __awaiter (/Users/apple/Work/weChaty/wechaty/dist/src/user/room.js:4:12) at AnotherOriginalClass.sayTemplateStringsArray (/Users/apple/Work/weChaty/wechaty/dist/src/user/room.js:454:16) at AnotherOriginalClass. (/Users/apple/Work/weChaty/wechaty/src/user/room.ts:528:26) at Generator.next () at /Users/apple/Work/weChaty/wechaty/dist/src/user/room.js:8:71 at new Promise () at __awaiter (/Users/apple/Work/weChaty/wechaty/dist/src/user/room.js:4:12) at AnotherOriginalClass.say (/Users/apple/Work/weChaty/wechaty/dist/src/user/room.js:388:16) at /Users/apple/Work/weChaty/my-wechaty-project/index.ts:47:19 at step (/Users/apple/Work/weChaty/my-wechaty-project/index.ts:33:23) at Object.next (/Users/apple/Work/weChaty/my-wechaty-project/index.ts:14:53) at /Users/apple/Work/weChaty/my-wechaty-project/index.ts:8:71 at new Promise () at __awaiter (/Users/apple/Work/weChaty/my-wechaty-project/index.ts:4:12) at Wechaty. (/Users/apple/Work/weChaty/my-wechaty-project/index.ts:25:27) at Wechaty.on.args (/Users/apple/Work/weChaty/wechaty/src/wechaty.ts:553:18) at Wechaty.emit (events.js:198:13) at Wechaty.EventEmitter.emit (domain.js:448:20) at Wechaty.emit (/Users/apple/Work/weChaty/wechaty/src/wechaty.ts:317:18) at Wechaty. (/Users/apple/Work/weChaty/wechaty/src/wechaty.ts:661:18) at Generator.next () at fulfilled (/Users/apple/Work/weChaty/wechaty/dist/src/wechaty.js:5:58) (node:25231) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 3) 18:33:02 SILL PadplusManager setContactAndRoomData() initialize contact and room data.
$ WECHATY_LOG=silly node yourbot.js
Question: Paste your FULL(DO NOT ONLY PROVIDE FRAGMENTS) log messages
Answer:
7. Additional context
Add any other context about the problem here.
[bug]