-
Notifications
You must be signed in to change notification settings - Fork 711
消息Message
HanSon edited this page Mar 30, 2017
·
5 revisions
微信有许多消息类型,例如 文字、语音、视频等等。
Message 是所有消息类的父类,也就是所有消息都含有以下的属性(之后每个消息类就不再讲解这些公共属性)。
Message的raw['MsgId']
为一个很重要的属性,代表着一个消息的ID,之后也会比较常用,特别在资源消息类中尤为常见。
所有的Message中的message都是经过html_entity_decode()
以及str_replace('<br/>', "\n", $content)
的处理
所有的message子类都会保存在Hanson\Vbot\Collections\Message
中,可以通过 message() 获取存储message的单例实例
属性 | 类型 | 含义 |
---|---|---|
from | array | 消息来源(群,联系人等) |
sender | array | 群消息发送者(只有消息来源为群主才不为空) |
content | string | 转为中文的内容 |
message | string | 转为格式后的消息 |
time | int | 消息发送的时间戳 |
fromType | string | 消息发送者类型 |
msg | array | 消息原始数据(已废弃) |
raw | array | 消息原始数据(之后每个消息类都会有栗子) |
消息来源
"MsgId": "8502319330630579",
"FromUserName": "@@b761d35ece918bbff572e875388dfba288933cf7cb708cfb0d39f511a829e669",
"ToUserName": "@f18e33e48ec385faaf4e766913bd53bb9ae0288c9272e8a2c892942f086389f8",
"MsgType": 47,
"Content": "@9780186f2beb5fe108d85384c55ca927:<br/><msg><emoji fromusername=\"kila602217914\" tousername=\"3769518846@chatroom\" type=\"2\" idbuffer=\"media:0_0\" md5=\"ebbf7cf829baba7d459076007d99e212\" len=\"530347\" productid=\"\" androidmd5=\"ebbf7cf829baba7d459076007d99e212\" androidlen=\"530347\" s60v3md5=\"ebbf7cf829baba7d459076007d99e212\" s60v3len=\"530347\" s60v5md5=\"ebbf7cf829baba7d459076007d99e212\" s60v5len=\"530347\" cdnurl=\"http://emoji.qpic.cn/wx_emoji/O74TaRhN6vJb3NmmoLtg2mT3u5w4pn2yrvfC9t6uRC0Aje0xCKfib5kKYXicnSeKpW/\" designerid=\"\" thumburl=\"\" encrypturl=\"http://emoji.qpic.cn/wx_emoji/O74TaRhN6vJb3NmmoLtg2mT3u5w4pn2yrvfC9t6uRC394gsoYV5JvibMevjTUgd43/\" aeskey=\"b1aa51fa21bf3fe2abd957839e6f0b0d\" width=\"220\" height=\"220\"></emoji><gameext type=\"0\" content=\"0\"></gameext></msg>",
"Status": 3,
"ImgStatus": 2,
"CreateTime": 1490758520,
"VoiceLength": 0,
"PlayLength": 0,
"FileName": "",
"FileSize": "",
"MediaId": "",
"Url": "",
"AppMsgType": 0,
"StatusNotifyCode": 0,
"StatusNotifyUserName": "",
"RecommendInfo": {
"UserName": "",
"NickName": "",
"QQNum": 0,
"Province": "",
"City": "",
"Content": "",
"Signature": "",
"Alias": "",
"Scene": 0,
"VerifyFlag": 0,
"AttrStatus": 0,
"Sex": 0,
"Ticket": "",
"OpCode": 0
},
"ForwardFlag": 0,
"AppInfo": {
"AppID": "",
"Type": 0
},
"HasProductId": 0,
"Ticket": "",
"ImgHeight": 220,
"ImgWidth": 220,
"SubMsgType": 0,
"NewMsgId": 8502319330630579,
"OriContent": ""
},
"raw": {
"MsgId": "8502319330630579",
"FromUserName": "@@b761d35ece918bbff572e875388dfba288933cf7cb708cfb0d39f511a829e669",
"ToUserName": "@f18e33e48ec385faaf4e766913bd53bb9ae0288c9272e8a2c892942f086389f8",
"MsgType": 47,
"Content": "@9780186f2beb5fe108d85384c55ca927:<br/><msg><emoji fromusername=\"kila602217914\" tousername=\"3769518846@chatroom\" type=\"2\" idbuffer=\"media:0_0\" md5=\"ebbf7cf829baba7d459076007d99e212\" len=\"530347\" productid=\"\" androidmd5=\"ebbf7cf829baba7d459076007d99e212\" androidlen=\"530347\" s60v3md5=\"ebbf7cf829baba7d459076007d99e212\" s60v3len=\"530347\" s60v5md5=\"ebbf7cf829baba7d459076007d99e212\" s60v5len=\"530347\" cdnurl=\"http://emoji.qpic.cn/wx_emoji/O74TaRhN6vJb3NmmoLtg2mT3u5w4pn2yrvfC9t6uRC0Aje0xCKfib5kKYXicnSeKpW/\" designerid=\"\" thumburl=\"\" encrypturl=\"http://emoji.qpic.cn/wx_emoji/O74TaRhN6vJb3NmmoLtg2mT3u5w4pn2yrvfC9t6uRC394gsoYV5JvibMevjTUgd43/\" aeskey=\"b1aa51fa21bf3fe2abd957839e6f0b0d\" width=\"220\" height=\"220\"></emoji><gameext type=\"0\" content=\"0\"></gameext></msg>",
"Status": 3,
"ImgStatus": 2,
"CreateTime": 1490758520,
"VoiceLength": 0,
"PlayLength": 0,
"FileName": "",
"FileSize": "",
"MediaId": "",
"Url": "",
"AppMsgType": 0,
"StatusNotifyCode": 0,
"StatusNotifyUserName": "",
"RecommendInfo": {
"UserName": "",
"NickName": "",
"QQNum": 0,
"Province": "",
"City": "",
"Content": "",
"Signature": "",
"Alias": "",
"Scene": 0,
"VerifyFlag": 0,
"AttrStatus": 0,
"Sex": 0,
"Ticket": "",
"OpCode": 0
},
"ForwardFlag": 0,
"AppInfo": {
"AppID": "",
"Type": 0
},
"HasProductId": 0,
"Ticket": "",
"ImgHeight": 220,
"ImgWidth": 220,
"SubMsgType": 0,
"NewMsgId": 8502319330630579,
"OriContent": ""
}
消息发送者的类型
-
System
系统消息 -
Self
自己发送的消息 -
Group
群组消息 -
Contact
联系人消息 -
Official
公众号消息 -
Special
特殊账号消息 -
Unknown
未知消息
message()->get($msgId)