-
Notifications
You must be signed in to change notification settings - Fork 52
/
HandlePinMessageCommand.js
46 lines (36 loc) · 1.07 KB
/
HandlePinMessageCommand.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
function debugPinMessageCommand() {
debug()
}
function handlePinMessageCommand(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 targetMessage = origParas[1];
var isAdmin = isAdminOrCreator(share.from.id, share.chat.id);
if (isAdmin) {
var payload2 = {
"method": "pinChatMessage",
"chat_id": share.chat.id,
"message_id": parseInt(targetMessage)
};
return payload2;
} else {
if (body.callback_query) {
var answerCallBackQueryPayload = {
"method": "answerCallbackQuery",
"callback_query_id": callback_query_id,
"text": "只有本群管理才可以使用此命令",
};
return answerCallBackQueryPayload;
} else {
payload.text += "只有本群管理才可以使用此命令";
return payload;
}
}
}