forked from fengnz/fengdoorbot
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHandleBanCommand.js
64 lines (54 loc) · 1.57 KB
/
HandleBanCommand.js
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
55
56
57
58
59
60
61
62
63
64
function debugBanCommand() {
debug()
}
function handleBanCommand(body, paras, origParas) {
var share = getShareObject(body);
var payload = share.payload;
var chat = share.chat;
var callback_query_id = share.callback_query_id;
var payloads = [];
if (chat.type.indexOf("group") < 0) {
payload.text += "请将本机器人加入您的群中再使用此命令";
return payload;
}
var targetUser;
var theUser;
if (origParas.length > 1) {
targetUser = origParas[1];
} else {
if (body.message && body.message.reply_to_message) {
targetUser = body.message.reply_to_message.from.id;
theUser = body.message.reply_to_message.from;
}
}
if (targetUser) {
var isAdmin = isAdminOrCreator(share.from.id, share.chat.id);
if (isAdmin) {
var payload4 = {
"method": "kickChatMember",
"chat_id": share.chat.id,
"user_id": targetUser,
};
payloads.push(payload4);
if (theUser) {
payload.text += getMentionName(share.from);
payload.text += "踢了";
payload.text += getMentionName(theUser);
payloads.push(payload);
}
} else {
if (body.callback_query) {
var answerCallBackQueryPayload = {
"method": "answerCallbackQuery",
"callback_query_id": callback_query_id,
"text": "只有本群管理才可以使用此命令",
};
return answerCallBackQueryPayload;
} else {
payload.text += "只有本群管理才可以使用此命令";
return payload;
}
}
}
return payloads;
}