Skip to content

红包RedPacket

HanSon edited this page Mar 16, 2017 · 1 revision

红包的判断有点不是太准确,取决于内容判断,而且也因语言不同而不同,目前暂时只判断(简体中文,香港繁体中文,英文)

属性

属性 类型 含义
msg array 消息的原始数组

msg

Array
(
    [MsgId] => 6191881620117916877
    [FromUserName] => @@4e0bc30dfe4492997fb2039182fa58afbc3f73ba767aa099b3ffa4b605ff892f
    [ToUserName] => @a0bc983ab0d1d811d0530c0236de8304d89920ada2f1c6468adffff337fe2bf7
    [MsgType] => 10000
    [Content] => 收到红包,请在手机上查看
    [Status] => 4
    [ImgStatus] => 1
    [CreateTime] => 1484669613
    [VoiceLength] => 0
    [PlayLength] => 0
    [FileName] => 
    [FileSize] => 
    [MediaId] => 
    [Url] => 
    [AppMsgType] => 0
    [StatusNotifyCode] => 0
    [StatusNotifyUserName] => 
    [RecommendInfo] => Array
        (
            [UserName] => 
            [NickName] => 
            [QQNum] => 0
            [Province] => 
            [City] => 
            [Content] => 
            [Signature] => 
            [Alias] => 
            [Scene] => 0
            [VerifyFlag] => 0
            [AttrStatus] => 0
            [Sex] => 0
            [Ticket] => 
            [OpCode] => 0
        )

    [ForwardFlag] => 0
    [AppInfo] => Array
        (
            [AppID] => 
            [Type] => 0
        )

    [HasProductId] => 0
    [Ticket] => 
    [ImgHeight] => 0
    [ImgWidth] => 0
    [SubMsgType] => 0
    [NewMsgId] => 6191881620117916877
    [OriContent] => 
)

栗子

$robot->server->setMessageHandler(function ($message){
        // 红包信息
    if($message instanceof RedPacket){
        // do something to notify if you want ...
        return $message->content . ' 来自 ' .$message->from['NickName'];
    }
});
Clone this wiki locally