onebots 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -83,17 +83,17 @@ class CommonAction {
|
|
|
83
83
|
callLogin(func, ...args) {
|
|
84
84
|
return new Promise(async (resolve) => {
|
|
85
85
|
const receiveResult = (event) => {
|
|
86
|
-
this.client.
|
|
87
|
-
this.client.
|
|
88
|
-
this.client.
|
|
89
|
-
this.client.
|
|
86
|
+
this.client.offTrap('system.login.qrcode', receiveResult);
|
|
87
|
+
this.client.offTrap('system.login.device', receiveResult);
|
|
88
|
+
this.client.offTrap('system.login.slider', receiveResult);
|
|
89
|
+
this.client.offTrap('system.login.error', receiveResult);
|
|
90
90
|
resolve(event);
|
|
91
91
|
};
|
|
92
|
-
this.client.
|
|
93
|
-
this.client.
|
|
94
|
-
this.client.
|
|
95
|
-
this.client.
|
|
96
|
-
this.client.
|
|
92
|
+
this.client.trap('system.login.qrcode', receiveResult);
|
|
93
|
+
this.client.trap('system.login.device', receiveResult);
|
|
94
|
+
this.client.trap('system.login.slider', receiveResult);
|
|
95
|
+
this.client.trap('system.login.error', receiveResult);
|
|
96
|
+
this.client.trapOnce('system.online', receiveResult);
|
|
97
97
|
try {
|
|
98
98
|
await this.client[func](...args);
|
|
99
99
|
}
|
|
@@ -112,16 +112,16 @@ class CommonAction {
|
|
|
112
112
|
return new Promise(resolve => {
|
|
113
113
|
const receiveResult = (e) => {
|
|
114
114
|
const callback = (data) => {
|
|
115
|
-
this.client.
|
|
116
|
-
this.client.
|
|
115
|
+
this.client.offTrap('internal.verbose', receiveResult);
|
|
116
|
+
this.client.offTrap('system.login.error', receiveResult);
|
|
117
117
|
resolve(data);
|
|
118
118
|
};
|
|
119
119
|
if ((typeof e === 'string' && e.includes('已发送')) || typeof e !== 'string') {
|
|
120
120
|
callback(e);
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
|
-
this.client.
|
|
124
|
-
this.client.
|
|
123
|
+
this.client.trap('internal.verbose', receiveResult);
|
|
124
|
+
this.client.trap('system.login.error', receiveResult);
|
|
125
125
|
this.client.sendSmsCode();
|
|
126
126
|
});
|
|
127
127
|
}
|
|
@@ -131,10 +131,10 @@ class CommonAction {
|
|
|
131
131
|
logout(keepalive) {
|
|
132
132
|
return new Promise(async (resolve) => {
|
|
133
133
|
const receiveResult = (e) => {
|
|
134
|
-
this.client.
|
|
134
|
+
this.client.offTrap('system.offline', receiveResult);
|
|
135
135
|
resolve(e);
|
|
136
136
|
};
|
|
137
|
-
this.client.
|
|
137
|
+
this.client.trap('system.offline', receiveResult);
|
|
138
138
|
await this.client.logout(keepalive);
|
|
139
139
|
});
|
|
140
140
|
}
|
|
@@ -19,7 +19,7 @@ export declare class CommonAction {
|
|
|
19
19
|
* 获取 Cookies
|
|
20
20
|
* @param domain {string} 域名
|
|
21
21
|
*/
|
|
22
|
-
getCookies(this: V11, domain: string):
|
|
22
|
+
getCookies(this: V11, domain: string): string;
|
|
23
23
|
getStatus(this: V12): {
|
|
24
24
|
good: boolean;
|
|
25
25
|
bots: {
|
|
@@ -38,7 +38,7 @@ export declare class CommonAction {
|
|
|
38
38
|
submitSlider(this: V12, ticket: string): Promise<any>;
|
|
39
39
|
submitSmsCode(this: V12, code: string): Promise<any>;
|
|
40
40
|
sendSmsCode(this: V12): Promise<any>;
|
|
41
|
-
login(this: V12, password?: string):
|
|
41
|
+
login(this: V12, password?: string): Promise<unknown>;
|
|
42
42
|
logout(this: V12, keepalive?: boolean): Promise<unknown>;
|
|
43
43
|
getSupportedActions(this: V12): string[];
|
|
44
44
|
}
|
|
@@ -58,17 +58,17 @@ class CommonAction {
|
|
|
58
58
|
callLogin(func, ...args) {
|
|
59
59
|
return new Promise(async (resolve) => {
|
|
60
60
|
const receiveResult = (event) => {
|
|
61
|
-
this.client.
|
|
62
|
-
this.client.
|
|
63
|
-
this.client.
|
|
64
|
-
this.client.
|
|
61
|
+
this.client.offTrap('system.login.qrcode', receiveResult);
|
|
62
|
+
this.client.offTrap('system.login.device', receiveResult);
|
|
63
|
+
this.client.offTrap('system.login.slider', receiveResult);
|
|
64
|
+
this.client.offTrap('system.login.error', receiveResult);
|
|
65
65
|
resolve(event);
|
|
66
66
|
};
|
|
67
|
-
this.client.
|
|
68
|
-
this.client.
|
|
69
|
-
this.client.
|
|
70
|
-
this.client.
|
|
71
|
-
this.client.
|
|
67
|
+
this.client.trap('system.login.qrcode', receiveResult);
|
|
68
|
+
this.client.trap('system.login.device', receiveResult);
|
|
69
|
+
this.client.trap('system.login.slider', receiveResult);
|
|
70
|
+
this.client.trap('system.login.error', receiveResult);
|
|
71
|
+
this.client.trapOnce('system.online', receiveResult);
|
|
72
72
|
try {
|
|
73
73
|
await this.client[func](...args);
|
|
74
74
|
}
|
|
@@ -87,16 +87,16 @@ class CommonAction {
|
|
|
87
87
|
return new Promise(resolve => {
|
|
88
88
|
const receiveResult = (e) => {
|
|
89
89
|
const callback = (data) => {
|
|
90
|
-
this.client.
|
|
91
|
-
this.client.
|
|
90
|
+
this.client.offTrap('internal.verbose', receiveResult);
|
|
91
|
+
this.client.offTrap('system.login.error', receiveResult);
|
|
92
92
|
resolve(data);
|
|
93
93
|
};
|
|
94
94
|
if ((typeof e === 'string' && e.includes('已发送')) || typeof e !== 'string') {
|
|
95
95
|
callback(e);
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
|
-
this.client.
|
|
99
|
-
this.client.
|
|
98
|
+
this.client.trap('internal.verbose', receiveResult);
|
|
99
|
+
this.client.trap('system.login.error', receiveResult);
|
|
100
100
|
this.client.sendSmsCode();
|
|
101
101
|
});
|
|
102
102
|
}
|
|
@@ -106,7 +106,7 @@ class CommonAction {
|
|
|
106
106
|
logout(keepalive) {
|
|
107
107
|
return new Promise(async (resolve) => {
|
|
108
108
|
const receiveResult = (e) => {
|
|
109
|
-
this.client.
|
|
109
|
+
this.client.offTrap('system.offline', receiveResult);
|
|
110
110
|
resolve(e);
|
|
111
111
|
};
|
|
112
112
|
this.client.on('system.offline', receiveResult);
|
|
@@ -1,2 +1,20 @@
|
|
|
1
|
+
import { V12 } from "../../../service/V12";
|
|
2
|
+
import SegmentElem = V12.SegmentElem;
|
|
1
3
|
export declare class GuildAction {
|
|
4
|
+
getGuildList(this: V12): {
|
|
5
|
+
guild_id: string;
|
|
6
|
+
guild_name: string;
|
|
7
|
+
}[];
|
|
8
|
+
getChannelList(this: V12, guild_id: string): {
|
|
9
|
+
guild_id: string;
|
|
10
|
+
channel_id: string;
|
|
11
|
+
channel_name: string;
|
|
12
|
+
channel_type: import("icqq/lib/channel").ChannelType;
|
|
13
|
+
}[];
|
|
14
|
+
getGuildMemberList(this: V12, guild_id: string): never[] | Promise<import("icqq/lib/guild").GuildMember[]>;
|
|
15
|
+
sendGuildMsg(this: V12, guild_id: string, channel_id: string, message: SegmentElem[]): Promise<{
|
|
16
|
+
seq: number;
|
|
17
|
+
rand: number;
|
|
18
|
+
time: number;
|
|
19
|
+
}>;
|
|
2
20
|
}
|
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GuildAction = void 0;
|
|
4
|
+
const V12_1 = require("../../../service/V12");
|
|
5
|
+
const utils_1 = require("../../../utils");
|
|
4
6
|
class GuildAction {
|
|
7
|
+
getGuildList() {
|
|
8
|
+
return this.client.getGuildList();
|
|
9
|
+
}
|
|
10
|
+
getChannelList(guild_id) {
|
|
11
|
+
return this.client.getChannelList(guild_id);
|
|
12
|
+
}
|
|
13
|
+
getGuildMemberList(guild_id) {
|
|
14
|
+
return this.client.getGuildMemberList(guild_id);
|
|
15
|
+
}
|
|
16
|
+
async sendGuildMsg(guild_id, channel_id, message) {
|
|
17
|
+
const forward = message.find(e => e.type === 'node');
|
|
18
|
+
if (forward)
|
|
19
|
+
(0, utils_1.remove)(message, forward);
|
|
20
|
+
let quote = message.find(e => e.type === 'reply');
|
|
21
|
+
if (quote)
|
|
22
|
+
(0, utils_1.remove)(message, quote);
|
|
23
|
+
const element = V12_1.V12.fromSegment(message);
|
|
24
|
+
// if(forward) element.unshift(await this.client.makeForwardMsg(forward.data.message.map(segment=>{
|
|
25
|
+
// return {
|
|
26
|
+
// message:V12.fromSegment([segment]),
|
|
27
|
+
// user_id:forward.data.user_id,
|
|
28
|
+
// nickname:forward.data.user_name,
|
|
29
|
+
// time:forward.data.time
|
|
30
|
+
// }
|
|
31
|
+
// })))
|
|
32
|
+
// if(quote && !message_id) message_id=quote.data.message_id
|
|
33
|
+
return await this.client.sendGuildMsg(guild_id, channel_id, element);
|
|
34
|
+
}
|
|
5
35
|
}
|
|
6
36
|
exports.GuildAction = GuildAction;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onebots",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "基于icqq的多例oneBot实现",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16"
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@koa/router": "^10.1.1",
|
|
53
|
-
"icqq": "^0.0.13-
|
|
53
|
+
"icqq": "^0.0.13-6",
|
|
54
54
|
"icqq-cq-enable": "^1.0.0",
|
|
55
55
|
"js-yaml": "^4.1.0",
|
|
56
56
|
"koa": "^2.13.4",
|