-
Notifications
You must be signed in to change notification settings - Fork 717
好友请求RequestFriend
HanSon edited this page Mar 16, 2017
·
1 revision
在info中,province在国内代表的是省份,如果是国外,则是国家名(如:Britain London)
属性 | 类型 | 含义 |
---|---|---|
msg | array | 消息的原始数组 |
info | array | 请求好友信息,等同于msg['RecommendInfo']
|
avatar | string | 头像链接 |
const ADD | int | 常量,添加好友的code |
const VIA | int | 常量,通过好友的code(通过好友需要用到) |
Array
(
[MsgId] => 1536543482976263184
[FromUserName] => fmessage
[ToUserName] => @568570c2a6d6e558c6a326d3ffe417dd6edf65b1ce270fe9b317bfffbe73369b
[MsgType] => 37
[Content] => <msg fromusername="fasdsfsa" encryptusername="v1_8f7ef6d9b2cba1910eaba4c842b5e864430b28a2e7fa23fa0e4d6b819e58a8c7@stranger" fromnickname="HanSon" content="上山打老虎" shortpy="HANSON" imagestatus="3" scene="8" country="CN" province="Guangdong" city="Guangzhou" sign="Keep Learning, Keep Running" percard="1" sex="1" alias="hanson" weibo="" weibonickname="" albumflag="0" albumstyle="0" albumbgimgid="" snsflag="17" snsbgimgid="http://mmsns.qpic.cn/mmsns/PiajxSqBRaEKUGEPgB7h6L9mtsmPx2yxUBCYtcpofEUmjC8QqibTkwvhkDib5iafMuhf/0" snsbgobjectid="11905753500808196174" mhash="f4ce7559f512d75e6b026eefc7de191f" mfullhash="f4ce7559f512d75e6b026eefc7de191f" bigheadimgurl="http://wx.qlogo.cn/mmhead/ver_1/aVEAcnmlA3xPiaicOMKP76njOBibjvGe4CYbsibooSIXBEiaybib8spgdoT35ib6CofWPAdr4hApOvPEgkEvWDo2ae9CxoNw7xSrQE4ZBOVztw5YEk/0" smallheadimgurl="http://wx.qlogo.cn/mmhead/ver_1/aVEAcnmlA3xPiaicOMKP76njOBibjvGe4CYbsibooSIXBEiaybib8spgdoT35ib6CofWPAdr4hApOvPEgkEvWDo2ae9CxoNw7xSrQE4ZBOVztw5YEk/132" ticket="v2_7cf272434569459780071e0cd92e4f5f1f2b7feade1c207a2cf39a67d4dc7d6593756e401e72e7726c56d323d32fe5cd9cadab8daceecf99671c8fe2db53e4e2@stranger" opcode="2" googlecontact="" qrticket="" chatroomusername="" sourceusername="" sourcenickname=""><brandlist count="0" ver="655485547"></brandlist></msg>
[Status] => 3
[ImgStatus] => 1
[CreateTime] => 1484670181
[VoiceLength] => 0
[PlayLength] => 0
[FileName] =>
[FileSize] =>
[MediaId] =>
[Url] =>
[AppMsgType] => 0
[StatusNotifyCode] => 0
[StatusNotifyUserName] =>
[RecommendInfo] => Array
(
[UserName] => @e33afbb6a5890d6ae52339fd74ea5659
[NickName] => HanSon
[QQNum] => 0
[Province] => Guangdong
[City] => Guangzhou
[Content] => 上山打老虎
[Signature] => Keep Learning, Keep Running
[Alias] => hanson
[Scene] => 8
[VerifyFlag] => 0
[AttrStatus] => 33784831
[Sex] => 1
[Ticket] => v2_7cf272434569459780071e0cd92e4f5f1f2b7feade1c207a2cf39a67d4dc7d6593756e401e72e7726c56d323d32fe5cd9cadab8daceecf99671c8fe2db53e4e2@stranger
[OpCode] => 2
)
[ForwardFlag] => 0
[AppInfo] => Array
(
[AppID] =>
[Type] => 0
)
[HasProductId] => 0
[Ticket] =>
[ImgHeight] => 0
[ImgWidth] => 0
[SubMsgType] => 0
[NewMsgId] => 1536543482976263184
[OriContent] =>
)
verifyUser($code, $ticket = null)
验证通过好友, $code
2 - 添加, 3 - 通过
$robot->server->setMessageHandler(function ($message){
// 请求添加信息
if($message instanceof RequestFriend){
/** @var $message RequestFriend */
$groupUsername = group()->getGroupsByNickname('通知到某个群名的群组', true)->first()['UserName'];
// 广东广州 的 HanSon 请求添加好友 “Hi, I'm creator of Vbot”
Text::send($groupUsername, "{$message->province}{$message->city} 的 {$message->info['NickName']} 请求添加好友 \"{$message->info['Content']}\"");
// 通过暗号自动添加好友
if($message->info['Content'] === '上山打老虎'){
Text::send($groupUsername, '暗号正确');
$message->verifyUser($message::VIA);
}else{
Text::send($groupUsername, '暗号错误');
}
}
});