Message
所有的微信消息会被封装成一个Message 类
Last updated
Was this helpful?
所有的微信消息会被封装成一个Message 类
Last updated
Was this helpful?
Kind: global class
instance
⇒ Contact
| null
⇒ Contact
| null
⇒ Room
| null
~~[.content()](message.md#message-content)~~
. ⇒ string
⇒ Promise.
⇒ MessageType
⇒ boolean
⇒ Promise.>
⇒ Promise.
⇒ Promise.
⇒ number
~~[.file()](message.md#message-file)~~
⇒ Promise.
⇒ Promise.
static
Contact
获取发送消息的联系人
Contact
| null
获取消息发送的联系人。在微信群中,Message.to() 会返回null,使用Message.room()获取微信群信息。
Example
Room
| null
获取消息所在的微信群,如果这条消息不在微信群中,会返回null
Deprecated
string
获取消息的文本内容。
Promise
获取撤回消息的文本内容。
Promise.
回复多媒体、微信名片、文本或者链接给这条消息的发送者。
Param
Type
Description
textOrContactOrFileOrUrl
string
| Contact
| FileBox
| UrlLink
发送文本、名片或者文件
// 1. send Image
// 2. send Text
if (/^dong$/i.test(m.text())) { await msg.say('dingdingding') }
// 3. send Contact
if (/^lijiarui$/i.test(m.text())) { const contactCard = await bot.Contact.find({name: 'lijiarui'}) if (!contactCard) { console.log('not found') return } await msg.say(contactCard) }
})
// 4. send UrlLink
boolean
查看这条消息是否为机器人发送的。
Promise.
获取在群中@的用户列表。
Promise.
获取机器人是否在群里被@ 了
Promise.
转发收到的消息
Param
Type
Description
to
Sayable
| Array.
Room 或者 Contact。指的是收消息方。
消息发送的时间
number
消息的时差
例如: 消息在8:43:01
发送的,当我们在wechaty 上收到消息的时候,时间是8:43:15
,那么 age() 为 8:43:15 - 8:43:01 = 14 (seconds)
Deprecated
Promise.
从消息中提取多媒体文件并把它 存入到FileBox 里面。
Promise.
提取转发的微信好友名片内容,并封装成Contact 类型。
在缓存中找消息。
在缓存中找消息
Kind: instance method of Example
Kind: instance method of
Kind: instance method of Example
请使用
Kind: instance method of
Kind: instance method of Example
Kind: instance method of Example
这个功能是否能实现取决于你使用的是哪一个Puppet, 详情参考:
Kind: instance method of See:
你可以使用 来发送文件
if (/^ding$/i.test(m.text())) { const fileBox = FileBox.fromUrl('') await msg.say(fileBox) }
if (/^link$/i.test(m.text())) { const linkPayload = new UrlLnik({ description : 'Netty', thumbnailUrl: '', title : 'Netty', url : '', }) await msg.say(linkPayload) } .start()
Kind: instance method of
Returns: boolean
- - Return true
for send from self, false
for send from others.
Example
Kind: instance method of
Returns: Promise.>
- - Return message mentioned contactList
Example
Kind: instance method of
Returns: Promise.
- - Return true
for mention me.
Example
Kind: instance method of
Kind: instance method of
Kind: instance method of
使用
Kind: instance method of
这个方法是否能实现,取决于用的是什么Puppet,具体请看:
Kind: instance method of
这个方法是否能实现,取决于用的是什么Puppet,具体请看:
Kind: instance method of
Kind: static method of
Kind: static method of