Commit 34f1e2ce by HanSon

删除好友的省份城市

1 parent 97dbd725
......@@ -34,9 +34,9 @@ $robot->server->setMessageHandler(function ($message) use ($path) {
/** @var $message Message */
print_r($message);
if($message){
print_r($message->msg);
}
// if($message){
// print_r($message->msg);
// }
// 位置信息 返回位置文字
// if ($message instanceof Location) {
......@@ -126,20 +126,20 @@ $robot->server->setMessageHandler(function ($message) use ($path) {
// }
// }
//
// // 请求添加信息
// if($message instanceof RequestFriend){
// /** @var $message RequestFriend */
// $groupUsername = group()->getGroupsByNickname('芬芬', true)->first()['UserName'];
//
// 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, '暗号错误');
// }
// }
// 请求添加信息
if($message instanceof RequestFriend){
/** @var $message RequestFriend */
$groupUsername = group()->getGroupsByNickname('芬芬', true)->first()['UserName'];
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, '暗号错误');
}
}
//
// // 分享信息
// if($message instanceof Share){
......
......@@ -35,10 +35,12 @@ class MessageFactory
/**
* 处理消息类型
*
* @param $msg
* @return Touch
*/
private function handleMessageByType($msg)
{
print_r($msg);
switch($msg['MsgType']){
case 1: //文本消息
if(Location::isLocation($msg)){
......@@ -57,10 +59,14 @@ class MessageFactory
case 10002:
return new Recall($msg);
case 10000:
if(in_array($msg['Content'], ['利是', '红包', 'Red Packet'])){
if(str_contains($msg['Content'], '利是') || str_contains($msg['Content'], '红包') || str_contains($msg['Content'], 'Red Packet')){
return new RedPacket($msg);
}else if(in_array($msg['Content'], ['好友', 'friend'])){
}
// else if(str_contains($msg['Content'], '好友') || str_contains($msg['Content'], 'friend')){
// print_r($msg);
// }
else{
print_r($msg);
}
break;
case 49:
......
......@@ -55,7 +55,6 @@ class Message
$this->msg = $msg;
$this->setFrom();
$this->setTo();
$this->setFromType();
$this->msg['Content'] = html_entity_decode($this->formatContent($this->msg['Content']));
......
......@@ -20,20 +20,6 @@ class RequestFriend extends Message implements MessageInterface
public $avatar;
/**
* 国内为省,国外为国
*
* @var string
*/
public $province;
/**
* 城市
*
* @var string
*/
public $city;
const ADD = 2;
const VIA = 3;
......@@ -52,11 +38,9 @@ class RequestFriend extends Message implements MessageInterface
private function parseContent()
{
$isMatch = preg_match('/province="(.+?)"\scity="(.+?)".+bigheadimgurl="(.+?)"/', $this->msg['Content'], $matches);
$isMatch = preg_match('/bigheadimgurl="(.+?)"/', $this->msg['Content'], $matches);
if($isMatch){
$this->province = $matches[1];
$this->city = $matches[2];
if ($isMatch) {
$this->avatar = $matches[3];
}
}
......@@ -70,12 +54,12 @@ class RequestFriend extends Message implements MessageInterface
*/
public function verifyUser($code, $ticket = null)
{
$url = sprintf(server()->baseUri.'/webwxverifyuser?lang=zh_CN&r=%s&pass_ticket=%s' ,time()*1000, server()->passTicket);
$url = sprintf(server()->baseUri . '/webwxverifyuser?lang=zh_CN&r=%s&pass_ticket=%s', time() * 1000, server()->passTicket);
$data = [
'BaseRequest' => server()->baseRequest,
'Opcode' => $code,
'VerifyUserListSize' => 1,
'VerifyUserList' => [$ticket ? : $this->verifyTicket()],
'VerifyUserList' => [$ticket ?: $this->verifyTicket()],
'VerifyContent' => '',
'SceneListCount' => 1,
'SceneList' => [33],
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!