Commit 34f1e2ce by HanSon

删除好友的省份城市

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