onebots 0.0.15 → 0.0.17

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.
Files changed (46) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +84 -63
  3. package/lib/bin.d.ts +2 -2
  4. package/lib/bin.js +11 -5
  5. package/lib/config.sample.yaml +31 -0
  6. package/lib/db.d.ts +19 -19
  7. package/lib/db.js +91 -91
  8. package/lib/index.d.ts +5 -5
  9. package/lib/index.js +21 -21
  10. package/lib/onebot.d.ts +44 -44
  11. package/lib/onebot.js +133 -86
  12. package/lib/server/app.d.ts +52 -52
  13. package/lib/server/app.js +235 -232
  14. package/lib/server/router.d.ts +9 -9
  15. package/lib/server/router.js +32 -32
  16. package/lib/service/V11/action/common.d.ts +65 -65
  17. package/lib/service/V11/action/common.js +142 -142
  18. package/lib/service/V11/action/friend.d.ts +38 -38
  19. package/lib/service/V11/action/friend.js +44 -44
  20. package/lib/service/V11/action/group.d.ts +104 -104
  21. package/lib/service/V11/action/group.js +138 -138
  22. package/lib/service/V11/action/index.d.ts +9 -9
  23. package/lib/service/V11/action/index.js +10 -10
  24. package/lib/service/V11/config.d.ts +10 -10
  25. package/lib/service/V11/config.js +2 -2
  26. package/lib/service/V11/index.d.ts +95 -95
  27. package/lib/service/V11/index.js +499 -499
  28. package/lib/service/V12/action/common.d.ts +37 -33
  29. package/lib/service/V12/action/common.js +114 -108
  30. package/lib/service/V12/action/friend.d.ts +13 -13
  31. package/lib/service/V12/action/friend.js +15 -15
  32. package/lib/service/V12/action/group.d.ts +104 -104
  33. package/lib/service/V12/action/group.js +138 -138
  34. package/lib/service/V12/action/guild.d.ts +2 -2
  35. package/lib/service/V12/action/guild.js +6 -6
  36. package/lib/service/V12/action/index.d.ts +10 -10
  37. package/lib/service/V12/action/index.js +11 -11
  38. package/lib/service/V12/config.d.ts +17 -17
  39. package/lib/service/V12/config.js +2 -2
  40. package/lib/service/V12/index.d.ts +121 -102
  41. package/lib/service/V12/index.js +539 -538
  42. package/lib/types.d.ts +3 -3
  43. package/lib/types.js +2 -2
  44. package/lib/utils.d.ts +14 -14
  45. package/lib/utils.js +150 -150
  46. package/package.json +58 -58
@@ -1,95 +1,95 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { Client } from "oicq";
4
- import { Config } from "./config";
5
- import { Action } from "./action";
6
- import { OneBot } from "../../onebot";
7
- import { Logger } from "log4js";
8
- import { WebSocket, WebSocketServer } from "ws";
9
- import { Dispose } from "../../types";
10
- import { EventEmitter } from "events";
11
- export declare class V11 extends EventEmitter implements OneBot.Base {
12
- oneBot: OneBot<'V11'>;
13
- client: Client;
14
- config: V11.Config;
15
- action: Action;
16
- version: string;
17
- protected timestamp: number;
18
- protected heartbeat?: NodeJS.Timeout;
19
- private path;
20
- disposes: Dispose[];
21
- protected _queue: Array<{
22
- method: keyof Action;
23
- args: any[];
24
- }>;
25
- protected queue_running: boolean;
26
- logger: Logger;
27
- wss?: WebSocketServer;
28
- wsr: Set<WebSocket>;
29
- constructor(oneBot: OneBot<'V11'>, client: Client, config: V11.Config);
30
- start(path?: string): void;
31
- private startHttp;
32
- private startHttpReverse;
33
- private startWs;
34
- private startWsReverse;
35
- stop(force?: boolean): Promise<void>;
36
- dispatch(data: any): void;
37
- private _httpRequestHandler;
38
- /**
39
- * 处理ws消息
40
- */
41
- protected _webSocketHandler(ws: WebSocket): void;
42
- /**
43
- * 创建反向ws
44
- */
45
- protected _createWsr(url: string): import("ws");
46
- /**
47
- * 快速操作
48
- */
49
- protected _quickOperate(event: any, res: any): void;
50
- /**
51
- * 调用api
52
- */
53
- apply(req: V11.Protocol): Promise<string>;
54
- /**
55
- * 限速队列调用
56
- */
57
- protected _runQueue(): Promise<void>;
58
- }
59
- export declare namespace V11 {
60
- interface Result<T extends any> {
61
- retcode: number;
62
- status: "ok" | 'async' | 'error';
63
- data: T;
64
- error: string;
65
- }
66
- function ok<T extends any>(data: T, retcode?: number, pending?: boolean): Result<T>;
67
- function error(error: string, retcode?: number): Result<any>;
68
- const defaultConfig: Config;
69
- function genMetaEvent(uin: number, type: string): {
70
- self_id: number;
71
- time: number;
72
- post_type: string;
73
- meta_event_type: string;
74
- sub_type: string;
75
- };
76
- interface Protocol {
77
- action: string;
78
- params: any;
79
- echo?: any;
80
- }
81
- interface Config {
82
- access_token?: string;
83
- post_timeout?: number;
84
- enable_cors?: boolean;
85
- rate_limit_interval?: number;
86
- post_message_format?: 'string' | 'array';
87
- heartbeat?: number;
88
- secret?: string;
89
- reconnect_interval?: number;
90
- use_http?: boolean;
91
- use_ws?: boolean;
92
- http_reverse?: (string | Config.HttpReverseConfig)[];
93
- ws_reverse?: string[];
94
- }
95
- }
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { Client } from "oicq";
4
+ import { Config } from "./config";
5
+ import { Action } from "./action";
6
+ import { OneBot } from "../../onebot";
7
+ import { Logger } from "log4js";
8
+ import { WebSocket, WebSocketServer } from "ws";
9
+ import { Dispose } from "../../types";
10
+ import { EventEmitter } from "events";
11
+ export declare class V11 extends EventEmitter implements OneBot.Base {
12
+ oneBot: OneBot<'V11'>;
13
+ client: Client;
14
+ config: V11.Config;
15
+ action: Action;
16
+ version: string;
17
+ protected timestamp: number;
18
+ protected heartbeat?: NodeJS.Timeout;
19
+ private path;
20
+ disposes: Dispose[];
21
+ protected _queue: Array<{
22
+ method: keyof Action;
23
+ args: any[];
24
+ }>;
25
+ protected queue_running: boolean;
26
+ logger: Logger;
27
+ wss?: WebSocketServer;
28
+ wsr: Set<WebSocket>;
29
+ constructor(oneBot: OneBot<'V11'>, client: Client, config: V11.Config);
30
+ start(path?: string): void;
31
+ private startHttp;
32
+ private startHttpReverse;
33
+ private startWs;
34
+ private startWsReverse;
35
+ stop(force?: boolean): Promise<void>;
36
+ dispatch(data: any): void;
37
+ private _httpRequestHandler;
38
+ /**
39
+ * 处理ws消息
40
+ */
41
+ protected _webSocketHandler(ws: WebSocket): void;
42
+ /**
43
+ * 创建反向ws
44
+ */
45
+ protected _createWsr(url: string): import("ws");
46
+ /**
47
+ * 快速操作
48
+ */
49
+ protected _quickOperate(event: any, res: any): void;
50
+ /**
51
+ * 调用api
52
+ */
53
+ apply(req: V11.Protocol): Promise<string>;
54
+ /**
55
+ * 限速队列调用
56
+ */
57
+ protected _runQueue(): Promise<void>;
58
+ }
59
+ export declare namespace V11 {
60
+ interface Result<T extends any> {
61
+ retcode: number;
62
+ status: "ok" | 'async' | 'error';
63
+ data: T;
64
+ error: string;
65
+ }
66
+ function ok<T extends any>(data: T, retcode?: number, pending?: boolean): Result<T>;
67
+ function error(error: string, retcode?: number): Result<any>;
68
+ const defaultConfig: Config;
69
+ function genMetaEvent(uin: number, type: string): {
70
+ self_id: number;
71
+ time: number;
72
+ post_type: string;
73
+ meta_event_type: string;
74
+ sub_type: string;
75
+ };
76
+ interface Protocol {
77
+ action: string;
78
+ params: any;
79
+ echo?: any;
80
+ }
81
+ interface Config {
82
+ access_token?: string;
83
+ post_timeout?: number;
84
+ enable_cors?: boolean;
85
+ rate_limit_interval?: number;
86
+ post_message_format?: 'string' | 'array';
87
+ heartbeat?: number;
88
+ secret?: string;
89
+ reconnect_interval?: number;
90
+ use_http?: boolean;
91
+ use_ws?: boolean;
92
+ http_reverse?: (string | Config.HttpReverseConfig)[];
93
+ ws_reverse?: string[];
94
+ }
95
+ }