Message
All wechat messages will be encapsulated as a Message.
Last updated
Was this helpful?
All wechat messages will be encapsulated as a Message.
Last updated
Was this helpful?
All wechat messages will be encapsulated as a Message.
Kind: global class
instance
⇒ Contact
| null
⇒ Contact
| null
⇒ Room
| null
⇒ string
⇒ Promise <void>
⇒ MessageType
⇒ boolean
⇒ Promise <Contact []>
⇒ Promise <boolean>
⇒ Promise <void>
⇒ Date
⇒ number
⇒ Promise <FileBox>
⇒ Promise <Contact>
⇒ Promise <UrlLink>
static
⇒ Promise <Message>
⇒ Promise <Message []>
Contact | null
Get the sender from a message.
Contact
| null
Get the destination of the message Message.to() will return null if a message is in a room, use Message.room() to get the room.
Example
Room
| null
Get the room from the message. If the message is not in a room, then will return null
Example
Deprecated
string
Get the text content of the message
Promise <Message | null>
Get the text content of the recalled message
Promise <void>
Reply a Text, Contact Card, Media File or Link message to the sender.
Param
Type
Description
textOrContactOrFileOrUrlLinkOrMiniProgram
string
| Contact
| FileBox
| UrlLink
| MiniProgram
Example
MessageType
Get the type from the message.
Tips: MessageType is Enum here. </br>
MessageType.Unknown
MessageType.Attachment
MessageType.Audio
MessageType.Contact
MessageType.Emoticon
MessageType.Image
MessageType.Text
MessageType.Video
MessageType.Url
boolean
Check if a message is sent by self.
Promise <Contact []>
Get message mentioned contactList.
Message event table as follows
Web
Mac PC Client
iOS Mobile
android Mobile
[You were mentioned] tip ([有人@我]的提示)
✘
√
√
√
Identify magic code (8197) by copy & paste in mobile
✘
√
√
✘
Identify magic code (8197) by programming
✘
✘
✘
✘
Identify two contacts with the same roomAlias by [You were mentioned] tip
✘
✘
√
√
Promise <boolean>
Check if a message is mention self.
Promise <void>
Forward the received message.
Param
Type
Description
to
Sayable
| Array
Room or Contact The recipient of the message, the room, or the contact
Example
Date
Message sent date
number
Returns the message age in seconds.
For example, the message is sent at time 8:43:01
, and when we received it in Wechaty, the time is 8:43:15
, then the age() will return 8:43:15 - 8:43:01 = 14 (seconds)
Deprecated
Promise <FileBox>
Extract the Media File from the Message, and put it into the FileBox.
Promise <Contact>
Get Share Card of the Message Extract the Contact Card from the Message, and encapsulate it into Contact class
Promise <UrlLink>
Get Url Link of the Message Extract the Url Link from the Message, and encapsulate it into UrlLink class
Promise <Message | null>
Find message in cache
Promise <Message []>
Find messages in cache
Kind: instance method of Example
Kind: instance method of
Kind: instance method of
use instead
Kind: instance method of
Kind: instance method of Example
Kind: instance method of Example
Tips: This function is depending on the Puppet Implementation, see
Kind: instance method of See:
send text, Contact, UrlLink, MiniProgram or file to bot. You can use to send file
Kind: instance method of Example
Kind: instance method of Returns: boolean
- - Return true
for send from self, false
for send from others. Example
Kind: instance method of Returns: Promise <Contact []>
- - Return message mentioned contactList Example
Kind: instance method of Returns: Promise <boolean>
- - Return true
for mention me. Example
Kind: instance method of
Kind: instance method of
Kind: instance method of
use instead
Kind: instance method of
Tips: This function is depending on the Puppet Implementation, see
Kind: instance method of
Tips: This function is depending on the Puppet Implementation, see
Kind: instance method of
Tips: This function is depending on the Puppet Implementation, see
Kind: instance method of
Kind: static method of
Kind: static method of