onebots 0.1.17 → 0.2.0

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/onebot.js CHANGED
@@ -129,7 +129,7 @@ class OneBot extends events_1.EventEmitter {
129
129
  case 'private':
130
130
  data.message.shift({
131
131
  type: 'reply',
132
- message_id: (0, message_1.genDmMessageId)(data.source.user_id, data.source.seq, data.source.rand, data.source.rand, data.source.time)
132
+ message_id: (0, message_1.genDmMessageId)(data.source.user_id, data.source.seq, data.source.rand, data.source.time)
133
133
  });
134
134
  break;
135
135
  }
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', 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);
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', receiveResult);
116
- this.client.offTrap('system.login.error', receiveResult);
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', receiveResult);
134
+ this.client.offTrap('system.offline');
135
135
  resolve(e);
136
136
  };
137
137
  this.client.trap('system.offline', receiveResult);
@@ -1,5 +1,4 @@
1
1
  import { V12 } from '../../../service/V12';
2
- import { OnlineStatus } from "icqq";
3
2
  import { Action } from "./";
4
3
  import { V11 } from "../../../service/V11";
5
4
  export declare class CommonAction {
@@ -24,7 +23,7 @@ export declare class CommonAction {
24
23
  good: boolean;
25
24
  bots: {
26
25
  self: any;
27
- online: OnlineStatus;
26
+ online: boolean;
28
27
  }[];
29
28
  };
30
29
  getLatestEvents(this: V12, limit?: number, timout?: number): Promise<V12.Payload<keyof Action>[]>;
@@ -35,7 +35,7 @@ class CommonAction {
35
35
  bots: [
36
36
  {
37
37
  self: this.action.getSelfInfo.apply(this),
38
- online: this.client.status = icqq_1.OnlineStatus.Online,
38
+ online: this.client.status === icqq_1.OnlineStatus.Online,
39
39
  }
40
40
  ]
41
41
  };
@@ -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', receiveResult);
63
- this.client.offTrap('system.login.device', receiveResult);
64
- this.client.offTrap('system.login.slider', receiveResult);
65
- this.client.offTrap('system.login.error', receiveResult);
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', receiveResult);
92
- this.client.offTrap('system.login.error', receiveResult);
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', receiveResult);
110
+ this.client.offTrap('system.offline');
111
111
  resolve(e);
112
112
  };
113
113
  this.client.on('system.offline', receiveResult);
@@ -188,6 +188,7 @@ export declare namespace V12 {
188
188
  };
189
189
  heartbeat: {
190
190
  detail_type: 'heartbeat';
191
+ status: ReturnType<Action['getStatus']>;
191
192
  interval: number;
192
193
  };
193
194
  status_update: {
@@ -94,7 +94,8 @@ class V12 extends events_1.EventEmitter {
94
94
  this.heartbeat = setInterval(() => {
95
95
  this.dispatch(V12.formatPayload(this.oneBot.uin, 'heartbeat', {
96
96
  detail_type: "heartbeat",
97
- interval: new Date().getTime() + this.config.heartbeat * 1000
97
+ interval: new Date().getTime() + this.config.heartbeat * 1000,
98
+ status: this.action.getStatus.apply(this)
98
99
  }));
99
100
  }, this.config.heartbeat * 1000);
100
101
  }
@@ -299,7 +300,10 @@ class V12 extends events_1.EventEmitter {
299
300
  if (data.type === 'notice') {
300
301
  switch (data.detail_type) {
301
302
  case 'friend':
302
- data.detail_type += data.sub_type;
303
+ if (['increase', 'decrease'].includes(data.sub_type))
304
+ data.detail_type = 'friend_' + data.sub_type;
305
+ else if (data.sub_type === 'recall')
306
+ data.detail_type = 'private_message_delete';
303
307
  break;
304
308
  case 'group':
305
309
  if (['increase', 'decrease'].includes(data.sub_type))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onebots",
3
- "version": "0.1.17",
3
+ "version": "0.2.0",
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.26",
53
+ "icqq": "^0.0.37",
54
54
  "icqq-cq-enable": "^1.0.0",
55
55
  "js-yaml": "^4.1.0",
56
56
  "koa": "^2.13.4",
@@ -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版本的通用配置