This repository has been archived by the owner on Sep 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmiraiApi.js
72 lines (63 loc) · 1.75 KB
/
miraiApi.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
65
66
67
68
69
70
71
72
const json2str = (obj) => JSON.stringify(obj);
//const callbackLists = new Map();
function miraiApi(client) {
let cl = client
let createCallback;
this.setResCreator = (address) => {
createCallback = address;
}
this.sendPrivateMsg = (uin, msg, group_id = 0) => {
cl.send(json2str({
"action": "send_private_msg",
"params": {
"user_id": uin,
"group_id": group_id,
"message": msg
}
}))
}
this.sendGroupMsg = (group_id, msg) => {
cl.send(json2str({
"action": "send_group_msg",
"params": {
"group_id": group_id,
"message": msg
}
}))
}
this.setFriendAddRequest = (flag, approve = false, remark) => {
cl.send(json2str({
"action": "set_friend_add_request",
"params": {
"flag": flag,
"approve": approve,
"remark": remark
}
}))
}
this.setGroupAddRequest = (flag, subtype, approve = false, reason) => {
cl.send(json2str({
"action": "set_group_add_request",
"params": {
"flag": flag,
'sub_type': subtype,
"approve": approve,
"reason": reason
}
}))
}
this.getGroupMemberInfo = (gc, uin) => {
let id = Math.random();
cl.send(json2str({
"action": "get_group_member_info",
"params": {
"group_id": gc,
"user_id": uin,
"no_cache": false
},
"echo": id
}))
return createCallback(id);
}
}
module.exports = miraiApi