@kotori-bot/core 1.5.1 → 1.6.0
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 +10 -4
- package/lib/app/config.d.ts +32 -0
- package/lib/app/config.js +65 -0
- package/lib/app/core.d.ts +138 -0
- package/lib/{components → app}/core.js +24 -10
- package/lib/app/index.d.ts +1 -0
- package/lib/{service → app}/index.js +7 -13
- package/lib/{components → app}/message.d.ts +11 -10
- package/lib/app/message.js +253 -0
- package/lib/components/adapter.d.ts +122 -0
- package/lib/components/adapter.js +75 -0
- package/lib/components/api.d.ts +417 -0
- package/lib/components/api.js +546 -0
- package/lib/components/cache.d.ts +37 -0
- package/lib/{service → components}/cache.js +27 -6
- package/lib/components/command.d.ts +153 -0
- package/lib/{utils → components}/command.js +154 -48
- package/lib/components/elements.d.ts +144 -0
- package/lib/components/elements.js +179 -0
- package/lib/components/filter.d.ts +22 -0
- package/lib/components/filter.js +130 -0
- package/lib/components/index.d.ts +8 -2
- package/lib/components/index.js +19 -7
- package/lib/components/messages.d.ts +186 -0
- package/lib/components/messages.js +218 -0
- package/lib/components/session.d.ts +177 -0
- package/lib/components/session.js +275 -0
- package/lib/decorators/index.d.ts +7 -0
- package/lib/{components/config.js → decorators/index.js} +23 -39
- package/lib/decorators/plugin.d.ts +7 -0
- package/lib/{utils/commandError.js → decorators/plugin.js} +16 -16
- package/lib/decorators/utils.d.ts +59 -0
- package/lib/decorators/utils.js +189 -0
- package/lib/global/constants.d.ts +1 -8
- package/lib/global/constants.js +6 -25
- package/lib/global/index.js +3 -3
- package/lib/global/symbols.d.ts +13 -8
- package/lib/global/symbols.js +18 -12
- package/lib/index.d.ts +4 -4
- package/lib/index.js +10 -11
- package/lib/types/adapter.d.ts +1 -1
- package/lib/types/adapter.js +3 -3
- package/lib/types/api.d.ts +72 -0
- package/lib/{utils/jsxFactory.js → types/api.js} +5 -5
- package/lib/types/command.d.ts +78 -0
- package/lib/types/command.js +50 -0
- package/lib/types/config.d.ts +4 -6
- package/lib/types/config.js +3 -3
- package/lib/types/filter.d.ts +51 -0
- package/lib/types/filter.js +87 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/index.js +12 -4
- package/lib/types/message.d.ts +128 -193
- package/lib/types/message.js +12 -31
- package/lib/types/session.d.ts +349 -0
- package/lib/types/session.js +27 -0
- package/lib/utils/container.d.ts +6 -6
- package/lib/utils/container.js +12 -16
- package/lib/utils/error.d.ts +46 -22
- package/lib/utils/error.js +38 -21
- package/lib/utils/factory.d.ts +10 -16
- package/lib/utils/factory.js +41 -101
- package/lib/utils/internal.d.ts +46 -0
- package/lib/utils/internal.js +102 -0
- package/package.json +10 -7
- package/lib/components/config.d.ts +0 -16
- package/lib/components/core.d.ts +0 -34
- package/lib/components/message.js +0 -195
- package/lib/service/adapter.d.ts +0 -41
- package/lib/service/adapter.js +0 -131
- package/lib/service/api.d.ts +0 -32
- package/lib/service/api.js +0 -80
- package/lib/service/cache.d.ts +0 -13
- package/lib/service/elements.d.ts +0 -12
- package/lib/service/elements.js +0 -73
- package/lib/service/index.d.ts +0 -4
- package/lib/utils/command.d.ts +0 -51
- package/lib/utils/commandError.d.ts +0 -7
- package/lib/utils/jsxFactory.d.ts +0 -6
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { Context, EventsList } from 'fluoro';
|
|
2
|
+
import type Api from './api';
|
|
3
|
+
import type { AdapterConfig, EventDataApiBase } from '../types';
|
|
4
|
+
import type Elements from './elements';
|
|
5
|
+
import { Session } from './session';
|
|
6
|
+
export type EventApiType = {
|
|
7
|
+
[K in keyof EventsList]: EventsList[K] extends EventDataApiBase ? EventsList[K] : never;
|
|
8
|
+
};
|
|
9
|
+
/** Bot Status */
|
|
10
|
+
interface AdapterStatus {
|
|
11
|
+
/** Online status */
|
|
12
|
+
value: 'online' | 'offline';
|
|
13
|
+
/** Bot create time */
|
|
14
|
+
createTime: Date;
|
|
15
|
+
/** Bot last sending message time, or empty if haven't received message */
|
|
16
|
+
lastMsgTime: Date | null;
|
|
17
|
+
/** Received message count */
|
|
18
|
+
receivedMsg: number;
|
|
19
|
+
/** Sent message count */
|
|
20
|
+
sentMsg: number;
|
|
21
|
+
/** Offline times */
|
|
22
|
+
offlineTimes: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Platform adapter.
|
|
26
|
+
*
|
|
27
|
+
* @template A - Api instance of bot bind
|
|
28
|
+
* @template C - Adapter config
|
|
29
|
+
* @template E - Elements instance of bot bind
|
|
30
|
+
*
|
|
31
|
+
* @class
|
|
32
|
+
* @abstract
|
|
33
|
+
*/
|
|
34
|
+
export interface AdapterImpl<A extends Api = Api, C extends AdapterConfig = AdapterConfig, E extends Elements = Elements> {
|
|
35
|
+
/**
|
|
36
|
+
* Context instance.
|
|
37
|
+
*
|
|
38
|
+
* @readonly
|
|
39
|
+
*/
|
|
40
|
+
readonly ctx: Context;
|
|
41
|
+
/**
|
|
42
|
+
* Adapter config.
|
|
43
|
+
*
|
|
44
|
+
* @readonly
|
|
45
|
+
*/
|
|
46
|
+
readonly config: C;
|
|
47
|
+
/**
|
|
48
|
+
* Adapter support platform.
|
|
49
|
+
*
|
|
50
|
+
* @readonly
|
|
51
|
+
*/
|
|
52
|
+
readonly platform: string;
|
|
53
|
+
/**
|
|
54
|
+
* Platform id of bot instanceof itself.
|
|
55
|
+
*
|
|
56
|
+
* @readonly
|
|
57
|
+
*/
|
|
58
|
+
readonly selfId: string;
|
|
59
|
+
/**
|
|
60
|
+
* Unique identity of bot.
|
|
61
|
+
*
|
|
62
|
+
* @readonly
|
|
63
|
+
*/
|
|
64
|
+
readonly identity: string;
|
|
65
|
+
/**
|
|
66
|
+
* Api instance of bot bind.
|
|
67
|
+
*
|
|
68
|
+
* @readonly
|
|
69
|
+
*/
|
|
70
|
+
readonly api: A;
|
|
71
|
+
/**
|
|
72
|
+
* Elements instance of bot bind.
|
|
73
|
+
*
|
|
74
|
+
* @readonly
|
|
75
|
+
*/
|
|
76
|
+
readonly elements: E;
|
|
77
|
+
/**
|
|
78
|
+
* Bot status.
|
|
79
|
+
*
|
|
80
|
+
* @readonly
|
|
81
|
+
*/
|
|
82
|
+
readonly status: AdapterStatus;
|
|
83
|
+
/**
|
|
84
|
+
* Handle interactive data from platform.
|
|
85
|
+
*
|
|
86
|
+
* @param data - Data from platform.
|
|
87
|
+
*/
|
|
88
|
+
handle(...data: unknown[]): void;
|
|
89
|
+
/**
|
|
90
|
+
* Start bot.
|
|
91
|
+
*/
|
|
92
|
+
start(): void;
|
|
93
|
+
/**
|
|
94
|
+
* Stop bot.
|
|
95
|
+
*/
|
|
96
|
+
stop(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Send interactive data to platform.
|
|
99
|
+
*
|
|
100
|
+
* @param data - Data to send.
|
|
101
|
+
*/
|
|
102
|
+
send(...data: unknown[]): void;
|
|
103
|
+
}
|
|
104
|
+
export declare abstract class Adapter<A extends Api = Api, C extends AdapterConfig = AdapterConfig, E extends Elements = Elements> implements AdapterImpl<A, C, E> {
|
|
105
|
+
constructor(ctx: Context, config: C, identity: string);
|
|
106
|
+
abstract readonly platform: string;
|
|
107
|
+
abstract readonly api: A;
|
|
108
|
+
abstract readonly elements: E;
|
|
109
|
+
abstract handle(...data: unknown[]): void;
|
|
110
|
+
abstract start(): void;
|
|
111
|
+
abstract stop(): void;
|
|
112
|
+
abstract send(...data: unknown[]): void;
|
|
113
|
+
protected online(): void;
|
|
114
|
+
protected offline(): void;
|
|
115
|
+
protected session<N extends keyof EventApiType>(type: N, data: EventApiType[N] extends Session<infer U> ? U : never): void;
|
|
116
|
+
readonly ctx: Context;
|
|
117
|
+
readonly config: C;
|
|
118
|
+
readonly identity: string;
|
|
119
|
+
readonly status: AdapterStatus;
|
|
120
|
+
selfId: string;
|
|
121
|
+
}
|
|
122
|
+
export default Adapter;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @Package @kotori-bot/core
|
|
4
|
+
* @Version 1.6.0-rc.1
|
|
5
|
+
* @Author Arimura Sena <me@hotaru.icu>
|
|
6
|
+
* @Copyright 2024 Hotaru. All rights reserved.
|
|
7
|
+
* @License GPL-3.0
|
|
8
|
+
* @Link https://github.com/kotorijs/kotori
|
|
9
|
+
* @Date 2024/8/9 17:33:05
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
"use strict";
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var adapter_exports = {};
|
|
31
|
+
__export(adapter_exports, {
|
|
32
|
+
Adapter: () => Adapter,
|
|
33
|
+
default: () => adapter_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(adapter_exports);
|
|
36
|
+
var import_session = require("./session");
|
|
37
|
+
class Adapter {
|
|
38
|
+
constructor(ctx, config, identity) {
|
|
39
|
+
this.ctx = ctx;
|
|
40
|
+
this.config = config;
|
|
41
|
+
this.identity = identity;
|
|
42
|
+
}
|
|
43
|
+
online() {
|
|
44
|
+
if (this.status.value !== "offline") return;
|
|
45
|
+
this.status.value = "online";
|
|
46
|
+
this.ctx.emit("status", { adapter: this, status: "online" });
|
|
47
|
+
}
|
|
48
|
+
offline() {
|
|
49
|
+
if (this.status.value !== "online") return;
|
|
50
|
+
this.status.value = "offline";
|
|
51
|
+
this.status.offlineTimes += 1;
|
|
52
|
+
this.ctx.emit("status", { adapter: this, status: "offline" });
|
|
53
|
+
}
|
|
54
|
+
session(type, data) {
|
|
55
|
+
const session = new import_session.Session(data, this);
|
|
56
|
+
this.ctx.emit(type, ...[session]);
|
|
57
|
+
}
|
|
58
|
+
ctx;
|
|
59
|
+
config;
|
|
60
|
+
identity;
|
|
61
|
+
status = {
|
|
62
|
+
value: "offline",
|
|
63
|
+
createTime: /* @__PURE__ */ new Date(),
|
|
64
|
+
lastMsgTime: null,
|
|
65
|
+
receivedMsg: 0,
|
|
66
|
+
sentMsg: 0,
|
|
67
|
+
offlineTimes: 0
|
|
68
|
+
};
|
|
69
|
+
selfId = "";
|
|
70
|
+
}
|
|
71
|
+
var adapter_default = Adapter;
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
Adapter
|
|
75
|
+
});
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type Adapter from './adapter';
|
|
3
|
+
import type { ChannelInfoResponse, GetFileDataResponse, GetFilePathResponse, GetFileUrlResponse, GroupInfoResponse, GuildInfoResponse, Message, SelfInfoResponse, SendMessageResponse, UploadFileResponse, UserInfoResponse } from '../types';
|
|
4
|
+
import type { EventsMapping } from 'fluoro';
|
|
5
|
+
import type { Session } from './session';
|
|
6
|
+
type ReverseList = {
|
|
7
|
+
[K in keyof EventsMapping]: Parameters<EventsMapping[K]>[0] extends Session ? K : never;
|
|
8
|
+
};
|
|
9
|
+
type SessionEvents = ReverseList[keyof ReverseList];
|
|
10
|
+
type Actions = Exclude<keyof Api, 'adapter' | 'getSupportedEvents' | 'getSupportedEvents'>;
|
|
11
|
+
/**
|
|
12
|
+
* Api which identify bot's standard platform apis.
|
|
13
|
+
*
|
|
14
|
+
* For different `api` child class, not most of them have implementation.
|
|
15
|
+
*
|
|
16
|
+
* @class
|
|
17
|
+
* @abstract
|
|
18
|
+
*/
|
|
19
|
+
export declare abstract class Api {
|
|
20
|
+
/**
|
|
21
|
+
* Get supported actions for current api implementation.
|
|
22
|
+
*
|
|
23
|
+
* @returns Supported actions
|
|
24
|
+
*/
|
|
25
|
+
getSupportedActions(): Actions[];
|
|
26
|
+
abstract getSupportedEvents(): SessionEvents[];
|
|
27
|
+
/**
|
|
28
|
+
* Current api's bot instance.
|
|
29
|
+
*
|
|
30
|
+
* @readonly
|
|
31
|
+
*/
|
|
32
|
+
readonly adapter: Adapter<any, any, any>;
|
|
33
|
+
/**
|
|
34
|
+
* Api class constructor.
|
|
35
|
+
*
|
|
36
|
+
* @param adapter - Current api's bot instance
|
|
37
|
+
*/
|
|
38
|
+
constructor(adapter: Adapter<any, any, any>);
|
|
39
|
+
/**
|
|
40
|
+
* Send a private message.
|
|
41
|
+
*
|
|
42
|
+
* @param message - Message content to send
|
|
43
|
+
* @param userId - Target user id
|
|
44
|
+
* @param meta - Extra meta data, optional
|
|
45
|
+
* @returns Message id and send time
|
|
46
|
+
*
|
|
47
|
+
* @async
|
|
48
|
+
*/
|
|
49
|
+
sendPrivateMsg(message: Message, userId: string, meta?: object): Promise<SendMessageResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* Send a group message.
|
|
52
|
+
*
|
|
53
|
+
* @param message - Message content to send
|
|
54
|
+
* @param groupId - Target group id
|
|
55
|
+
* @param meta - Extra meta data, optional
|
|
56
|
+
* @returns Message id and send time
|
|
57
|
+
*
|
|
58
|
+
* @async
|
|
59
|
+
*/
|
|
60
|
+
sendGroupMsg(message: Message, groupId: string, meta?: object): Promise<SendMessageResponse>;
|
|
61
|
+
/**
|
|
62
|
+
* Send a channel message.
|
|
63
|
+
*
|
|
64
|
+
* @param message - Message content to send
|
|
65
|
+
* @param guildId - Target guild id
|
|
66
|
+
* @param channelId - Target channel id
|
|
67
|
+
* @param meta - Extra meta data, optional
|
|
68
|
+
* @returns Message id and send time
|
|
69
|
+
*
|
|
70
|
+
* @async
|
|
71
|
+
*/
|
|
72
|
+
sendChannelMsg(message: Message, guildId: string, channelId: string, meta?: object): Promise<SendMessageResponse>;
|
|
73
|
+
/**
|
|
74
|
+
* Delete a message.
|
|
75
|
+
*
|
|
76
|
+
* Required target message that is sent by self or bot had manger permission.
|
|
77
|
+
*
|
|
78
|
+
* @param messageId - Target message id
|
|
79
|
+
* @param meta - Extra meta data, optional
|
|
80
|
+
*
|
|
81
|
+
* @async
|
|
82
|
+
*/
|
|
83
|
+
deleteMsg(messageId: string, meta?: object): void;
|
|
84
|
+
/**
|
|
85
|
+
* Get information about the bot itself.
|
|
86
|
+
*
|
|
87
|
+
* @returns Self info
|
|
88
|
+
*
|
|
89
|
+
* @async
|
|
90
|
+
*/
|
|
91
|
+
getSelfInfo(meta?: object): Promise<SelfInfoResponse>;
|
|
92
|
+
/**
|
|
93
|
+
* Get user information.
|
|
94
|
+
*
|
|
95
|
+
* @param userId - Target user id, can be the friend or the stronger
|
|
96
|
+
* @param meta - Extra meta data, optional
|
|
97
|
+
* @returns User info
|
|
98
|
+
*
|
|
99
|
+
* @async
|
|
100
|
+
*/
|
|
101
|
+
getUserInfo(userId: string, meta?: object): Promise<UserInfoResponse>;
|
|
102
|
+
/**
|
|
103
|
+
* Get friend list.
|
|
104
|
+
*
|
|
105
|
+
* @param meta - Extra meta data, optional
|
|
106
|
+
* @returns Friend list information
|
|
107
|
+
*
|
|
108
|
+
* @async
|
|
109
|
+
*/
|
|
110
|
+
getFriendList(meta?: object): Promise<UserInfoResponse[]>;
|
|
111
|
+
/**
|
|
112
|
+
* Get group information.
|
|
113
|
+
*
|
|
114
|
+
* @param groupId - Target group id
|
|
115
|
+
* @param meta - Extra meta data, optional
|
|
116
|
+
* @returns Group info
|
|
117
|
+
*
|
|
118
|
+
* @async
|
|
119
|
+
*/
|
|
120
|
+
getGroupInfo(groupId: string, meta?: object): Promise<GroupInfoResponse>;
|
|
121
|
+
/**
|
|
122
|
+
* Get group list.
|
|
123
|
+
*
|
|
124
|
+
* @param meta - Extra meta data, optional
|
|
125
|
+
* @returns Group list information
|
|
126
|
+
*
|
|
127
|
+
* @async
|
|
128
|
+
*/
|
|
129
|
+
getGroupList(meta?: object): Promise<GroupInfoResponse[]>;
|
|
130
|
+
/**
|
|
131
|
+
* Get group member information.
|
|
132
|
+
*
|
|
133
|
+
* @param groupId - Target group id
|
|
134
|
+
* @param userId - Target user id
|
|
135
|
+
* @param meta - Extra meta data, optional
|
|
136
|
+
* @returns Group member info
|
|
137
|
+
*
|
|
138
|
+
* @async
|
|
139
|
+
*/
|
|
140
|
+
getGroupMemberInfo(groupId: string, userId: string, meta?: object): Promise<SelfInfoResponse>;
|
|
141
|
+
/**
|
|
142
|
+
* Get group member list.
|
|
143
|
+
*
|
|
144
|
+
* @param groupId - Target group id
|
|
145
|
+
* @param meta - Extra meta data, optional
|
|
146
|
+
* @returns Group member list information
|
|
147
|
+
*
|
|
148
|
+
* @async
|
|
149
|
+
*/
|
|
150
|
+
getGroupMemberList(groupId: string, meta?: object): Promise<SelfInfoResponse[]>;
|
|
151
|
+
/**
|
|
152
|
+
* Set group information.
|
|
153
|
+
*
|
|
154
|
+
* @param groupId - Target group id
|
|
155
|
+
* @param groupName - Group name
|
|
156
|
+
* @param meta - Extra meta data, optional
|
|
157
|
+
*/
|
|
158
|
+
setGroupName(groupId: string, groupName: string, meta?: object): void;
|
|
159
|
+
/**
|
|
160
|
+
* Leave a group, if bot is owner so it will be destroy the group.
|
|
161
|
+
*
|
|
162
|
+
* @param groupId - Target group id
|
|
163
|
+
* @param meta - Extra meta data, optional
|
|
164
|
+
*/
|
|
165
|
+
leaveGroup(groupId: string, meta?: object): void;
|
|
166
|
+
/**
|
|
167
|
+
* Get guild information.
|
|
168
|
+
*
|
|
169
|
+
* @param guildId - Target guild id
|
|
170
|
+
* @param meta - Extra meta data, optional
|
|
171
|
+
* @returns Guild info
|
|
172
|
+
*
|
|
173
|
+
* @async
|
|
174
|
+
*/
|
|
175
|
+
getGuildInfo(guildId: string, meta?: object): Promise<GuildInfoResponse>;
|
|
176
|
+
/**
|
|
177
|
+
* Get guild list.
|
|
178
|
+
*
|
|
179
|
+
* @param meta - Extra meta data, optional
|
|
180
|
+
* @returns Guild list information
|
|
181
|
+
*
|
|
182
|
+
* @async
|
|
183
|
+
*/
|
|
184
|
+
getGuildList(meta?: object): Promise<GuildInfoResponse[]>;
|
|
185
|
+
/**
|
|
186
|
+
* Set guild information.
|
|
187
|
+
*
|
|
188
|
+
* @param guildId - Target guild id
|
|
189
|
+
* @param guildName - Guild name
|
|
190
|
+
* @param meta - Extra meta data, optional
|
|
191
|
+
*/
|
|
192
|
+
setGuildName(guildId: string, guildName: string, meta?: object): void;
|
|
193
|
+
/**
|
|
194
|
+
* Get guild member information.
|
|
195
|
+
*
|
|
196
|
+
* @param guildId - Target guild id
|
|
197
|
+
* @param channelId - Target channel id
|
|
198
|
+
* @param userId - Target user id
|
|
199
|
+
* @param meta - Extra meta data, optional
|
|
200
|
+
* @returns Guild member info
|
|
201
|
+
*
|
|
202
|
+
* @async
|
|
203
|
+
*/
|
|
204
|
+
getGuildMemberInfo(guildId: string, userId: string, meta?: object): Promise<UserInfoResponse>;
|
|
205
|
+
/**
|
|
206
|
+
* Get guild member list.
|
|
207
|
+
*
|
|
208
|
+
* @param guildId - Target guild id
|
|
209
|
+
* @param channelId - Target channel id
|
|
210
|
+
* @param meta - Extra meta data, optional
|
|
211
|
+
* @returns Guild member list information
|
|
212
|
+
*
|
|
213
|
+
* @async
|
|
214
|
+
*/
|
|
215
|
+
getGuildMemberList(guildId: string, meta?: object): Promise<UserInfoResponse[]>;
|
|
216
|
+
/**
|
|
217
|
+
* Leave a guild.
|
|
218
|
+
*
|
|
219
|
+
* @param guildId - Target guild id
|
|
220
|
+
* @param meta - Extra meta data, optional
|
|
221
|
+
*/
|
|
222
|
+
leaveGuild(guildId: string, meta?: object): void;
|
|
223
|
+
/**
|
|
224
|
+
* Get channel information.
|
|
225
|
+
*
|
|
226
|
+
* @param guildId - Target guild id
|
|
227
|
+
* @param channelId - Target channel id
|
|
228
|
+
* @param meta - Extra meta data, optional
|
|
229
|
+
* @returns Channel info
|
|
230
|
+
*
|
|
231
|
+
* @async
|
|
232
|
+
*/
|
|
233
|
+
getChannelInfo(guildId: string, channelId: string, meta?: object): Promise<ChannelInfoResponse>;
|
|
234
|
+
/**
|
|
235
|
+
* Get channel list.
|
|
236
|
+
*
|
|
237
|
+
* @param guildId - Target guild id
|
|
238
|
+
* @param joinedOnly - Whether to get joined channels only, default is false
|
|
239
|
+
* @param meta - Extra meta data, optional
|
|
240
|
+
* @returns Channel list information
|
|
241
|
+
*
|
|
242
|
+
* @async
|
|
243
|
+
*/
|
|
244
|
+
getChannelList(guildId: string, joinedOnly?: boolean, meta?: object): Promise<ChannelInfoResponse[]>;
|
|
245
|
+
/**
|
|
246
|
+
* Set channel information.
|
|
247
|
+
*
|
|
248
|
+
* @param guildId - Target guild id
|
|
249
|
+
* @param channelId - Target channel id
|
|
250
|
+
* @param channelName - Channel name
|
|
251
|
+
* @param meta - Extra meta data, optional
|
|
252
|
+
*/
|
|
253
|
+
setChannelName(guildId: string, channelId: string, channelName: string, meta?: object): void;
|
|
254
|
+
/**
|
|
255
|
+
* Get channel member information.
|
|
256
|
+
*
|
|
257
|
+
* @param guildId - Target guild id
|
|
258
|
+
* @param channelId - Target channel id
|
|
259
|
+
* @param userId - Target user id
|
|
260
|
+
* @param meta - Extra meta data, optional
|
|
261
|
+
* @returns Channel member info
|
|
262
|
+
*
|
|
263
|
+
* @async
|
|
264
|
+
*/
|
|
265
|
+
getChannelMemberInfo(guildId: string, channelId: string, userId: string, meta?: object): Promise<UserInfoResponse>;
|
|
266
|
+
/**
|
|
267
|
+
* Get channel member list.
|
|
268
|
+
*
|
|
269
|
+
* @param guildId - Target guild id
|
|
270
|
+
* @param channelId - Target channel id
|
|
271
|
+
* @param meta - Extra meta data, optional
|
|
272
|
+
* @returns Channel member list information
|
|
273
|
+
*
|
|
274
|
+
* @async
|
|
275
|
+
*/
|
|
276
|
+
getChannelMemberList(guildId: string, channelId: string, meta?: object): Promise<UserInfoResponse[]>;
|
|
277
|
+
/**
|
|
278
|
+
* Leave a channel.
|
|
279
|
+
*
|
|
280
|
+
* @param guildId - Target guild id
|
|
281
|
+
* @param channelId - Target channel id
|
|
282
|
+
* @param meta - Extra meta data, optional
|
|
283
|
+
*/
|
|
284
|
+
leaveChannel(guildId: string, channelId: string, meta?: object): void;
|
|
285
|
+
/**
|
|
286
|
+
* Upload file from url.
|
|
287
|
+
*
|
|
288
|
+
* @param name - File name
|
|
289
|
+
* @param url - File url
|
|
290
|
+
* @param headers - File download url headers, optional
|
|
291
|
+
* @param meta - Extra meta data, optional
|
|
292
|
+
* @returns File id
|
|
293
|
+
*
|
|
294
|
+
* @async
|
|
295
|
+
*/
|
|
296
|
+
uploadFileUrl(name: string, url: string, headers?: Record<string, string>, meta?: object): Promise<UploadFileResponse>;
|
|
297
|
+
/**
|
|
298
|
+
* Upload file from path.
|
|
299
|
+
*
|
|
300
|
+
* @param name - File name
|
|
301
|
+
* @param path - File path
|
|
302
|
+
* @param meta - Extra meta data, optional
|
|
303
|
+
* @returns File id
|
|
304
|
+
*
|
|
305
|
+
* @async
|
|
306
|
+
*/
|
|
307
|
+
uploadFilePath(name: string, path: string, meta?: object): Promise<UploadFileResponse>;
|
|
308
|
+
/**
|
|
309
|
+
* Upload file from data.
|
|
310
|
+
*
|
|
311
|
+
* @param name - File name
|
|
312
|
+
* @param data - File data
|
|
313
|
+
* @param meta - Extra meta data, optional
|
|
314
|
+
* @returns File id
|
|
315
|
+
*
|
|
316
|
+
* @async
|
|
317
|
+
*/
|
|
318
|
+
uploadFileData(name: string, data: Buffer, meta?: object): Promise<UploadFileResponse>;
|
|
319
|
+
/**
|
|
320
|
+
* Get file url.
|
|
321
|
+
*
|
|
322
|
+
* @param filedId - File id
|
|
323
|
+
* @param meta - Extra meta data, optional
|
|
324
|
+
* @returns File url data
|
|
325
|
+
*
|
|
326
|
+
* @async
|
|
327
|
+
*/
|
|
328
|
+
getFileUrl(filedId: string, meta?: object): Promise<GetFileUrlResponse>;
|
|
329
|
+
/**
|
|
330
|
+
* Get file path.
|
|
331
|
+
*
|
|
332
|
+
* @param filedId - File id
|
|
333
|
+
* @param meta - Extra meta data, optional
|
|
334
|
+
* @returns File path data
|
|
335
|
+
*
|
|
336
|
+
* @async
|
|
337
|
+
*/
|
|
338
|
+
getFilePath(filedId: string, meta?: object): Promise<GetFilePathResponse>;
|
|
339
|
+
/**
|
|
340
|
+
* Get file data.
|
|
341
|
+
*
|
|
342
|
+
* @param filedId - File id
|
|
343
|
+
* @param meta - Extra meta data, optional
|
|
344
|
+
* @returns File data
|
|
345
|
+
*
|
|
346
|
+
* @async
|
|
347
|
+
*/
|
|
348
|
+
getFileData(filedId: string, meta?: object): Promise<GetFileDataResponse>;
|
|
349
|
+
/**
|
|
350
|
+
* Set group avatar.
|
|
351
|
+
*
|
|
352
|
+
* @param groupId - Target group id
|
|
353
|
+
* @param groupName - Group name
|
|
354
|
+
* @param meta - Extra meta data, optional
|
|
355
|
+
*
|
|
356
|
+
* @experimental
|
|
357
|
+
*/
|
|
358
|
+
setGroupAvatar(groupId: string, image: string, meta?: object): void;
|
|
359
|
+
/**
|
|
360
|
+
* Set group admin.
|
|
361
|
+
*
|
|
362
|
+
* @param groupId - Target group id
|
|
363
|
+
* @param groupName - Group name
|
|
364
|
+
* @param meta - Extra meta data, optional
|
|
365
|
+
*
|
|
366
|
+
* @experimental
|
|
367
|
+
*/
|
|
368
|
+
setGroupAdmin(groupId: string, userId: string, enable: boolean, meta?: object): void;
|
|
369
|
+
/**
|
|
370
|
+
* Set group card.
|
|
371
|
+
*
|
|
372
|
+
* @param groupId - Target group id
|
|
373
|
+
* @param groupName - Group name
|
|
374
|
+
* @param meta - Extra meta data, optional
|
|
375
|
+
*
|
|
376
|
+
* @experimental
|
|
377
|
+
*/
|
|
378
|
+
setGroupCard(groupId: string, userId: string, card: string, meta?: object): void;
|
|
379
|
+
/**
|
|
380
|
+
* Set group members ban or unban.
|
|
381
|
+
*
|
|
382
|
+
* @param groupId - Target group id
|
|
383
|
+
* @param groupName - Group name
|
|
384
|
+
* @param meta - Extra meta data, optional
|
|
385
|
+
*
|
|
386
|
+
* @experimental
|
|
387
|
+
*/
|
|
388
|
+
setGroupBan(groupId: string, userId: string, time: number, meta?: object): void;
|
|
389
|
+
/**
|
|
390
|
+
* Set group new notice.
|
|
391
|
+
*
|
|
392
|
+
* @param groupId - Target group id
|
|
393
|
+
* @param groupName - Group name
|
|
394
|
+
* @param meta - Extra meta data, optional
|
|
395
|
+
*
|
|
396
|
+
* @experimental
|
|
397
|
+
*/
|
|
398
|
+
sendGroupNotice(groupId: string, content: string, image?: string, meta?: object): void;
|
|
399
|
+
/**
|
|
400
|
+
* Set group whole ban
|
|
401
|
+
*
|
|
402
|
+
* @param groupId - Target group id
|
|
403
|
+
* @param enable - Whether to ban
|
|
404
|
+
*/
|
|
405
|
+
setGroupWholeBan(groupId: string, enable?: boolean): void;
|
|
406
|
+
/**
|
|
407
|
+
* Set group members kicked.
|
|
408
|
+
*
|
|
409
|
+
* @param groupId - Target group id
|
|
410
|
+
* @param groupName - Group name
|
|
411
|
+
* @param meta - Extra meta data, optional
|
|
412
|
+
*
|
|
413
|
+
* @experimental
|
|
414
|
+
*/
|
|
415
|
+
setGroupKick(groupId: string, userId: string, meta?: object): void;
|
|
416
|
+
}
|
|
417
|
+
export default Api;
|