You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a group it is so convenient to message the bot using @botName
I was looking at the message API and trying to see how @mentions work
but looking at output from console.log(inspect(m)) . I don't see any special data that refers to the mentioned users.
Their names are included in the text of the message. If you change your name, then the mention will use the updated name (not the wechat ID)
So I guess the only way is to use message and match against the Room.memberList()
It just seems surprising this is left encoded in the message text and not as a userId in the data somewhere...
I guess that the memberList requires room.ready() and maybe not available all the time?
So we could provide this as an async API helper on the message object?
The text was updated successfully, but these errors were encountered:
I agree that if we have a room-mention / mention event for the room when we got mentioned will be very convenience.
How about let's design it like this:
// Global EventWechaty.instance().on('room-mention',(room,message)=>{// here we got message mentioned us})// or a specific Room EventRoom.find({name: 'test'}).then(room=>{room.on('mention',message=>{// here we got message mentioned us})})
Before we implement that, I suggest you can have a try with Room.member(name) to get the Contact by name in a Room. And I think you should not worry about room.ready() because the room will always be called ready() by Wechaty Framework before you received the event. (If it's not updated with the latest data, call room.refresh() instead)
In a group it is so convenient to message the bot using @botName
I was looking at the message API and trying to see how @mentions work
but looking at output from
console.log(inspect(m))
. I don't see any special data that refers to the mentioned users.Their names are included in the text of the message. If you change your name, then the mention will use the updated name (not the wechat ID)
So I guess the only way is to use message and match against the
Room.memberList()
It just seems surprising this is left encoded in the message text and not as a userId in the data somewhere...
I guess that the memberList requires room.ready() and maybe not available all the time?
So we could provide this as an async API helper on the message object?
The text was updated successfully, but these errors were encountered: