onebots 0.0.13 → 0.0.15

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 +63 -63
  3. package/lib/bin.d.ts +2 -2
  4. package/lib/bin.js +5 -5
  5. package/lib/db.d.ts +19 -19
  6. package/lib/db.js +91 -91
  7. package/lib/index.d.ts +5 -5
  8. package/lib/index.js +21 -21
  9. package/lib/onebot.d.ts +44 -44
  10. package/lib/onebot.js +86 -86
  11. package/lib/server/app.d.ts +52 -52
  12. package/lib/server/app.js +232 -232
  13. package/lib/server/router.d.ts +9 -9
  14. package/lib/server/router.js +32 -32
  15. package/lib/service/V11/action/common.d.ts +65 -66
  16. package/lib/service/V11/action/common.js +142 -142
  17. package/lib/service/V11/action/friend.d.ts +38 -38
  18. package/lib/service/V11/action/friend.js +44 -44
  19. package/lib/service/V11/action/group.d.ts +104 -104
  20. package/lib/service/V11/action/group.js +138 -138
  21. package/lib/service/V11/action/index.d.ts +9 -9
  22. package/lib/service/V11/action/index.js +10 -10
  23. package/lib/service/V11/config.d.ts +10 -10
  24. package/lib/service/V11/config.js +2 -2
  25. package/lib/service/V11/index.d.ts +95 -95
  26. package/lib/service/V11/index.js +499 -488
  27. package/lib/service/V12/action/common.d.ts +33 -33
  28. package/lib/service/V12/action/common.js +108 -108
  29. package/lib/service/V12/action/friend.d.ts +13 -13
  30. package/lib/service/V12/action/friend.js +15 -15
  31. package/lib/service/V12/action/group.d.ts +104 -104
  32. package/lib/service/V12/action/group.js +138 -138
  33. package/lib/service/V12/action/guild.d.ts +2 -2
  34. package/lib/service/V12/action/guild.js +6 -6
  35. package/lib/service/V12/action/index.d.ts +10 -10
  36. package/lib/service/V12/action/index.js +11 -11
  37. package/lib/service/V12/config.d.ts +17 -17
  38. package/lib/service/V12/config.js +2 -2
  39. package/lib/service/V12/index.d.ts +102 -102
  40. package/lib/service/V12/index.js +538 -537
  41. package/lib/types.d.ts +3 -3
  42. package/lib/types.js +2 -2
  43. package/lib/utils.d.ts +14 -14
  44. package/lib/utils.js +150 -150
  45. package/package.json +58 -58
  46. package/lib/config.sample.yaml +0 -31
@@ -1,66 +1,65 @@
1
- import { OnlineStatus } from "oicq";
2
- import { V11 } from "../../../service/V11";
3
- export declare class CommonAction {
4
- /**
5
- * 获取登录信息
6
- */
7
- getLoginInfo(this: V11): {
8
- user_id: number;
9
- nickname: string;
10
- };
11
- /**
12
- * 撤回消息
13
- * @param message_id {string} 消息id
14
- */
15
- deleteMsg(this: V11, message_id: string): Promise<boolean>;
16
- /**
17
- * 获取消息
18
- * @param message_id {string} 消息id
19
- */
20
- getMsg(this: V11, message_id: string): Promise<import("oicq").GroupMessage | import("oicq").PrivateMessage>;
21
- /**
22
- * 获取合并消息
23
- * @param id {string} 合并id
24
- */
25
- getForwardMsg(this: V11, id: string): Promise<import("oicq").ForwardMessage[]>;
26
- /**
27
- * 获取 Cookies
28
- * @param domain {string} 域名
29
- */
30
- getCookies(this: V11, domain: string): any;
31
- /**
32
- * 获取 CSRF Token
33
- */
34
- getCsrfToken(this: V11): number;
35
- /**
36
- * 获取 QQ 相关接口凭证
37
- * @param domain
38
- */
39
- getCredentials(this: V11, domain: string): {
40
- cookies: any;
41
- csrf_token: number;
42
- };
43
- /**
44
- * 获取版本信息
45
- */
46
- getVersion(this: V11): {
47
- app_name: string;
48
- app_version: string;
49
- protocol_version: string;
50
- };
51
- /**
52
- * 重启OneBot实现
53
- * @param delay {number} 要延迟的毫秒数
54
- */
55
- setRestart(this: V11, delay: number): boolean;
56
- getStatus(this: V11): {
57
- online: OnlineStatus;
58
- good: boolean;
59
- };
60
- callLogin(this: V11, func: string, ...args: any[]): Promise<unknown>;
61
- submitSlider(this: V11, ticket: string): Promise<any>;
62
- submitSmsCode(this: V11, code: string): Promise<any>;
63
- sendSmsCode(this: V11): Promise<any>;
64
- login(this: V11, password?: string): any;
65
- logout(this: V11, keepalive?: boolean): Promise<unknown>;
66
- }
1
+ import { V11 } from "../../../service/V11";
2
+ export declare class CommonAction {
3
+ /**
4
+ * 获取登录信息
5
+ */
6
+ getLoginInfo(this: V11): {
7
+ user_id: number;
8
+ nickname: string;
9
+ };
10
+ /**
11
+ * 撤回消息
12
+ * @param message_id {string} 消息id
13
+ */
14
+ deleteMsg(this: V11, message_id: string): Promise<boolean>;
15
+ /**
16
+ * 获取消息
17
+ * @param message_id {string} 消息id
18
+ */
19
+ getMsg(this: V11, message_id: string): Promise<import("oicq").GroupMessage | import("oicq").PrivateMessage>;
20
+ /**
21
+ * 获取合并消息
22
+ * @param id {string} 合并id
23
+ */
24
+ getForwardMsg(this: V11, id: string): Promise<import("oicq").ForwardMessage[]>;
25
+ /**
26
+ * 获取 Cookies
27
+ * @param domain {string} 域名
28
+ */
29
+ getCookies(this: V11, domain: string): any;
30
+ /**
31
+ * 获取 CSRF Token
32
+ */
33
+ getCsrfToken(this: V11): number;
34
+ /**
35
+ * 获取 QQ 相关接口凭证
36
+ * @param domain
37
+ */
38
+ getCredentials(this: V11, domain: string): {
39
+ cookies: any;
40
+ csrf_token: number;
41
+ };
42
+ /**
43
+ * 获取版本信息
44
+ */
45
+ getVersion(this: V11): {
46
+ app_name: string;
47
+ app_version: string;
48
+ protocol_version: string;
49
+ };
50
+ /**
51
+ * 重启OneBot实现
52
+ * @param delay {number} 要延迟的毫秒数
53
+ */
54
+ setRestart(this: V11, delay: number): boolean;
55
+ getStatus(this: V11): {
56
+ online: boolean;
57
+ good: boolean;
58
+ };
59
+ callLogin(this: V11, func: string, ...args: any[]): Promise<unknown>;
60
+ submitSlider(this: V11, ticket: string): Promise<any>;
61
+ submitSmsCode(this: V11, code: string): Promise<any>;
62
+ sendSmsCode(this: V11): Promise<any>;
63
+ login(this: V11, password?: string): any;
64
+ logout(this: V11, keepalive?: boolean): Promise<unknown>;
65
+ }
@@ -1,142 +1,142 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommonAction = void 0;
4
- const oicq_1 = require("oicq");
5
- const onebot_1 = require("../../../onebot");
6
- class CommonAction {
7
- /**
8
- * 获取登录信息
9
- */
10
- getLoginInfo() {
11
- return {
12
- user_id: this.client.uin,
13
- nickname: this.client.nickname
14
- };
15
- }
16
- /**
17
- * 撤回消息
18
- * @param message_id {string} 消息id
19
- */
20
- deleteMsg(message_id) {
21
- return this.client.deleteMsg(message_id);
22
- }
23
- /**
24
- * 获取消息
25
- * @param message_id {string} 消息id
26
- */
27
- getMsg(message_id) {
28
- return this.client.getMsg(message_id);
29
- }
30
- /**
31
- * 获取合并消息
32
- * @param id {string} 合并id
33
- */
34
- getForwardMsg(id) {
35
- return this.client.getForwardMsg(id);
36
- }
37
- /**
38
- * 获取 Cookies
39
- * @param domain {string} 域名
40
- */
41
- getCookies(domain) {
42
- return this.client.cookies[domain];
43
- }
44
- /**
45
- * 获取 CSRF Token
46
- */
47
- getCsrfToken() {
48
- return this.client.getCsrfToken();
49
- }
50
- /**
51
- * 获取 QQ 相关接口凭证
52
- * @param domain
53
- */
54
- getCredentials(domain) {
55
- return {
56
- cookies: this.client.cookies[domain],
57
- csrf_token: this.client.getCsrfToken()
58
- };
59
- }
60
- /**
61
- * 获取版本信息
62
- */
63
- getVersion() {
64
- return {
65
- app_name: 'oicq',
66
- app_version: '2.x',
67
- protocol_version: 'v11'
68
- };
69
- }
70
- /**
71
- * 重启OneBot实现
72
- * @param delay {number} 要延迟的毫秒数
73
- */
74
- setRestart(delay) {
75
- return this.emit('restart', delay);
76
- }
77
- getStatus() {
78
- return {
79
- online: this.client.status = oicq_1.OnlineStatus.Online,
80
- good: this.oneBot.status === onebot_1.OneBotStatus.Good
81
- };
82
- }
83
- callLogin(func, ...args) {
84
- return new Promise(async (resolve) => {
85
- const receiveResult = (event) => {
86
- this.client.off('system.login.qrcode', receiveResult);
87
- this.client.off('system.login.device', receiveResult);
88
- this.client.off('system.login.slider', receiveResult);
89
- this.client.off('system.login.error', receiveResult);
90
- resolve(event);
91
- };
92
- this.client.on('system.login.qrcode', receiveResult);
93
- this.client.on('system.login.device', receiveResult);
94
- this.client.on('system.login.slider', receiveResult);
95
- this.client.on('system.login.error', receiveResult);
96
- this.client.once('system.online', receiveResult);
97
- try {
98
- await this.client[func](...args);
99
- }
100
- catch (reason) {
101
- receiveResult(reason);
102
- }
103
- });
104
- }
105
- async submitSlider(ticket) {
106
- return this.action.callLogin.apply(this, ['submitSlider', ticket]);
107
- }
108
- async submitSmsCode(code) {
109
- return this.action.callLogin.apply(this, ['submitSmsCode', code]);
110
- }
111
- sendSmsCode() {
112
- return new Promise(resolve => {
113
- const receiveResult = (e) => {
114
- const callback = (data) => {
115
- this.client.off('internal.verbose', receiveResult);
116
- this.client.off('system.login.error', receiveResult);
117
- resolve(data);
118
- };
119
- if ((typeof e === 'string' && e.includes('已发送')) || typeof e !== 'string') {
120
- callback(e);
121
- }
122
- };
123
- this.client.on('internal.verbose', receiveResult);
124
- this.client.on('system.login.error', receiveResult);
125
- this.client.sendSmsCode();
126
- });
127
- }
128
- login(password) {
129
- return this.action.callLogin.apply(this, ['login', password]);
130
- }
131
- logout(keepalive) {
132
- return new Promise(async (resolve) => {
133
- const receiveResult = (e) => {
134
- this.client.off('system.offline', receiveResult);
135
- resolve(e);
136
- };
137
- this.client.on('system.offline', receiveResult);
138
- await this.client.logout(keepalive);
139
- });
140
- }
141
- }
142
- exports.CommonAction = CommonAction;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommonAction = void 0;
4
+ const oicq_1 = require("oicq");
5
+ const onebot_1 = require("../../../onebot");
6
+ class CommonAction {
7
+ /**
8
+ * 获取登录信息
9
+ */
10
+ getLoginInfo() {
11
+ return {
12
+ user_id: this.client.uin,
13
+ nickname: this.client.nickname
14
+ };
15
+ }
16
+ /**
17
+ * 撤回消息
18
+ * @param message_id {string} 消息id
19
+ */
20
+ deleteMsg(message_id) {
21
+ return this.client.deleteMsg(message_id);
22
+ }
23
+ /**
24
+ * 获取消息
25
+ * @param message_id {string} 消息id
26
+ */
27
+ getMsg(message_id) {
28
+ return this.client.getMsg(message_id);
29
+ }
30
+ /**
31
+ * 获取合并消息
32
+ * @param id {string} 合并id
33
+ */
34
+ getForwardMsg(id) {
35
+ return this.client.getForwardMsg(id);
36
+ }
37
+ /**
38
+ * 获取 Cookies
39
+ * @param domain {string} 域名
40
+ */
41
+ getCookies(domain) {
42
+ return this.client.cookies[domain];
43
+ }
44
+ /**
45
+ * 获取 CSRF Token
46
+ */
47
+ getCsrfToken() {
48
+ return this.client.getCsrfToken();
49
+ }
50
+ /**
51
+ * 获取 QQ 相关接口凭证
52
+ * @param domain
53
+ */
54
+ getCredentials(domain) {
55
+ return {
56
+ cookies: this.client.cookies[domain],
57
+ csrf_token: this.client.getCsrfToken()
58
+ };
59
+ }
60
+ /**
61
+ * 获取版本信息
62
+ */
63
+ getVersion() {
64
+ return {
65
+ app_name: 'oicq',
66
+ app_version: '2.x',
67
+ protocol_version: 'v11'
68
+ };
69
+ }
70
+ /**
71
+ * 重启OneBot实现
72
+ * @param delay {number} 要延迟的毫秒数
73
+ */
74
+ setRestart(delay) {
75
+ return this.emit('restart', delay);
76
+ }
77
+ getStatus() {
78
+ return {
79
+ online: this.client.status === oicq_1.OnlineStatus.Online,
80
+ good: this.oneBot.status === onebot_1.OneBotStatus.Good
81
+ };
82
+ }
83
+ callLogin(func, ...args) {
84
+ return new Promise(async (resolve) => {
85
+ const receiveResult = (event) => {
86
+ this.client.off('system.login.qrcode', receiveResult);
87
+ this.client.off('system.login.device', receiveResult);
88
+ this.client.off('system.login.slider', receiveResult);
89
+ this.client.off('system.login.error', receiveResult);
90
+ resolve(event);
91
+ };
92
+ this.client.on('system.login.qrcode', receiveResult);
93
+ this.client.on('system.login.device', receiveResult);
94
+ this.client.on('system.login.slider', receiveResult);
95
+ this.client.on('system.login.error', receiveResult);
96
+ this.client.once('system.online', receiveResult);
97
+ try {
98
+ await this.client[func](...args);
99
+ }
100
+ catch (reason) {
101
+ receiveResult(reason);
102
+ }
103
+ });
104
+ }
105
+ async submitSlider(ticket) {
106
+ return this.action.callLogin.apply(this, ['submitSlider', ticket]);
107
+ }
108
+ async submitSmsCode(code) {
109
+ return this.action.callLogin.apply(this, ['submitSmsCode', code]);
110
+ }
111
+ sendSmsCode() {
112
+ return new Promise(resolve => {
113
+ const receiveResult = (e) => {
114
+ const callback = (data) => {
115
+ this.client.off('internal.verbose', receiveResult);
116
+ this.client.off('system.login.error', receiveResult);
117
+ resolve(data);
118
+ };
119
+ if ((typeof e === 'string' && e.includes('已发送')) || typeof e !== 'string') {
120
+ callback(e);
121
+ }
122
+ };
123
+ this.client.on('internal.verbose', receiveResult);
124
+ this.client.on('system.login.error', receiveResult);
125
+ this.client.sendSmsCode();
126
+ });
127
+ }
128
+ login(password) {
129
+ return this.action.callLogin.apply(this, ['login', password]);
130
+ }
131
+ logout(keepalive) {
132
+ return new Promise(async (resolve) => {
133
+ const receiveResult = (e) => {
134
+ this.client.off('system.offline', receiveResult);
135
+ resolve(e);
136
+ };
137
+ this.client.on('system.offline', receiveResult);
138
+ await this.client.logout(keepalive);
139
+ });
140
+ }
141
+ }
142
+ exports.CommonAction = CommonAction;
@@ -1,38 +1,38 @@
1
- import { OneBot } from "../../../onebot";
2
- import { Sendable } from "oicq";
3
- export declare class FriendAction {
4
- /**
5
- * 发送私聊消息
6
- * @param user_id {number} 用户id
7
- * @param message {import('oicq').Sendable} 发送的消息
8
- */
9
- sendPrivateMsg(this: OneBot<'V11'>, user_id: number, message: Sendable): Promise<import("oicq").MessageRet>;
10
- /**
11
- * 获取好友列表
12
- */
13
- getFriendList(this: OneBot<'V11'>): Promise<import("oicq").FriendInfo[]>;
14
- /**
15
- * 处理好友添加请求
16
- * @param flag {string} 请求flag
17
- * @param approve {boolean} 是否同意
18
- * @param remark {string} 添加后的备注
19
- */
20
- setFriendAddRequest(this: OneBot<'V11'>, flag: string, approve?: boolean, remark?: string): Promise<boolean>;
21
- /**
22
- * 获取陌生人信息
23
- * @param user_id {number} 用户id
24
- */
25
- getStrangerInfo(this: OneBot<'V11'>, user_id: number): Promise<{
26
- user_id: number;
27
- nickname: string;
28
- sex: import("oicq").Gender;
29
- age: number;
30
- area: string;
31
- }>;
32
- /**
33
- * 发送好友赞
34
- * @param user_id {number} 用户id
35
- * @param times 点赞次数
36
- */
37
- sendLike(this: OneBot<'V11'>, user_id: number, times?: number): Promise<boolean>;
38
- }
1
+ import { OneBot } from "../../../onebot";
2
+ import { Sendable } from "oicq";
3
+ export declare class FriendAction {
4
+ /**
5
+ * 发送私聊消息
6
+ * @param user_id {number} 用户id
7
+ * @param message {import('oicq').Sendable} 发送的消息
8
+ */
9
+ sendPrivateMsg(this: OneBot<'V11'>, user_id: number, message: Sendable): Promise<import("oicq").MessageRet>;
10
+ /**
11
+ * 获取好友列表
12
+ */
13
+ getFriendList(this: OneBot<'V11'>): Promise<import("oicq").FriendInfo[]>;
14
+ /**
15
+ * 处理好友添加请求
16
+ * @param flag {string} 请求flag
17
+ * @param approve {boolean} 是否同意
18
+ * @param remark {string} 添加后的备注
19
+ */
20
+ setFriendAddRequest(this: OneBot<'V11'>, flag: string, approve?: boolean, remark?: string): Promise<boolean>;
21
+ /**
22
+ * 获取陌生人信息
23
+ * @param user_id {number} 用户id
24
+ */
25
+ getStrangerInfo(this: OneBot<'V11'>, user_id: number): Promise<{
26
+ user_id: number;
27
+ nickname: string;
28
+ sex: import("oicq").Gender;
29
+ age: number;
30
+ area: string;
31
+ }>;
32
+ /**
33
+ * 发送好友赞
34
+ * @param user_id {number} 用户id
35
+ * @param times 点赞次数
36
+ */
37
+ sendLike(this: OneBot<'V11'>, user_id: number, times?: number): Promise<boolean>;
38
+ }
@@ -1,44 +1,44 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FriendAction = void 0;
4
- class FriendAction {
5
- /**
6
- * 发送私聊消息
7
- * @param user_id {number} 用户id
8
- * @param message {import('oicq').Sendable} 发送的消息
9
- */
10
- sendPrivateMsg(user_id, message) {
11
- return this.client.sendPrivateMsg(user_id, message);
12
- }
13
- /**
14
- * 获取好友列表
15
- */
16
- async getFriendList() {
17
- return [...(await this.client.getFriendList()).values()];
18
- }
19
- /**
20
- * 处理好友添加请求
21
- * @param flag {string} 请求flag
22
- * @param approve {boolean} 是否同意
23
- * @param remark {string} 添加后的备注
24
- */
25
- async setFriendAddRequest(flag, approve = true, remark = '') {
26
- return await this.client.setFriendAddRequest(flag, approve, remark);
27
- }
28
- /**
29
- * 获取陌生人信息
30
- * @param user_id {number} 用户id
31
- */
32
- async getStrangerInfo(user_id) {
33
- return await this.client.getStrangerInfo(user_id);
34
- }
35
- /**
36
- * 发送好友赞
37
- * @param user_id {number} 用户id
38
- * @param times 点赞次数
39
- */
40
- async sendLike(user_id, times) {
41
- return this.client.sendLike(user_id, times);
42
- }
43
- }
44
- exports.FriendAction = FriendAction;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FriendAction = void 0;
4
+ class FriendAction {
5
+ /**
6
+ * 发送私聊消息
7
+ * @param user_id {number} 用户id
8
+ * @param message {import('oicq').Sendable} 发送的消息
9
+ */
10
+ sendPrivateMsg(user_id, message) {
11
+ return this.client.sendPrivateMsg(user_id, message);
12
+ }
13
+ /**
14
+ * 获取好友列表
15
+ */
16
+ async getFriendList() {
17
+ return [...(await this.client.getFriendList()).values()];
18
+ }
19
+ /**
20
+ * 处理好友添加请求
21
+ * @param flag {string} 请求flag
22
+ * @param approve {boolean} 是否同意
23
+ * @param remark {string} 添加后的备注
24
+ */
25
+ async setFriendAddRequest(flag, approve = true, remark = '') {
26
+ return await this.client.setFriendAddRequest(flag, approve, remark);
27
+ }
28
+ /**
29
+ * 获取陌生人信息
30
+ * @param user_id {number} 用户id
31
+ */
32
+ async getStrangerInfo(user_id) {
33
+ return await this.client.getStrangerInfo(user_id);
34
+ }
35
+ /**
36
+ * 发送好友赞
37
+ * @param user_id {number} 用户id
38
+ * @param times 点赞次数
39
+ */
40
+ async sendLike(user_id, times) {
41
+ return this.client.sendLike(user_id, times);
42
+ }
43
+ }
44
+ exports.FriendAction = FriendAction;