-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMasterNotifyPlugin.php
More file actions
54 lines (47 loc) · 1.97 KB
/
MasterNotifyPlugin.php
File metadata and controls
54 lines (47 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace kjBotModule\kj415j45\CoreModule;
use kjBot\SDK\CoolQ;
use kjBot\Framework\Plugin;
use kjBot\Framework\Event\FriendRequestEvent;
use kjBot\Framework\Event\InvitedToGroupEvent;
use kjBot\Framework\Event\GroupDecreaseEvent;
class MasterNotifyPlugin extends Plugin{
public $handleDepth = 3;
public function notice_group_decrease_kick_me(GroupDecreaseEvent $event){
return notifyMaster("{$event->operatorId} 将我从群 {$event->groupId} 踢出");
}
const cq_request_friend = true;
public function coolq_request_friend(FriendRequestEvent $event, CoolQ $cq){
$uid = $event->getId();
$comment = $event->comment;
$flag = $event->getFlag();
if(Config('AllowFriends', false)){
try{
$event->accept($cq);
}catch(\Exception $e){
_log('ERROR', export($e));
return notifyMaster("自动添加 {$uid} 为好友失败,备注信息为“{$comment}”。flag为\n{$flag}");
}
return notifyMaster("已自动添加 {$uid} 为好友,备注信息为“{$comment}”");
}else{
return notifyMaster("{$uid} 请求添加好友,备注信息为“{$comment}”。flag为\n{$flag}");
}
}
const cq_request_group_invite = true;
public function coolq_request_group_invite(InvitedToGroupEvent $event, CoolQ $cq){
$uid = $event->getId();
$gid = $event->groupId;
$flag = $event->getFlag();
if(Config('AllowGroups', false)){
try{
$event->accept($cq);
}catch(\Exception $e){
_log('ERROR', export($e));
return notifyMaster("自动接受 {$uid} 邀请到群 {$gid} 的请求失败。flag为\n{$flag}");
}
return notifyMaster("已自动接受 {$uid} 邀请到群 {$gid} 的请求");
}else{
return notifyMaster("{$uid} 请求添加到群 {$gid},flag为\n{$flag}");
}
}
}