onebots 0.1.18 → 0.2.1
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.
package/lib/server/app.js
CHANGED
|
@@ -200,10 +200,10 @@ class App extends koa_1.default {
|
|
|
200
200
|
this.logger.mark(`server listen at http://0.0.0.0:${this.config.port}/${this.config.path ? this.config.path : ''}`);
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
-
exports.App = App;
|
|
204
203
|
_a = App;
|
|
205
204
|
App.configDir = path.join(os.homedir(), '.onebots');
|
|
206
205
|
App.configPath = path.join(_a.configDir, 'config.yaml');
|
|
206
|
+
exports.App = App;
|
|
207
207
|
function createApp(config = 'config.yaml') {
|
|
208
208
|
if (typeof config === 'string') {
|
|
209
209
|
config = path.resolve(process.cwd(), config);
|
|
@@ -239,3 +239,4 @@ exports.defineConfig = defineConfig;
|
|
|
239
239
|
log_level: 'info',
|
|
240
240
|
};
|
|
241
241
|
})(App = exports.App || (exports.App = {}));
|
|
242
|
+
exports.App = App;
|
|
@@ -83,10 +83,10 @@ class CommonAction {
|
|
|
83
83
|
callLogin(func, ...args) {
|
|
84
84
|
return new Promise(async (resolve) => {
|
|
85
85
|
const receiveResult = (event) => {
|
|
86
|
-
this.client.offTrap('system.login.qrcode'
|
|
87
|
-
this.client.offTrap('system.login.device'
|
|
88
|
-
this.client.offTrap('system.login.slider'
|
|
89
|
-
this.client.offTrap('system.login.error'
|
|
86
|
+
this.client.offTrap('system.login.qrcode');
|
|
87
|
+
this.client.offTrap('system.login.device');
|
|
88
|
+
this.client.offTrap('system.login.slider');
|
|
89
|
+
this.client.offTrap('system.login.error');
|
|
90
90
|
resolve(event);
|
|
91
91
|
};
|
|
92
92
|
this.client.trap('system.login.qrcode', receiveResult);
|
|
@@ -112,8 +112,8 @@ class CommonAction {
|
|
|
112
112
|
return new Promise(resolve => {
|
|
113
113
|
const receiveResult = (e) => {
|
|
114
114
|
const callback = (data) => {
|
|
115
|
-
this.client.offTrap('internal.verbose'
|
|
116
|
-
this.client.offTrap('system.login.error'
|
|
115
|
+
this.client.offTrap('internal.verbose');
|
|
116
|
+
this.client.offTrap('system.login.error');
|
|
117
117
|
resolve(data);
|
|
118
118
|
};
|
|
119
119
|
if ((typeof e === 'string' && e.includes('已发送')) || typeof e !== 'string') {
|
|
@@ -131,7 +131,7 @@ class CommonAction {
|
|
|
131
131
|
logout(keepalive) {
|
|
132
132
|
return new Promise(async (resolve) => {
|
|
133
133
|
const receiveResult = (e) => {
|
|
134
|
-
this.client.offTrap('system.offline'
|
|
134
|
+
this.client.offTrap('system.offline');
|
|
135
135
|
resolve(e);
|
|
136
136
|
};
|
|
137
137
|
this.client.trap('system.offline', receiveResult);
|
|
@@ -59,10 +59,10 @@ class CommonAction {
|
|
|
59
59
|
callLogin(func, ...args) {
|
|
60
60
|
return new Promise(async (resolve) => {
|
|
61
61
|
const receiveResult = (event) => {
|
|
62
|
-
this.client.offTrap('system.login.qrcode'
|
|
63
|
-
this.client.offTrap('system.login.device'
|
|
64
|
-
this.client.offTrap('system.login.slider'
|
|
65
|
-
this.client.offTrap('system.login.error'
|
|
62
|
+
this.client.offTrap('system.login.qrcode');
|
|
63
|
+
this.client.offTrap('system.login.device');
|
|
64
|
+
this.client.offTrap('system.login.slider');
|
|
65
|
+
this.client.offTrap('system.login.error');
|
|
66
66
|
resolve(event);
|
|
67
67
|
};
|
|
68
68
|
this.client.trap('system.login.qrcode', receiveResult);
|
|
@@ -88,8 +88,8 @@ class CommonAction {
|
|
|
88
88
|
return new Promise(resolve => {
|
|
89
89
|
const receiveResult = (e) => {
|
|
90
90
|
const callback = (data) => {
|
|
91
|
-
this.client.offTrap('internal.verbose'
|
|
92
|
-
this.client.offTrap('system.login.error'
|
|
91
|
+
this.client.offTrap('internal.verbose');
|
|
92
|
+
this.client.offTrap('system.login.error');
|
|
93
93
|
resolve(data);
|
|
94
94
|
};
|
|
95
95
|
if ((typeof e === 'string' && e.includes('已发送')) || typeof e !== 'string') {
|
|
@@ -107,7 +107,7 @@ class CommonAction {
|
|
|
107
107
|
logout(keepalive) {
|
|
108
108
|
return new Promise(async (resolve) => {
|
|
109
109
|
const receiveResult = (e) => {
|
|
110
|
-
this.client.offTrap('system.offline'
|
|
110
|
+
this.client.offTrap('system.offline');
|
|
111
111
|
resolve(e);
|
|
112
112
|
};
|
|
113
113
|
this.client.on('system.offline', receiveResult);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onebots",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "基于icqq的多例oneBot实现",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16"
|
|
@@ -48,9 +48,11 @@
|
|
|
48
48
|
"/lib/*.yaml",
|
|
49
49
|
"/**/LICENSE"
|
|
50
50
|
],
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"icqq": "latest"
|
|
53
|
+
},
|
|
51
54
|
"dependencies": {
|
|
52
55
|
"@koa/router": "^10.1.1",
|
|
53
|
-
"icqq": "^0.0.31",
|
|
54
56
|
"icqq-cq-enable": "^1.0.0",
|
|
55
57
|
"js-yaml": "^4.1.0",
|
|
56
58
|
"koa": "^2.13.4",
|
package/lib/config.sample.yaml
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
port: 6727 # 监听端口
|
|
2
|
-
log_level: info # 日志等级
|
|
3
|
-
general: # 通用配置,在单个配置省略时的默认值
|
|
4
|
-
V11: # oneBotV11的通用配置
|
|
5
|
-
heartbeat: 3 # 心跳间隔 (秒)
|
|
6
|
-
access_token: '' # 访问api的token
|
|
7
|
-
post_timeout: 15 # 上报超时时间,(秒)
|
|
8
|
-
secret: '' # 上报数据的sha1签名密钥
|
|
9
|
-
rate_limit_interval: 4 # ws心跳间隔(秒)
|
|
10
|
-
post_message_format: string # "string"或"array"
|
|
11
|
-
reconnect_interval: 3 # 重连间隔 (秒)
|
|
12
|
-
use_http: true # 是否使用 http
|
|
13
|
-
enable_cors: true # 是否允许跨域
|
|
14
|
-
use_ws: true # 是否使用websocket
|
|
15
|
-
http_reverse: [ ] # http上报地址
|
|
16
|
-
ws_reverse: [ ] # 反向ws连接地址
|
|
17
|
-
V12: # oneBotV12的通用配置
|
|
18
|
-
heartbeat: 3 # 心跳间隔 (秒)
|
|
19
|
-
access_token: '' # 访问api的token
|
|
20
|
-
request_timeout: 15 # 上报超时时间 (秒)
|
|
21
|
-
reconnect_interval: 3 # 重连间隔 (秒)
|
|
22
|
-
enable_cors: true # 是否允许跨域
|
|
23
|
-
use_http: true # 是否启用http
|
|
24
|
-
use_ws: true # 是否启用 websocket
|
|
25
|
-
webhook: [ ] # http 上报地址
|
|
26
|
-
ws_reverse: [ ] # 反向ws连接地址
|
|
27
|
-
# 每个账号的单独配置(用于覆盖通用配置)
|
|
28
|
-
123456789:
|
|
29
|
-
version: V11 # 使用的oneBot版本
|
|
30
|
-
password: abcedfghi # 账号密码,未配置则扫码登陆
|
|
31
|
-
# 。。。其他配置项参见上方对应oneBot版本的通用配置
|