onebots 0.0.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/LICENSE +21 -0
- package/README.md +59 -0
- package/lib/bin.d.ts +2 -0
- package/lib/bin.js +5 -0
- package/lib/config.sample.yaml +31 -0
- package/lib/db.d.ts +19 -0
- package/lib/db.js +91 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +21 -0
- package/lib/onebot.d.ts +43 -0
- package/lib/onebot.js +85 -0
- package/lib/server/app.d.ts +52 -0
- package/lib/server/app.js +232 -0
- package/lib/server/router.d.ts +9 -0
- package/lib/server/router.js +32 -0
- package/lib/service/V11/action/common.d.ts +64 -0
- package/lib/service/V11/action/common.js +115 -0
- package/lib/service/V11/action/friend.d.ts +38 -0
- package/lib/service/V11/action/friend.js +44 -0
- package/lib/service/V11/action/group.d.ts +104 -0
- package/lib/service/V11/action/group.js +138 -0
- package/lib/service/V11/action/index.d.ts +9 -0
- package/lib/service/V11/action/index.js +10 -0
- package/lib/service/V11/config.d.ts +10 -0
- package/lib/service/V11/config.js +2 -0
- package/lib/service/V11/index.d.ts +95 -0
- package/lib/service/V11/index.js +481 -0
- package/lib/service/V12/action/common.d.ts +32 -0
- package/lib/service/V12/action/common.js +105 -0
- package/lib/service/V12/action/friend.d.ts +13 -0
- package/lib/service/V12/action/friend.js +15 -0
- package/lib/service/V12/action/group.d.ts +104 -0
- package/lib/service/V12/action/group.js +138 -0
- package/lib/service/V12/action/guild.d.ts +2 -0
- package/lib/service/V12/action/guild.js +6 -0
- package/lib/service/V12/action/index.d.ts +10 -0
- package/lib/service/V12/action/index.js +11 -0
- package/lib/service/V12/config.d.ts +17 -0
- package/lib/service/V12/config.js +2 -0
- package/lib/service/V12/index.d.ts +102 -0
- package/lib/service/V12/index.js +530 -0
- package/lib/types.d.ts +3 -0
- package/lib/types.js +2 -0
- package/lib/utils.d.ts +13 -0
- package/lib/utils.js +139 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 凉菜
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>基于icqq的oneBot实现</h1>
|
|
3
|
+
<p>
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/icqq-onebot)
|
|
6
|
+
[](https://onebot.dev/)
|
|
7
|
+
[](https://12.onebot.dev/)
|
|
8
|
+
[](https://nodejs.org)
|
|
9
|
+
[](https://jq.qq.com/?_wv=1027&k=B22VGXov)
|
|
10
|
+
[docs](/docs)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
</p>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
# 使用示例
|
|
17
|
+
1. 新建一个node项目
|
|
18
|
+
```shell
|
|
19
|
+
npm init -y
|
|
20
|
+
```
|
|
21
|
+
2. 安装@icqq/oneBot
|
|
22
|
+
```shell
|
|
23
|
+
npm install onebots
|
|
24
|
+
```
|
|
25
|
+
3. 在项目跟目录添加配置文件config.yaml
|
|
26
|
+
```yaml
|
|
27
|
+
port: 6727 # 项目icqq-oneBot监听的端口(默认:6727)
|
|
28
|
+
1472258369: # 你的机器人账户
|
|
29
|
+
version: V11 # oneBot版本(V11 或 V12)
|
|
30
|
+
```
|
|
31
|
+
4. 新建入口文件`index.js`并输入一下内容
|
|
32
|
+
```javascript
|
|
33
|
+
const {createApp}=require('onebots')
|
|
34
|
+
createApp()
|
|
35
|
+
.start()
|
|
36
|
+
```
|
|
37
|
+
5. 启动项目
|
|
38
|
+
```shell
|
|
39
|
+
node ./index.js
|
|
40
|
+
```
|
|
41
|
+
# 使用命令行启动
|
|
42
|
+
```shell
|
|
43
|
+
npm install -g onebots
|
|
44
|
+
onebots
|
|
45
|
+
```
|
|
46
|
+
# 使用接口管理oneBot
|
|
47
|
+
|
|
48
|
+
| url | method | params | desc |
|
|
49
|
+
|:--------| :--- |:-----------------|:----------------------|
|
|
50
|
+
| /list | GET | | 获取当前运行的机器人列表 |
|
|
51
|
+
| /detail | GET | uin | 获取指定机器人配置 |
|
|
52
|
+
| /qrcode | GET | uin | 获取指定机器人登录二维码 |
|
|
53
|
+
| /add | POST | {uin,...config} | 添加机器人 config 为机器人配置 |
|
|
54
|
+
| /edit | POST | {uin,...config} | 修改机器人配置 config 为机器人配置 |
|
|
55
|
+
| /remove | get | uin | 移除机器人 |
|
|
56
|
+
|
|
57
|
+
# 鸣谢
|
|
58
|
+
1. [icqqjs/icqq](https://github.com/takayama-lily/icqq) 底层服务支持
|
|
59
|
+
2. [takayama-lily/onebot](https://github.com/takayama-lily/node-onebot) oneBots原先版本
|
package/lib/bin.d.ts
ADDED
package/lib/bin.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
port: 6727 # 监听端口
|
|
2
|
+
general: # 通用配置,在单个配置省略时的默认值
|
|
3
|
+
V11: # oneBotV11的通用配置
|
|
4
|
+
heartbeat: 3 # 心跳间隔 (秒)
|
|
5
|
+
access_token: '' # 访问api的token
|
|
6
|
+
post_timeout: 15 # 上报超时时间,(秒)
|
|
7
|
+
secret: '' # 上报数据的sha1签名密钥
|
|
8
|
+
rate_limit_interval: 4 # ws心跳间隔(秒)
|
|
9
|
+
post_message_format: string # "string"或"array"
|
|
10
|
+
reconnect_interval: 3 # 重连间隔 (秒)
|
|
11
|
+
use_http: true # 是否使用 http
|
|
12
|
+
enable_cors: true # 是否允许跨域
|
|
13
|
+
use_ws: true # 是否使用websocket
|
|
14
|
+
http_reverse: [] # http上报地址
|
|
15
|
+
ws_reverse: [] # 反向ws连接地址
|
|
16
|
+
V12: # oneBotV12的通用配置
|
|
17
|
+
heartbeat: 3 # 心跳间隔 (秒)
|
|
18
|
+
access_token: '' # 访问api的token
|
|
19
|
+
request_timeout: 15 # 上报超时时间 (秒)
|
|
20
|
+
reconnect_interval: 3 # 重连间隔 (秒)
|
|
21
|
+
enable_cors: true # 是否允许跨域
|
|
22
|
+
use_http: true # 是否启用http
|
|
23
|
+
use_ws: true # 是否启用 websocket
|
|
24
|
+
webhook: [] # http 上报地址
|
|
25
|
+
ws_reverse: [] # 反向ws连接地址
|
|
26
|
+
log_level: info # 日志等级
|
|
27
|
+
# 每个账号的单独配置(用于覆盖通用配置)
|
|
28
|
+
123456789:
|
|
29
|
+
version: V11 # 使用的oneBot版本
|
|
30
|
+
password: abcedfghi # 账号密码,未配置则扫码登陆
|
|
31
|
+
# 。。。其他配置项参见上方对应oneBot版本的通用配置
|
package/lib/db.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from "events";
|
|
3
|
+
export declare class Db extends EventEmitter {
|
|
4
|
+
private readonly path;
|
|
5
|
+
private data;
|
|
6
|
+
private raw_data;
|
|
7
|
+
constructor(path: string, force_create?: boolean);
|
|
8
|
+
get(key: string, escape?: boolean): any;
|
|
9
|
+
set(key: string, value: any, escape?: boolean): any;
|
|
10
|
+
has(key: string, escape?: boolean): boolean;
|
|
11
|
+
delete(key: string, escape?: boolean): boolean;
|
|
12
|
+
write(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export declare namespace Db {
|
|
15
|
+
interface Config {
|
|
16
|
+
path: string;
|
|
17
|
+
force?: boolean;
|
|
18
|
+
}
|
|
19
|
+
}
|
package/lib/db.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Db = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const promises_1 = require("fs/promises");
|
|
6
|
+
const events_1 = require("events");
|
|
7
|
+
class Db extends events_1.EventEmitter {
|
|
8
|
+
constructor(path, force_create = true) {
|
|
9
|
+
super();
|
|
10
|
+
this.path = path;
|
|
11
|
+
this.data = {};
|
|
12
|
+
this.raw_data = '{}';
|
|
13
|
+
if (!this.path.toLowerCase().endsWith('.json'))
|
|
14
|
+
this.path = this.path + '.json';
|
|
15
|
+
if (!(0, fs_1.existsSync)(this.path) && force_create) {
|
|
16
|
+
(0, fs_1.writeFileSync)(this.path, this.raw_data);
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const raw_data = (0, fs_1.readFileSync)(this.path, 'utf8');
|
|
20
|
+
this.raw_data = raw_data || this.raw_data;
|
|
21
|
+
this.data = JSON.parse(this.raw_data);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
const { message } = error;
|
|
25
|
+
if (!message.includes('ENOENT: no such file or directory')) {
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
get(key, escape = true) {
|
|
31
|
+
const func = new Function(`return this.data.${key}`);
|
|
32
|
+
const _this = this;
|
|
33
|
+
let result;
|
|
34
|
+
try {
|
|
35
|
+
result = escape ? func.apply(this) : this.data[key];
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
throw new Error('不可达的位置:' + key.toString());
|
|
39
|
+
}
|
|
40
|
+
return result && typeof result === 'object' ? new Proxy(result, {
|
|
41
|
+
get(target, p) {
|
|
42
|
+
return target[p];
|
|
43
|
+
},
|
|
44
|
+
set(target, p, value, receiver) {
|
|
45
|
+
const result = target[p] = value;
|
|
46
|
+
_this.write();
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
}) : result;
|
|
50
|
+
}
|
|
51
|
+
set(key, value, escape = true) {
|
|
52
|
+
const func = new Function('value', `return this.data.${key}=value`);
|
|
53
|
+
const _this = this;
|
|
54
|
+
let result;
|
|
55
|
+
result = escape ? func.apply(this, [value]) : this.data[key] = value;
|
|
56
|
+
this.raw_data = JSON.stringify(this.data, null, 2);
|
|
57
|
+
this.write();
|
|
58
|
+
return result && typeof result === 'object' ? new Proxy(result, {
|
|
59
|
+
get(target, p) {
|
|
60
|
+
return target[p];
|
|
61
|
+
},
|
|
62
|
+
set(target, p, value, receiver) {
|
|
63
|
+
const result = target[p] = value;
|
|
64
|
+
_this.write();
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
}) : result;
|
|
68
|
+
}
|
|
69
|
+
has(key, escape = true) {
|
|
70
|
+
return escape ? new Function(`return !!this.data.${key}`).apply(this) : !!this.data[key];
|
|
71
|
+
}
|
|
72
|
+
delete(key, escape = true) {
|
|
73
|
+
const result = escape ? new Function(`return delete this.data.${key}`).apply(this) : delete this.data[key];
|
|
74
|
+
this.write();
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
async write() {
|
|
78
|
+
try {
|
|
79
|
+
const raw_data = JSON.stringify(this.data, null, 2);
|
|
80
|
+
if (raw_data !== this.raw_data) {
|
|
81
|
+
await (0, promises_1.writeFile)(this.path, raw_data);
|
|
82
|
+
this.raw_data = raw_data;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
this.data = JSON.parse(this.raw_data);
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.Db = Db;
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./server/app"), exports);
|
|
18
|
+
__exportStar(require("./server/router"), exports);
|
|
19
|
+
__exportStar(require("./onebot"), exports);
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
21
|
+
__exportStar(require("./utils"), exports);
|
package/lib/onebot.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { App } from "./server/app";
|
|
4
|
+
import { Client } from "icqq";
|
|
5
|
+
import { V11 } from "./service/V11";
|
|
6
|
+
import { V12 } from "./service/V12";
|
|
7
|
+
import { MayBeArray } from "./types";
|
|
8
|
+
export declare class NotFoundError extends Error {
|
|
9
|
+
message: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class OneBot<V extends OneBot.Version> extends EventEmitter {
|
|
12
|
+
app: App;
|
|
13
|
+
readonly uin: number;
|
|
14
|
+
config: OneBotConfig[];
|
|
15
|
+
status: OneBotStatus;
|
|
16
|
+
protected password: string;
|
|
17
|
+
client: Client;
|
|
18
|
+
instances: (V11 | V12)[];
|
|
19
|
+
constructor(app: App, uin: number, config: MayBeArray<OneBotConfig>);
|
|
20
|
+
start(): void;
|
|
21
|
+
startListen(): void;
|
|
22
|
+
stop(): void;
|
|
23
|
+
dispatch(data: any): void;
|
|
24
|
+
}
|
|
25
|
+
export declare enum OneBotStatus {
|
|
26
|
+
Good = 0,
|
|
27
|
+
Bad = 1
|
|
28
|
+
}
|
|
29
|
+
export declare type OneBotConfig = OneBot.Config<OneBot.Version>;
|
|
30
|
+
export declare namespace OneBot {
|
|
31
|
+
type Version = 'V11' | 'V12';
|
|
32
|
+
type Config<V extends Version = 'V11'> = ({
|
|
33
|
+
version?: V;
|
|
34
|
+
password?: string;
|
|
35
|
+
} & (V extends 'V11' ? V11.Config : V12.Config));
|
|
36
|
+
interface Base {
|
|
37
|
+
start(path?: string): any;
|
|
38
|
+
stop(): any;
|
|
39
|
+
dispatch(...args: any[]): any;
|
|
40
|
+
apply(...args: any[]): any;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export declare const BOOLS: string[];
|
package/lib/onebot.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BOOLS = exports.OneBotStatus = exports.OneBot = exports.NotFoundError = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
const app_1 = require("./server/app");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const icqq_1 = require("icqq");
|
|
9
|
+
const V11_1 = require("./service/V11");
|
|
10
|
+
const V12_1 = require("./service/V12");
|
|
11
|
+
class NotFoundError extends Error {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.message = '不支持的API';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.NotFoundError = NotFoundError;
|
|
18
|
+
class OneBot extends events_1.EventEmitter {
|
|
19
|
+
constructor(app, uin, config) {
|
|
20
|
+
super();
|
|
21
|
+
this.app = app;
|
|
22
|
+
this.uin = uin;
|
|
23
|
+
if (!Array.isArray(config))
|
|
24
|
+
config = new Array(config);
|
|
25
|
+
this.config = config.map(c => {
|
|
26
|
+
if (c.password)
|
|
27
|
+
this.password = c.password;
|
|
28
|
+
if (!c.version)
|
|
29
|
+
c.version = 'V11';
|
|
30
|
+
switch (c.version) {
|
|
31
|
+
case 'V11':
|
|
32
|
+
return (0, utils_1.deepMerge)(this.app.config.general.V11, c);
|
|
33
|
+
case 'V12':
|
|
34
|
+
return (0, utils_1.deepMerge)(this.app.config.general.V12, c);
|
|
35
|
+
default:
|
|
36
|
+
throw new Error('不支持的oneBot版本:' + c.version);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
this.client = new icqq_1.Client(uin, { platform: this.app.config.platform, data_dir: (0, path_1.join)(app_1.App.configDir, 'data') });
|
|
40
|
+
this.instances = this.config.map(c => {
|
|
41
|
+
switch (c.version) {
|
|
42
|
+
case 'V11':
|
|
43
|
+
return new V11_1.V11(this, this.client, (0, utils_1.omit)(c, ['version', 'password']));
|
|
44
|
+
case 'V12':
|
|
45
|
+
return new V12_1.V12(this, this.client, (0, utils_1.omit)(c, ['version', 'password']));
|
|
46
|
+
default:
|
|
47
|
+
throw new Error('不支持的oneBot版本:' + c.version);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
start() {
|
|
52
|
+
this.startListen();
|
|
53
|
+
this.client.login(this.password);
|
|
54
|
+
}
|
|
55
|
+
startListen() {
|
|
56
|
+
this.client.on('system', this.dispatch.bind(this));
|
|
57
|
+
this.client.on('notice', this.dispatch.bind(this));
|
|
58
|
+
this.client.on('request', this.dispatch.bind(this));
|
|
59
|
+
this.client.on('message', this.dispatch.bind(this));
|
|
60
|
+
this.instances.forEach(instance => {
|
|
61
|
+
instance.start(this.instances.length > 1 ? '/' + instance.version : undefined);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
stop() {
|
|
65
|
+
this.instances.forEach(instance => {
|
|
66
|
+
instance.stop();
|
|
67
|
+
});
|
|
68
|
+
this.client.off('system', this.dispatch.bind(this));
|
|
69
|
+
this.client.off('notice', this.dispatch.bind(this));
|
|
70
|
+
this.client.off('request', this.dispatch.bind(this));
|
|
71
|
+
this.client.off('message', this.dispatch.bind(this));
|
|
72
|
+
}
|
|
73
|
+
dispatch(data) {
|
|
74
|
+
for (const instance of this.instances) {
|
|
75
|
+
instance.dispatch(data);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.OneBot = OneBot;
|
|
80
|
+
var OneBotStatus;
|
|
81
|
+
(function (OneBotStatus) {
|
|
82
|
+
OneBotStatus[OneBotStatus["Good"] = 0] = "Good";
|
|
83
|
+
OneBotStatus[OneBotStatus["Bad"] = 1] = "Bad";
|
|
84
|
+
})(OneBotStatus = exports.OneBotStatus || (exports.OneBotStatus = {}));
|
|
85
|
+
exports.BOOLS = ["no_cache", "auto_escape", "as_long", "enable", "reject_add_request", "is_dismiss", "approve", "block"];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="koa-bodyparser" />
|
|
3
|
+
import Koa from 'koa';
|
|
4
|
+
import { Logger } from "log4js";
|
|
5
|
+
import { Server } from "http";
|
|
6
|
+
import { OneBot } from "../onebot";
|
|
7
|
+
import { Router } from "./router";
|
|
8
|
+
import { V11 } from "../service/V11";
|
|
9
|
+
import { V12 } from "../service/V12";
|
|
10
|
+
import { LogLevel, MayBeArray } from "../types";
|
|
11
|
+
import { Platform } from "icqq";
|
|
12
|
+
export interface KoaOptions {
|
|
13
|
+
env?: string;
|
|
14
|
+
keys?: string[];
|
|
15
|
+
proxy?: boolean;
|
|
16
|
+
subdomainOffset?: number;
|
|
17
|
+
proxyIpHeader?: string;
|
|
18
|
+
maxIpsCount?: number;
|
|
19
|
+
}
|
|
20
|
+
export declare class App extends Koa {
|
|
21
|
+
config: App.Config;
|
|
22
|
+
readonly httpServer: Server;
|
|
23
|
+
logger: Logger;
|
|
24
|
+
static configDir: string;
|
|
25
|
+
static configPath: string;
|
|
26
|
+
oneBots: OneBot<any>[];
|
|
27
|
+
router: Router;
|
|
28
|
+
constructor(config?: App.Config);
|
|
29
|
+
getLogger(uin: number | string, version?: string): Logger;
|
|
30
|
+
private getBots;
|
|
31
|
+
private createOneBots;
|
|
32
|
+
addAccount(uin: number | `${number}`, config: MayBeArray<OneBot.Config<OneBot.Version>>): void;
|
|
33
|
+
updateAccount(uin: number | `${number}`, config: MayBeArray<OneBot.Config<OneBot.Version>>): void;
|
|
34
|
+
removeAccount(uin: number | `${number}`): void;
|
|
35
|
+
createOneBot(uin: number, config: MayBeArray<OneBot.Config<OneBot.Version>>): OneBot<OneBot.Version>;
|
|
36
|
+
start(): void;
|
|
37
|
+
}
|
|
38
|
+
export declare function createApp<V extends OneBot.Version>(config?: App.Config | string): App;
|
|
39
|
+
export declare function defineConfig(config: App.Config): App.Config;
|
|
40
|
+
export declare namespace App {
|
|
41
|
+
type Config = {
|
|
42
|
+
port?: number;
|
|
43
|
+
path?: string;
|
|
44
|
+
log_level?: LogLevel;
|
|
45
|
+
platform?: Platform;
|
|
46
|
+
general?: {
|
|
47
|
+
V11?: V11.Config;
|
|
48
|
+
V12?: V12.Config;
|
|
49
|
+
};
|
|
50
|
+
} & KoaOptions & Record<`${number}`, MayBeArray<OneBot.Config<OneBot.Version>>>;
|
|
51
|
+
const defaultConfig: Config;
|
|
52
|
+
}
|