onebots 0.4.13 → 0.4.14

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/README.md CHANGED
@@ -91,53 +91,54 @@ general: # 通用配置,在单个配置省略时的默认值
91
91
  ```
92
92
  # 配置解释
93
93
  ## Config
94
- | 配置项 | 类型 | 默认值 | desc |
95
- |:-----|:-------|:-----|:--------------------------------------------|
96
- | port | number | 6727 | 服务监听端口 |
97
- | logLevel| string | info | 日志级别 |
98
- | general | OneBotConfig | general | 通用配置|
99
- | [number] | OneBotConfig\|OneBotConfig[] | - | 机器人配置|
94
+ | 配置项 | 类型 | 默认值 | desc |
95
+ |:---------|:-----------------------------|:--------|:-------|
96
+ | port | number | 6727 | 服务监听端口 |
97
+ | logLevel | string | info | 日志级别 |
98
+ | general | OneBotConfig | general | 通用配置 |
99
+ | [number] | OneBotConfig\|OneBotConfig[] | - | 机器人配置 |
100
100
  ## OneBotConfig
101
- | 配置项 | 类型 | 默认值 | desc |
102
- |:-----|:-------|:-----|:--------------------------------------------|
103
- | V11| ConfigV11| configV11| V11配置|
104
- | V12| ConfigV12| configV12| V12配置|
101
+ | 配置项 | 类型 | 默认值 | desc |
102
+ |:---------|:----------|:----------|:-------|
103
+ | V11 | ConfigV11 | configV11 | V11配置 |
104
+ | V12 | ConfigV12 | configV12 | V12配置 |
105
+ | protocol | Config | {} | icqq配置 |
105
106
  ## ConfigV11
106
- | 配置项 | 类型 | 默认值 | desc |
107
- |:-----|:---------|:----|:-----------|
108
- | heartbeat| number | 3 | 心跳间隔 单位:秒 |
109
- | access_token| string | - | 访问令牌 |
110
- | secret| string | - | 签名密钥 |
111
- |rate_limit_interval| number | 4 | 限速间隔 单位:秒 |
112
- | post_message_format| string | string | 消息格式化 |
113
- |reconnect_interval| number | 3 | 重连间隔 单位:秒 |
114
- | use_http| boolean | false | 是否使用http协议 |
115
- | enable_cors| boolean | false | 是否允许跨域 |
116
- | use_ws| boolean | false | 是否使用ws协议 |
117
- |http_reverse_url| string[] | - | http上报地址地址 |
118
- | ws_reverse_url| string[] | - | 反向ws连接地址 |
107
+ | 配置项 | 类型 | 默认值 | desc |
108
+ |:--------------------|:---------|:-------|:-----------|
109
+ | heartbeat | number | 3 | 心跳间隔 单位:秒 |
110
+ | access_token | string | - | 访问令牌 |
111
+ | secret | string | - | 签名密钥 |
112
+ | rate_limit_interval | number | 4 | 限速间隔 单位:秒 |
113
+ | post_message_format | string | string | 消息格式化 |
114
+ | reconnect_interval | number | 3 | 重连间隔 单位:秒 |
115
+ | use_http | boolean | false | 是否使用http协议 |
116
+ | enable_cors | boolean | false | 是否允许跨域 |
117
+ | use_ws | boolean | false | 是否使用ws协议 |
118
+ | http_reverse_url | string[] | - | http上报地址地址 |
119
+ | ws_reverse_url | string[] | - | 反向ws连接地址 |
119
120
  ## ConfigV12
120
- | 配置项 | 类型 | 默认值 | desc |
121
- |:-----|:---------|:----|:------------|
122
- | heartbeat| number | 3 | 心跳间隔 单位:秒 |
123
- | access_token| string | - | 访问令牌 |
124
- | request_timeout| number | 15 | 请求超时 单位:秒 |
125
- | reconnect_interval| number | 3 | 重连间隔 单位:秒 |
126
- |enable_cors| boolean | false | 是否允许跨域 |
127
- |use_http| boolean | false | 是否使用http协议 |
128
- |use_ws| boolean | false | 是否使用ws协议 |
129
- |webhook_reverse_url| string[] | - | webhook上报地址 |
130
- |ws_reverse_url| string[] | - | 反向ws连接地址 |
121
+ | 配置项 | 类型 | 默认值 | desc |
122
+ |:--------------------|:---------|:------|:------------|
123
+ | heartbeat | number | 3 | 心跳间隔 单位:秒 |
124
+ | access_token | string | - | 访问令牌 |
125
+ | request_timeout | number | 15 | 请求超时 单位:秒 |
126
+ | reconnect_interval | number | 3 | 重连间隔 单位:秒 |
127
+ | enable_cors | boolean | false | 是否允许跨域 |
128
+ | use_http | boolean | false | 是否使用http协议 |
129
+ | use_ws | boolean | false | 是否使用ws协议 |
130
+ | webhook_reverse_url | string[] | - | webhook上报地址 |
131
+ | ws_reverse_url | string[] | - | 反向ws连接地址 |
131
132
  # 使用API管理oneBot
132
133
 
133
134
  | url | method | params | desc |
134
- |:--------| :--- |:----------------|:-------------------------------|
135
- | /list | GET | | 获取当前运行的机器人列表 |
136
- | /detail | GET | uin | 获取指定机器人配置 |
137
- | /qrcode | GET | uin | 获取指定机器人登录二维码 |
138
- | /add | POST | {uin,...config} | 添加机器人 config 为机器人配置 |
139
- | /edit | POST | {uin,...config} | 修改机器人配置 config 为机器人配置 |
140
- | /remove | get | uin,force | 移除机器人,force为true时,将删除机器人data目录 |
135
+ |:--------|:-------|:----------------|:-------------------------------|
136
+ | /list | GET | | 获取当前运行的机器人列表 |
137
+ | /detail | GET | uin | 获取指定机器人配置 |
138
+ | /qrcode | GET | uin | 获取指定机器人登录二维码 |
139
+ | /add | POST | {uin,...config} | 添加机器人 config 为机器人配置 |
140
+ | /edit | POST | {uin,...config} | 修改机器人配置 config 为机器人配置 |
141
+ | /remove | get | uin,force | 移除机器人,force为true时,将删除机器人data目录 |
141
142
 
142
143
  # 鸣谢
143
144
  1. [icqqjs/icqq](https://github.com/icqqjs/icqq) 底层服务支持
@@ -31,4 +31,6 @@ general: # 通用配置,在单个配置省略时的默认值
31
31
  # 每个账号的单独配置(用于覆盖通用配置)
32
32
  123456789:
33
33
  version: V11 # 使用的oneBot版本
34
+ protocol: # 将会覆盖通用配置中的protocol
35
+ platform: 1
34
36
  # 。。。其他配置项参见上方对应oneBot版本的通用配置
package/lib/onebot.js CHANGED
@@ -49,7 +49,7 @@ class OneBot extends events_1.EventEmitter {
49
49
  config = [].concat(config);
50
50
  const protocolConfig = {
51
51
  data_dir: (0, path_1.join)(app_1.App.configDir, 'data'),
52
- ...this.app.config.general
52
+ ...this.app.config.general.protocol
53
53
  };
54
54
  this.config = config.map(c => {
55
55
  if (!c.version)
package/lib/server/app.js CHANGED
@@ -47,7 +47,7 @@ class App extends koa_1.default {
47
47
  constructor(config = {}) {
48
48
  super(config);
49
49
  this.oneBots = [];
50
- this.config = (0, utils_1.deepMerge)((0, utils_1.deepClone)(App.defaultConfig), config);
50
+ this.config = (0, utils_1.deepMerge)((0, utils_1.deepClone)(_a.defaultConfig), config);
51
51
  this.logger = (0, log4js_1.getLogger)('[icqq-OneBot]');
52
52
  this.logger.level = this.config.log_level;
53
53
  this.router = new router_1.Router({ prefix: config.path });
@@ -86,7 +86,7 @@ class App extends koa_1.default {
86
86
  this.config[uin] = config;
87
87
  const oneBot = this.createOneBot(uin, config);
88
88
  oneBot.startListen();
89
- (0, fs_1.writeFileSync)(App.configPath, js_yaml_1.default.dump((0, utils_1.deepClone)(this.config)));
89
+ (0, fs_1.writeFileSync)(_a.configPath, js_yaml_1.default.dump((0, utils_1.deepClone)(this.config)));
90
90
  }
91
91
  updateAccount(uin, config) {
92
92
  if (typeof uin !== "number")
@@ -112,7 +112,7 @@ class App extends koa_1.default {
112
112
  oneBot.stop(force);
113
113
  delete this.config[uin];
114
114
  this.oneBots.splice(currentIdx, 1);
115
- (0, fs_1.writeFileSync)(App.configPath, js_yaml_1.default.dump(this.config));
115
+ (0, fs_1.writeFileSync)(_a.configPath, js_yaml_1.default.dump(this.config));
116
116
  }
117
117
  createOneBot(uin, config) {
118
118
  const oneBot = new onebot_1.OneBot(this, uin, config);
@@ -132,11 +132,11 @@ class App extends koa_1.default {
132
132
  });
133
133
  this.router.get('/qrcode', (ctx) => {
134
134
  const { uin } = ctx.query;
135
- const uinUrl = path.join(App.configDir, 'data', uin);
135
+ const uinUrl = path.join(_a.configDir, 'data', uin);
136
136
  if (!(0, fs_1.existsSync)(uinUrl)) {
137
137
  return ctx.res.writeHead(400).end('未登录');
138
138
  }
139
- const qrcodePath = path.join(App.configDir, 'data', uin, 'qrcode.png');
139
+ const qrcodePath = path.join(_a.configDir, 'data', uin, 'qrcode.png');
140
140
  let file = null;
141
141
  try {
142
142
  file = (0, fs_2.readFileSync)(qrcodePath); //读取文件
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onebots",
3
- "version": "0.4.13",
3
+ "version": "0.4.14",
4
4
  "description": "基于icqq的多例oneBot实现",
5
5
  "engines": {
6
6
  "node": ">=16"