-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
message.mentioned() does not work as expected #512
Comments
Is the bot's wechat name is "bot"? you should do something like this: const bot = wechaty.instance()
const contactList = m.mentioned()
if (contactList[0] === bot.name()) {
console.log('mentioned bot')
} |
yes, 'bot' is actually the real name. (i changed it to 'bot' here for some confidential reason, apologize for it): apparently the following code snippet (line 476 - 481 in
i'm not familiar with typescript, perhaps something unexpected happened in room.ts: memberAll()? It's just a pure guess hypnosis though, any advice would be appreciated. |
so could you log the following result for me? console.log(bot)
console.log(room) |
message sent:
console.log('@room:', JSON.stringify(room)):
console.log('@room.member(新知客助手)', JSON.stringify(room.member('新知客助手')):
console.log('@room.memberList():', JSON.stringify(room.memberList())):
final log:
|
So you mean you can use function |
no, room.member() actually works fine. the problem is message.mentioned() always returns an empty array. i also tried to run npm version and print logs in message.ts, it seems something unexpected happened between line 476 - 481 as comments described above. code snippet here: https://gist.github.com/galendai/831bf2c415f38c2a051fe101dd6c2578 |
i think this is only a syntax error, see my pr #531 contactList = [].concat.apply([],
mentionList.map(member => {
room.memberAll(member)
})
.filter(contact => !!contact),
) you need to use return in arrow function when using contactList = [].concat.apply([],
mentionList.map(member => {
return room.memberAll(member)
})
.filter(contact => !!contact),
) or remove contactList = [].concat.apply([],
mentionList.map(member => room.memberAll(member))
.filter(contact => !!contact),
) |
@FlyingBlazer Thanks for your reply, yes, this is my syntax error and I have fixed it until author merge. |
Provide Your Network Information
Expected behavior
The message.mentioned() should return the corrected mentioned contact list.
Actual behavior
It always return an empty array, prints the log:
03:25:34 WARN Message message.mentioned() can not found member using room.member() from mentionList, metion string: ["bot"]
Steps to reproduce the behavior (and fixes, if any)
Remark:
The message is sent form iPhone 6P.
The text was updated successfully, but these errors were encountered: