Commit 5f6d1de6 by HanSon Committed by GitHub

Merge pull request #51 from HanSon/dev

表情随机发送
2 parents b3bfcfae 6cee90dc
...@@ -62,7 +62,7 @@ function isAdmin($message) ...@@ -62,7 +62,7 @@ function isAdmin($message)
$groupMap = [ $groupMap = [
[ [
'nickname' => 'vbot 测试群', 'nickname' => 'vbo 测试群',
'id' => 1 'id' => 1
] ]
]; ];
...@@ -141,6 +141,16 @@ $robot->server->setMessageHandler(function ($message) use ($path) { ...@@ -141,6 +141,16 @@ $robot->server->setMessageHandler(function ($message) use ($path) {
return 'vbot 从未见过这么犯贱的人'; return 'vbot 从未见过这么犯贱的人';
} }
if(substr($message->content, 0, 1) === '@' && preg_match('/@(.+)\s自作孽不可活/', $message->content, $match) && isAdmin($message)){
$nickname = $match[1];
$members = group()->getMembersByNickname($message->from['UserName'], $nickname);
if($members){
$member = current($members);
Text::send($message->from['UserName'], '拜拜 ' . $member['NickName'] . ' ,君让臣死,臣不得不死');
group()->deleteMember($message->from['UserName'], $member['UserName']);
}
}
if ($message->isAt) { if ($message->isAt) {
return reply($message->content); return reply($message->content);
} }
...@@ -158,7 +168,7 @@ $robot->server->setMessageHandler(function ($message) use ($path) { ...@@ -158,7 +168,7 @@ $robot->server->setMessageHandler(function ($message) use ($path) {
} }
// 表情信息 返回接收到的表情 // 表情信息 返回接收到的表情
if ($message instanceof Emoticon) { if ($message instanceof Emoticon && random_int(0,1) && random_int(0,1)) {
Emoticon::sendRandom($message->from['UserName']); Emoticon::sendRandom($message->from['UserName']);
} }
......
...@@ -182,10 +182,15 @@ class Group extends Collection ...@@ -182,10 +182,15 @@ class Group extends Collection
*/ */
public function addMember($groupUsername, $members) public function addMember($groupUsername, $members)
{ {
if(!$groupUsername) return false;
$group = group()->get($groupUsername); $group = group()->get($groupUsername);
if(!$group) return false;
$groupCount = count($group['MemberList']); $groupCount = count($group['MemberList']);
list($fun, $key) = $groupCount > 40 ? ['invitemember', 'InviteMemberList'] : ['addmember', 'AddMemberList']; list($fun, $key) = $groupCount > 40 ? ['invitemember', 'InviteMemberList'] : ['addmember', 'AddMemberList'];
$members = is_string($members) ? [$members] : $members; $members = is_string($members) ? [$members] : $members;
$result = http()->json(sprintf('%s/webwxupdatechatroom?fun=%s&pass_ticket=%s', server()->baseUri, $fun, server()->passTicket), [ $result = http()->json(sprintf('%s/webwxupdatechatroom?fun=%s&pass_ticket=%s', server()->baseUri, $fun, server()->passTicket), [
'BaseRequest' => server()->baseRequest, 'BaseRequest' => server()->baseRequest,
'ChatRoomName' => $groupUsername, 'ChatRoomName' => $groupUsername,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!