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
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GroupAction = void 0;
|
|
4
|
+
class GroupAction {
|
|
5
|
+
/**
|
|
6
|
+
* 发送群聊消息
|
|
7
|
+
* @param group_id {number} 群id
|
|
8
|
+
* @param message {import('icqq').Sendable} 消息
|
|
9
|
+
*/
|
|
10
|
+
sendGroupMsg(group_id, message) {
|
|
11
|
+
return this.client.sendGroupMsg(group_id, message);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 群组踢人
|
|
15
|
+
* @param group_id {number} 群id
|
|
16
|
+
* @param user_id {number} 成员id
|
|
17
|
+
* @param reject_add_request {boolean} 是否禁止此人加群请求
|
|
18
|
+
*/
|
|
19
|
+
setGroupKick(group_id, user_id, reject_add_request) {
|
|
20
|
+
return this.client.setGroupKick(group_id, user_id, reject_add_request);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 群禁言指定人
|
|
24
|
+
* @param group_id {number} 群id
|
|
25
|
+
* @param user_id {number} 成员id
|
|
26
|
+
* @param duration {number} 禁言时长(单位:秒)
|
|
27
|
+
*/
|
|
28
|
+
setGroupBan(group_id, user_id, duration = 1800) {
|
|
29
|
+
return this.client.setGroupBan(group_id, user_id, duration);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 群禁言匿名者
|
|
33
|
+
* @param group_id {number} 群id
|
|
34
|
+
* @param flag {string} 匿名者flag
|
|
35
|
+
* @param duration {number} 禁言时长(单位:秒)
|
|
36
|
+
*/
|
|
37
|
+
setGroupAnonymousBan(group_id, flag, duration = 1800) {
|
|
38
|
+
return this.client.setGroupAnonymousBan(group_id, flag, duration);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 群全体禁言
|
|
42
|
+
* @param group_id {number} 群id
|
|
43
|
+
* @param enable {boolean} 是否禁言
|
|
44
|
+
*/
|
|
45
|
+
setGroupWholeBan(group_id, enable) {
|
|
46
|
+
return this.client.setGroupWholeBan(group_id, enable);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 群匿名聊天
|
|
50
|
+
* @param group_id {number} 群id
|
|
51
|
+
* @param enable {boolean} 是否开启
|
|
52
|
+
*/
|
|
53
|
+
setGroupAnonymous(group_id, enable) {
|
|
54
|
+
return this.client.setGroupAnonymous(group_id, enable);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 设置群管
|
|
58
|
+
* @param group_id {number} 群id
|
|
59
|
+
* @param user_id {number} 成员id
|
|
60
|
+
* @param enable {boolean} true 设为管理,false 取消管理
|
|
61
|
+
*/
|
|
62
|
+
setGroupAdmin(group_id, user_id, enable) {
|
|
63
|
+
return this.client.setGroupAdmin(group_id, user_id, enable);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 设置群成员名片(成员备注)
|
|
67
|
+
* @param group_id {number} 群id
|
|
68
|
+
* @param user_id {number} 成员id
|
|
69
|
+
* @param card {string} 名片信息,不传或传空串则为 删除名片
|
|
70
|
+
*/
|
|
71
|
+
setGroupCard(group_id, user_id, card) {
|
|
72
|
+
return this.client.setGroupCard(group_id, user_id, card);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 设置群名
|
|
76
|
+
* @param group_id {number} 群id
|
|
77
|
+
* @param name {string} 新群名
|
|
78
|
+
*/
|
|
79
|
+
setGroupName(group_id, name) {
|
|
80
|
+
return this.client.setGroupName(group_id, name);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 退出指定群聊
|
|
84
|
+
* @param group_id {number} 群id
|
|
85
|
+
*/
|
|
86
|
+
setGroupLeave(group_id) {
|
|
87
|
+
return this.client.setGroupLeave(group_id);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* 设置群成员头衔
|
|
91
|
+
* @param group_id {number} 群id
|
|
92
|
+
* @param user_id {number} 成员id
|
|
93
|
+
* @param special_title {string} 头衔
|
|
94
|
+
* @param duration {number} 持有时长 不传则永久
|
|
95
|
+
*/
|
|
96
|
+
setGroupSpecialTitle(group_id, user_id, special_title, duration = -1) {
|
|
97
|
+
return this.client.setGroupSpecialTitle(group_id, user_id, special_title, duration);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 处理加群请求
|
|
101
|
+
* @param flag {string} 加群flag
|
|
102
|
+
* @param approve {boolean} 是否同意(默认:true)
|
|
103
|
+
* @param reason {string} 拒绝理由,approve为false时有效(默认为空)
|
|
104
|
+
* @param block {boolean} 拒绝时是否加入黑名单,(默认:false)
|
|
105
|
+
*/
|
|
106
|
+
setGroupAddRequest(flag, approve = true, reason = '', block = false) {
|
|
107
|
+
return this.client.setGroupAddRequest(flag, approve, reason, block);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* 获取群列表
|
|
111
|
+
*/
|
|
112
|
+
async getGroupList() {
|
|
113
|
+
return this.client.getGroupList();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* 获取指定群信息
|
|
117
|
+
* @param group_id
|
|
118
|
+
*/
|
|
119
|
+
getGroupInfo(group_id) {
|
|
120
|
+
return this.client.getGroupInfo(group_id);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* 获取群成员列表
|
|
124
|
+
* @param group_id
|
|
125
|
+
*/
|
|
126
|
+
async getGroupMemberList(group_id) {
|
|
127
|
+
return this.client.getGroupMemberList(group_id);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* 获取指定群成员信息
|
|
131
|
+
* @param group_id
|
|
132
|
+
* @param user_id
|
|
133
|
+
*/
|
|
134
|
+
getGroupMemberInfo(group_id, user_id) {
|
|
135
|
+
return this.client.getGroupMemberInfo(group_id, user_id);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.GroupAction = GroupAction;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CommonAction } from "./common";
|
|
2
|
+
import { FriendAction } from "./friend";
|
|
3
|
+
import { GroupAction } from "./group";
|
|
4
|
+
export interface Action extends CommonAction, FriendAction, GroupAction {
|
|
5
|
+
}
|
|
6
|
+
declare const Action_base: import("../../../utils").Class;
|
|
7
|
+
export declare class Action extends Action_base {
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Action = void 0;
|
|
4
|
+
const common_1 = require("./common");
|
|
5
|
+
const friend_1 = require("./friend");
|
|
6
|
+
const group_1 = require("./group");
|
|
7
|
+
const utils_1 = require("../../../utils");
|
|
8
|
+
class Action extends (0, utils_1.Mixin)(common_1.CommonAction, friend_1.FriendAction, group_1.GroupAction) {
|
|
9
|
+
}
|
|
10
|
+
exports.Action = Action;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Client } from "icqq";
|
|
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(): 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: "success" | 'async' | 'error';
|
|
63
|
+
data: T;
|
|
64
|
+
error: string;
|
|
65
|
+
}
|
|
66
|
+
function success<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
|
+
}
|