@kotori-bot/core 1.1.0 → 1.3.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 +17 -0
- package/lib/components/config.d.ts +16 -0
- package/lib/components/config.js +39 -0
- package/lib/components/core.d.ts +31 -0
- package/lib/components/core.js +30 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +17 -0
- package/lib/components/message.d.ts +25 -0
- package/lib/components/message.js +135 -0
- package/lib/components/modules.d.ts +12 -0
- package/lib/components/modules.js +127 -0
- package/lib/consts.d.ts +12 -8
- package/lib/consts.js +14 -8
- package/lib/context/context.d.ts +35 -0
- package/lib/context/context.js +111 -0
- package/lib/context/events.d.ts +18 -0
- package/lib/context/index.d.ts +5 -0
- package/lib/context/index.js +21 -0
- package/lib/context/modules.d.ts +39 -0
- package/lib/context/modules.js +65 -0
- package/lib/context/service.d.ts +16 -0
- package/lib/context/service.js +22 -0
- package/lib/context/symbols.d.ts +12 -0
- package/lib/context/symbols.js +18 -0
- package/lib/context/test.d.ts +6 -0
- package/lib/context/test.js +12 -0
- package/lib/index.d.ts +6 -11
- package/lib/index.js +13 -21
- package/lib/service/adapter.d.ts +44 -0
- package/lib/service/adapter.js +165 -0
- package/lib/service/api.d.ts +32 -0
- package/lib/{components → service}/api.js +12 -14
- package/lib/service/cache.d.ts +13 -0
- package/lib/service/cache.js +34 -0
- package/lib/service/elements.d.ts +12 -0
- package/lib/service/elements.js +39 -0
- package/lib/service/index.d.ts +4 -0
- package/lib/service/index.js +20 -0
- package/lib/service/service.d.ts +16 -0
- package/lib/service/service.js +22 -0
- package/lib/types/adapter.d.ts +22 -0
- package/lib/types/adapter.js +2 -0
- package/lib/types/config.d.ts +22 -0
- package/lib/types/config.js +2 -0
- package/lib/types/core.d.ts +7 -0
- package/lib/types/core.js +2 -0
- package/lib/types/index.d.ts +3 -0
- package/lib/types/index.js +19 -0
- package/lib/types/message.d.ts +228 -0
- package/lib/types/message.js +17 -0
- package/lib/types/modules.d.ts +39 -0
- package/lib/types/modules.js +2 -0
- package/lib/types/service.d.ts +23 -0
- package/lib/types/service.js +2 -0
- package/lib/utils/command.d.ts +43 -0
- package/lib/utils/command.js +212 -0
- package/lib/utils/commandError.d.ts +7 -0
- package/lib/utils/commandError.js +13 -0
- package/lib/utils/container.d.ts +9 -0
- package/lib/utils/container.js +21 -0
- package/lib/utils/errror.d.ts +5 -21
- package/lib/utils/errror.js +9 -14
- package/lib/utils/factory.d.ts +7 -0
- package/lib/utils/factory.js +25 -0
- package/package.json +10 -7
- package/lib/base/command.d.ts +0 -20
- package/lib/base/command.js +0 -217
- package/lib/base/core.d.ts +0 -30
- package/lib/base/core.js +0 -52
- package/lib/base/events.d.ts +0 -13
- package/lib/base/events.js +0 -41
- package/lib/base/filter.d.ts +0 -1
- package/lib/base/internal.d.ts +0 -34
- package/lib/base/internal.js +0 -89
- package/lib/base/message.d.ts +0 -18
- package/lib/base/message.js +0 -177
- package/lib/base/modules.d.ts +0 -15
- package/lib/base/modules.js +0 -205
- package/lib/components/adapter.d.ts +0 -38
- package/lib/components/adapter.js +0 -128
- package/lib/components/api.d.ts +0 -35
- package/lib/components/elements.d.ts +0 -12
- package/lib/components/elements.js +0 -28
- package/lib/components/service.d.ts +0 -13
- package/lib/components/service.js +0 -7
- package/lib/context.d.ts +0 -13
- package/lib/context.js +0 -35
- package/lib/types.d.ts +0 -417
- package/lib/types.js +0 -81
- package/lib/utils/commandExtra.d.ts +0 -6
- package/lib/utils/commandExtra.js +0 -11
- package/lib/utils/i18n.d.ts +0 -13
- package/lib/utils/i18n.js +0 -65
- /package/lib/{base/filter.js → context/events.js} +0 -0
package/lib/types.d.ts
DELETED
|
@@ -1,417 +0,0 @@
|
|
|
1
|
-
import type { StringTempArgs, obj } from '@kotori-bot/tools';
|
|
2
|
-
import Tsu from 'tsukiko';
|
|
3
|
-
import { LocaleType } from '@kotori-bot/i18n';
|
|
4
|
-
import type Api from './components/api';
|
|
5
|
-
import type Adapter from './components/adapter';
|
|
6
|
-
import type Context from './context';
|
|
7
|
-
import type Elements from './components/elements';
|
|
8
|
-
export declare const baseDirSchema: import("tsukiko").ObjectParser<{
|
|
9
|
-
root: import("tsukiko").StringParser;
|
|
10
|
-
modules: import("tsukiko").StringParser;
|
|
11
|
-
}>;
|
|
12
|
-
export type BaseDir = Tsu.infer<typeof baseDirSchema>;
|
|
13
|
-
export declare const packageInfoSchema: import("tsukiko").ObjectParser<{
|
|
14
|
-
name: import("tsukiko").StringParser;
|
|
15
|
-
version: import("tsukiko").StringParser;
|
|
16
|
-
description: import("tsukiko").StringParser;
|
|
17
|
-
main: import("tsukiko").StringParser;
|
|
18
|
-
license: import("tsukiko").LiteralParser<"GPL-3.0">;
|
|
19
|
-
author: import("tsukiko").StringParser;
|
|
20
|
-
}>;
|
|
21
|
-
export type PackageInfo = Tsu.infer<typeof packageInfoSchema>;
|
|
22
|
-
export declare const localeTypeSchema: import("tsukiko").UnionParser<[import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"en_US">, import("tsukiko").LiteralParser<"ja_JP">]>, import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"zh_CN">, import("tsukiko").LiteralParser<"zh_TW">]>]>;
|
|
23
|
-
export declare const globalOptions: import("tsukiko").ObjectParser<{
|
|
24
|
-
env: import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"dev">, import("tsukiko").LiteralParser<"build">]>;
|
|
25
|
-
}>;
|
|
26
|
-
export type GlobalOptions = Tsu.infer<typeof globalOptions>;
|
|
27
|
-
declare const adapterConfigBaseSchema: import("tsukiko").IntersectionParser<[import("tsukiko").ObjectParser<{
|
|
28
|
-
extends: import("tsukiko").StringParser;
|
|
29
|
-
master: import("tsukiko").UnionParser<[import("tsukiko").NumberParser, import("tsukiko").StringParser]>;
|
|
30
|
-
}>, import("tsukiko").ObjectParser<{
|
|
31
|
-
lang: import("tsukiko").UnionParser<[import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"en_US">, import("tsukiko").LiteralParser<"ja_JP">]>, import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"zh_CN">, import("tsukiko").LiteralParser<"zh_TW">]>]>;
|
|
32
|
-
'command-prefix': import("tsukiko").StringParser;
|
|
33
|
-
}>]>;
|
|
34
|
-
export declare const globalConfigSchemaController: (lang?: LocaleType, commandPrefix?: string) => import("tsukiko").ObjectParser<{
|
|
35
|
-
global: import("tsukiko").IntersectionParser<[import("tsukiko").ObjectParser<{
|
|
36
|
-
dirs: import("tsukiko").ArrayParser<import("tsukiko").StringParser>;
|
|
37
|
-
}>, import("tsukiko").ObjectParser<{
|
|
38
|
-
lang: import("tsukiko").UnionParser<[import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"en_US">, import("tsukiko").LiteralParser<"ja_JP">]>, import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"zh_CN">, import("tsukiko").LiteralParser<"zh_TW">]>]>;
|
|
39
|
-
'command-prefix': import("tsukiko").StringParser;
|
|
40
|
-
}>]>;
|
|
41
|
-
adapter: import("tsukiko").Parser<import("tsukiko").IndexObject<import("tsukiko").ObjectParserInfer<{
|
|
42
|
-
extends: import("tsukiko").StringParser;
|
|
43
|
-
master: import("tsukiko").UnionParser<[import("tsukiko").NumberParser, import("tsukiko").StringParser]>;
|
|
44
|
-
}> & import("tsukiko").ObjectParserInfer<{
|
|
45
|
-
lang: import("tsukiko").UnionParser<[import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"en_US">, import("tsukiko").LiteralParser<"ja_JP">]>, import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"zh_CN">, import("tsukiko").LiteralParser<"zh_TW">]>]>;
|
|
46
|
-
'command-prefix': import("tsukiko").StringParser;
|
|
47
|
-
}>>>;
|
|
48
|
-
plugin: import("tsukiko").Parser<import("tsukiko").IndexObject<import("tsukiko").ObjectParserInfer<{
|
|
49
|
-
priority: import("tsukiko").NumberParser;
|
|
50
|
-
}>>>;
|
|
51
|
-
}>;
|
|
52
|
-
declare const globalConfigSchema: import("tsukiko").ObjectParser<{
|
|
53
|
-
global: import("tsukiko").IntersectionParser<[import("tsukiko").ObjectParser<{
|
|
54
|
-
dirs: import("tsukiko").ArrayParser<import("tsukiko").StringParser>;
|
|
55
|
-
}>, import("tsukiko").ObjectParser<{
|
|
56
|
-
lang: import("tsukiko").UnionParser<[import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"en_US">, import("tsukiko").LiteralParser<"ja_JP">]>, import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"zh_CN">, import("tsukiko").LiteralParser<"zh_TW">]>]>;
|
|
57
|
-
'command-prefix': import("tsukiko").StringParser;
|
|
58
|
-
}>]>;
|
|
59
|
-
adapter: import("tsukiko").Parser<import("tsukiko").IndexObject<import("tsukiko").ObjectParserInfer<{
|
|
60
|
-
extends: import("tsukiko").StringParser;
|
|
61
|
-
master: import("tsukiko").UnionParser<[import("tsukiko").NumberParser, import("tsukiko").StringParser]>;
|
|
62
|
-
}> & import("tsukiko").ObjectParserInfer<{
|
|
63
|
-
lang: import("tsukiko").UnionParser<[import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"en_US">, import("tsukiko").LiteralParser<"ja_JP">]>, import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"zh_CN">, import("tsukiko").LiteralParser<"zh_TW">]>]>;
|
|
64
|
-
'command-prefix': import("tsukiko").StringParser;
|
|
65
|
-
}>>>;
|
|
66
|
-
plugin: import("tsukiko").Parser<import("tsukiko").IndexObject<import("tsukiko").ObjectParserInfer<{
|
|
67
|
-
priority: import("tsukiko").NumberParser;
|
|
68
|
-
}>>>;
|
|
69
|
-
}>;
|
|
70
|
-
export type GlobalConfig = Tsu.infer<typeof globalConfigSchema>;
|
|
71
|
-
export type AdapterConfig = Tsu.infer<typeof adapterConfigBaseSchema>;
|
|
72
|
-
export type AdapterConstructor = new (ctx: Context, config: AdapterConfig, identity: string) => Adapter;
|
|
73
|
-
export type ApiConstructor<T extends Api> = new (adapter: Adapter, el: Elements) => T;
|
|
74
|
-
export type ElementsParam = {
|
|
75
|
-
[K in Exclude<keyof Elements, 'supports'>]?: (...args: unknown[]) => string;
|
|
76
|
-
};
|
|
77
|
-
export declare const kotoriConfigSchema: import("tsukiko").ObjectParser<{
|
|
78
|
-
baseDir: import("tsukiko").ObjectParser<{
|
|
79
|
-
root: import("tsukiko").StringParser;
|
|
80
|
-
modules: import("tsukiko").StringParser;
|
|
81
|
-
}>;
|
|
82
|
-
config: import("tsukiko").ObjectParser<{
|
|
83
|
-
global: import("tsukiko").IntersectionParser<[import("tsukiko").ObjectParser<{
|
|
84
|
-
dirs: import("tsukiko").ArrayParser<import("tsukiko").StringParser>;
|
|
85
|
-
}>, import("tsukiko").ObjectParser<{
|
|
86
|
-
lang: import("tsukiko").UnionParser<[import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"en_US">, import("tsukiko").LiteralParser<"ja_JP">]>, import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"zh_CN">, import("tsukiko").LiteralParser<"zh_TW">]>]>;
|
|
87
|
-
'command-prefix': import("tsukiko").StringParser;
|
|
88
|
-
}>]>;
|
|
89
|
-
adapter: import("tsukiko").Parser<import("tsukiko").IndexObject<import("tsukiko").ObjectParserInfer<{
|
|
90
|
-
extends: import("tsukiko").StringParser;
|
|
91
|
-
master: import("tsukiko").UnionParser<[import("tsukiko").NumberParser, import("tsukiko").StringParser]>;
|
|
92
|
-
}> & import("tsukiko").ObjectParserInfer<{
|
|
93
|
-
lang: import("tsukiko").UnionParser<[import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"en_US">, import("tsukiko").LiteralParser<"ja_JP">]>, import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"zh_CN">, import("tsukiko").LiteralParser<"zh_TW">]>]>;
|
|
94
|
-
'command-prefix': import("tsukiko").StringParser;
|
|
95
|
-
}>>>;
|
|
96
|
-
plugin: import("tsukiko").Parser<import("tsukiko").IndexObject<import("tsukiko").ObjectParserInfer<{
|
|
97
|
-
priority: import("tsukiko").NumberParser;
|
|
98
|
-
}>>>;
|
|
99
|
-
}>;
|
|
100
|
-
options: import("tsukiko").ObjectParser<{
|
|
101
|
-
env: import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"dev">, import("tsukiko").LiteralParser<"build">]>;
|
|
102
|
-
}>;
|
|
103
|
-
}>;
|
|
104
|
-
export type KotoriConfig = Tsu.infer<typeof kotoriConfigSchema>;
|
|
105
|
-
export interface ApiExtra {
|
|
106
|
-
default: {
|
|
107
|
-
type: 'default';
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
export declare const enum CommandAccess {
|
|
111
|
-
MEMBER = 0,
|
|
112
|
-
MANGER = 1,
|
|
113
|
-
ADMIN = 2
|
|
114
|
-
}
|
|
115
|
-
export type CommandAction = (data: {
|
|
116
|
-
args: CommandArgType[];
|
|
117
|
-
options: obj<CommandArgType>;
|
|
118
|
-
}, session: EventType['group_msg' | 'private_msg']) => MessageQuick | CommandResultExtra[keyof CommandResultExtra] | void | Promise<MessageQuick | CommandResultExtra[keyof CommandResultExtra] | void>;
|
|
119
|
-
export type CommandArgType = string | number;
|
|
120
|
-
export type CommandArgTypeSign = 'string' | 'number';
|
|
121
|
-
export interface CommandConfig {
|
|
122
|
-
alias?: string[];
|
|
123
|
-
scope?: MessageScope | 'all';
|
|
124
|
-
access?: CommandAccess;
|
|
125
|
-
help?: string;
|
|
126
|
-
action?: CommandAction;
|
|
127
|
-
}
|
|
128
|
-
export interface CommandArg {
|
|
129
|
-
name: string;
|
|
130
|
-
type: CommandArgTypeSign;
|
|
131
|
-
optional: boolean;
|
|
132
|
-
default?: CommandArgType;
|
|
133
|
-
rest: boolean;
|
|
134
|
-
}
|
|
135
|
-
export interface CommandOption {
|
|
136
|
-
name: string;
|
|
137
|
-
type: CommandArgTypeSign;
|
|
138
|
-
default?: CommandArgType;
|
|
139
|
-
realname: string;
|
|
140
|
-
description?: string;
|
|
141
|
-
}
|
|
142
|
-
export interface CommandData {
|
|
143
|
-
root: string;
|
|
144
|
-
alias: string[];
|
|
145
|
-
args: CommandArg[];
|
|
146
|
-
options: CommandOption[];
|
|
147
|
-
scope: CommandConfig['scope'];
|
|
148
|
-
access: CommandAccess;
|
|
149
|
-
help?: string;
|
|
150
|
-
action?: CommandAction;
|
|
151
|
-
description?: string;
|
|
152
|
-
}
|
|
153
|
-
export interface CommandParseResult {
|
|
154
|
-
parsed: {
|
|
155
|
-
action: CommandAction;
|
|
156
|
-
args: CommandArgType[];
|
|
157
|
-
options: obj<CommandArgType>;
|
|
158
|
-
};
|
|
159
|
-
option_error: {
|
|
160
|
-
expected: string;
|
|
161
|
-
reality: string;
|
|
162
|
-
target: string;
|
|
163
|
-
};
|
|
164
|
-
arg_many: {
|
|
165
|
-
expected: number;
|
|
166
|
-
reality: number;
|
|
167
|
-
};
|
|
168
|
-
arg_few: CommandParseResult['arg_many'];
|
|
169
|
-
arg_error: CommandParseResult['option_error'];
|
|
170
|
-
syntax: {
|
|
171
|
-
index: number;
|
|
172
|
-
char: string;
|
|
173
|
-
};
|
|
174
|
-
unknown: {
|
|
175
|
-
input: string;
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
export interface CommandResult extends CommandParseResult {
|
|
179
|
-
success: {
|
|
180
|
-
return?: string;
|
|
181
|
-
};
|
|
182
|
-
error: {
|
|
183
|
-
error: unknown;
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
export type CommandParseResultExtra = Pick<CommandResultExtra, keyof CommandParseResult>;
|
|
187
|
-
export type CommandExecuteResultExtra = Pick<CommandResultExtra, Exclude<keyof CommandResult, keyof CommandParseResult>>;
|
|
188
|
-
export type CommandResultExtra = {
|
|
189
|
-
[K in keyof CommandResult]: {
|
|
190
|
-
type: K;
|
|
191
|
-
} & CommandResult[K];
|
|
192
|
-
};
|
|
193
|
-
export type MessageRaw = string;
|
|
194
|
-
export type MessageScope = 'private' | 'group';
|
|
195
|
-
export type MessageQuickFunc = (msg: MessageQuick) => void;
|
|
196
|
-
export type MessageQuickReal = MessageRaw | [string, StringTempArgs] | void;
|
|
197
|
-
export type MessageQuick = MessageQuickReal | Promise<MessageQuickReal>;
|
|
198
|
-
export type ModuleType = 'database' | 'adapter' | 'plugin';
|
|
199
|
-
export type ModuleInstanceType = 'constructor' | 'function' | 'none';
|
|
200
|
-
export type ModuleInstanceConstructor = new (ctx: Context, config: object) => unknown;
|
|
201
|
-
export type ModuleInstanceFunction = (ctx: Context, config: object) => unknown;
|
|
202
|
-
export type MidwareCallback = (next: () => void, session: EventDataMsg) => MessageQuick;
|
|
203
|
-
export type RegexpCallback = (match: RegExpMatchArray, session: EventDataMsg) => MessageQuick;
|
|
204
|
-
export interface MidwareStack {
|
|
205
|
-
extend: string;
|
|
206
|
-
callback: MidwareCallback;
|
|
207
|
-
priority: number;
|
|
208
|
-
}
|
|
209
|
-
export interface CommandStack {
|
|
210
|
-
extend: string;
|
|
211
|
-
data: CommandData;
|
|
212
|
-
}
|
|
213
|
-
export interface RegexpStack {
|
|
214
|
-
extend: string;
|
|
215
|
-
match: RegExp;
|
|
216
|
-
callback: RegexpCallback;
|
|
217
|
-
}
|
|
218
|
-
export declare const ModulePackageSchema: import("tsukiko").ObjectParser<{
|
|
219
|
-
name: import("tsukiko").StringParser;
|
|
220
|
-
version: import("tsukiko").StringParser;
|
|
221
|
-
description: import("tsukiko").StringParser;
|
|
222
|
-
main: import("tsukiko").StringParser;
|
|
223
|
-
license: import("tsukiko").LiteralParser<"GPL-3.0">;
|
|
224
|
-
author: import("tsukiko").UnionParser<[import("tsukiko").StringParser, import("tsukiko").ArrayParser<import("tsukiko").StringParser>]>;
|
|
225
|
-
peerDependencies: import("tsukiko").ObjectParser<{
|
|
226
|
-
'kotori-bot': import("tsukiko").StringParser;
|
|
227
|
-
}>;
|
|
228
|
-
}>;
|
|
229
|
-
export type ModulePackage = Tsu.infer<typeof ModulePackageSchema>;
|
|
230
|
-
export interface ModuleData {
|
|
231
|
-
package: ModulePackage;
|
|
232
|
-
fileList: string[];
|
|
233
|
-
mainPath: string;
|
|
234
|
-
}
|
|
235
|
-
export interface EventDataBase<T extends keyof EventType> {
|
|
236
|
-
type: T;
|
|
237
|
-
}
|
|
238
|
-
interface EventDataLoadModule extends EventDataBase<'load_module'> {
|
|
239
|
-
module: ModuleData | null;
|
|
240
|
-
moduleType: ModuleType;
|
|
241
|
-
instanceType: ModuleInstanceType;
|
|
242
|
-
}
|
|
243
|
-
interface EventDataLoadAllModule extends EventDataBase<'load_all_module'> {
|
|
244
|
-
reality: number;
|
|
245
|
-
expected: number;
|
|
246
|
-
}
|
|
247
|
-
interface EventDataUnloadModule extends EventDataBase<'unload_module'> {
|
|
248
|
-
module: ModuleData | null;
|
|
249
|
-
}
|
|
250
|
-
type EventDataMsgSenderSex = 'male' | 'female' | 'unknown';
|
|
251
|
-
type EventDataOperation = 'set' | 'unset';
|
|
252
|
-
export interface EventDataMsgSender {
|
|
253
|
-
nickname: string;
|
|
254
|
-
sex: EventDataMsgSenderSex;
|
|
255
|
-
age: number;
|
|
256
|
-
}
|
|
257
|
-
export interface EventDataAdapterBase<T extends keyof EventType> extends EventDataBase<T> {
|
|
258
|
-
adapter: Adapter;
|
|
259
|
-
}
|
|
260
|
-
interface EventDataConnect extends EventDataAdapterBase<'connect'> {
|
|
261
|
-
normal: boolean;
|
|
262
|
-
info: string;
|
|
263
|
-
onlyStart?: boolean;
|
|
264
|
-
}
|
|
265
|
-
interface EventDataDisconnect extends EventDataAdapterBase<'disconnect'> {
|
|
266
|
-
normal: boolean;
|
|
267
|
-
info: string;
|
|
268
|
-
}
|
|
269
|
-
interface EventDataReady extends EventDataAdapterBase<'ready'> {
|
|
270
|
-
}
|
|
271
|
-
interface EventDataOnline extends EventDataAdapterBase<'online'> {
|
|
272
|
-
}
|
|
273
|
-
interface EventDataOffline extends EventDataAdapterBase<'offline'> {
|
|
274
|
-
}
|
|
275
|
-
export type EventDataMsg = EventDataPrivateMsg | EventDataGroupMsg;
|
|
276
|
-
interface EventDataMidwares extends EventDataBase<'midwares'> {
|
|
277
|
-
isPass: boolean;
|
|
278
|
-
event: EventDataMsg;
|
|
279
|
-
}
|
|
280
|
-
interface EventDataBeforeParse extends EventDataBase<'before_parse'> {
|
|
281
|
-
event: EventDataMsg;
|
|
282
|
-
command: string;
|
|
283
|
-
}
|
|
284
|
-
interface EventDataParse extends EventDataBase<'parse'> {
|
|
285
|
-
event: EventDataMsg;
|
|
286
|
-
command: string;
|
|
287
|
-
result: CommandParseResultExtra[keyof CommandParseResultExtra];
|
|
288
|
-
cancel(): void;
|
|
289
|
-
}
|
|
290
|
-
interface EventDataBeforeCommand extends EventDataBase<'before_command'> {
|
|
291
|
-
event: EventDataMsg;
|
|
292
|
-
command: string;
|
|
293
|
-
scope: MessageScope;
|
|
294
|
-
access: CommandAccess;
|
|
295
|
-
cancel(): void;
|
|
296
|
-
}
|
|
297
|
-
interface EventDataCommand extends EventDataBase<'command'> {
|
|
298
|
-
event: EventDataMsg;
|
|
299
|
-
command: string;
|
|
300
|
-
scope: MessageScope;
|
|
301
|
-
access: CommandAccess;
|
|
302
|
-
result: CommandResultExtra[keyof CommandResultExtra];
|
|
303
|
-
}
|
|
304
|
-
export declare const eventDataTargetIdSchema: import("tsukiko").UnionParser<[import("tsukiko").StringParser, import("tsukiko").NumberParser]>;
|
|
305
|
-
export type EventDataTargetId = Tsu.infer<typeof eventDataTargetIdSchema>;
|
|
306
|
-
interface EventDataBeforeSend extends EventDataBase<'before_send'> {
|
|
307
|
-
api: Api;
|
|
308
|
-
message: MessageRaw;
|
|
309
|
-
messageType: MessageScope;
|
|
310
|
-
targetId: EventDataTargetId;
|
|
311
|
-
cancel(): void;
|
|
312
|
-
}
|
|
313
|
-
interface EventDataSend extends EventDataBase<'send'> {
|
|
314
|
-
api: Api;
|
|
315
|
-
messageId: EventDataTargetId;
|
|
316
|
-
}
|
|
317
|
-
export interface EventDataApiBase<T extends keyof EventType, M extends MessageScope = MessageScope> extends EventDataBase<T> {
|
|
318
|
-
api: Api;
|
|
319
|
-
el: Elements;
|
|
320
|
-
userId: EventDataTargetId;
|
|
321
|
-
messageType: M;
|
|
322
|
-
send(message: MessageRaw): void;
|
|
323
|
-
locale(val: string): string;
|
|
324
|
-
quick(message: MessageQuick): void;
|
|
325
|
-
error<T extends keyof CommandResult>(type: T, data?: Omit<CommandResultExtra[T], 'type'>): CommandResultExtra[T];
|
|
326
|
-
extra?: unknown;
|
|
327
|
-
}
|
|
328
|
-
interface EventDataPrivateMsg extends EventDataApiBase<'private_msg', 'private'> {
|
|
329
|
-
messageId: EventDataTargetId;
|
|
330
|
-
message: MessageRaw;
|
|
331
|
-
sender: EventDataMsgSender;
|
|
332
|
-
groupId?: EventDataTargetId;
|
|
333
|
-
}
|
|
334
|
-
interface EventDataGroupMsg extends EventDataApiBase<'group_msg', 'group'> {
|
|
335
|
-
messageId: EventDataTargetId;
|
|
336
|
-
message: MessageRaw;
|
|
337
|
-
sender: EventDataMsgSender;
|
|
338
|
-
groupId: EventDataTargetId;
|
|
339
|
-
}
|
|
340
|
-
interface EventDataPrivateRecall extends EventDataApiBase<'private_recall', 'private'> {
|
|
341
|
-
messageId: EventDataTargetId;
|
|
342
|
-
}
|
|
343
|
-
interface EventDataGroupRecall extends EventDataApiBase<'group_recall', 'group'> {
|
|
344
|
-
messageId: EventDataTargetId;
|
|
345
|
-
operatorId: EventDataTargetId;
|
|
346
|
-
groupId: EventDataTargetId;
|
|
347
|
-
}
|
|
348
|
-
interface EventDataPrivateRequest extends EventDataApiBase<'private_request', 'private'> {
|
|
349
|
-
userId: EventDataTargetId;
|
|
350
|
-
}
|
|
351
|
-
interface EventDataGroupRequest extends EventDataApiBase<'group_request', 'group'> {
|
|
352
|
-
userId: EventDataTargetId;
|
|
353
|
-
operatorId: EventDataTargetId;
|
|
354
|
-
groupId: EventDataTargetId;
|
|
355
|
-
}
|
|
356
|
-
interface EventDataPrivateAdd extends EventDataApiBase<'private_add', 'private'> {
|
|
357
|
-
userId: EventDataTargetId;
|
|
358
|
-
}
|
|
359
|
-
interface EventDataGroupIncrease extends EventDataApiBase<'group_increase', 'group'> {
|
|
360
|
-
userId: EventDataTargetId;
|
|
361
|
-
operatorId: EventDataTargetId;
|
|
362
|
-
groupId: EventDataTargetId;
|
|
363
|
-
}
|
|
364
|
-
interface EventDataGroupDecrease extends EventDataApiBase<'group_decrease', 'group'> {
|
|
365
|
-
userId: EventDataTargetId;
|
|
366
|
-
operatorId: EventDataTargetId;
|
|
367
|
-
groupId: EventDataTargetId;
|
|
368
|
-
}
|
|
369
|
-
interface EventDataGroupAdmin extends EventDataApiBase<'group_admin', 'group'> {
|
|
370
|
-
userId: EventDataTargetId;
|
|
371
|
-
operation: EventDataOperation;
|
|
372
|
-
groupId: EventDataTargetId;
|
|
373
|
-
}
|
|
374
|
-
interface EventDataGroupBan extends EventDataApiBase<'group_ban', 'group'> {
|
|
375
|
-
userId: EventDataTargetId | 0;
|
|
376
|
-
operatorId?: EventDataTargetId;
|
|
377
|
-
time?: number | -1;
|
|
378
|
-
groupId: EventDataTargetId;
|
|
379
|
-
}
|
|
380
|
-
export interface EventType {
|
|
381
|
-
load_module: EventDataLoadModule;
|
|
382
|
-
load_all_module: EventDataLoadAllModule;
|
|
383
|
-
unload_module: EventDataUnloadModule;
|
|
384
|
-
connect: EventDataConnect;
|
|
385
|
-
disconnect: EventDataDisconnect;
|
|
386
|
-
ready: EventDataReady;
|
|
387
|
-
online: EventDataOnline;
|
|
388
|
-
offline: EventDataOffline;
|
|
389
|
-
midwares: EventDataMidwares;
|
|
390
|
-
before_parse: EventDataBeforeParse;
|
|
391
|
-
parse: EventDataParse;
|
|
392
|
-
before_command: EventDataBeforeCommand;
|
|
393
|
-
command: EventDataCommand;
|
|
394
|
-
before_send: EventDataBeforeSend;
|
|
395
|
-
send: EventDataSend;
|
|
396
|
-
private_msg: EventDataPrivateMsg;
|
|
397
|
-
group_msg: EventDataGroupMsg;
|
|
398
|
-
private_recall: EventDataPrivateRecall;
|
|
399
|
-
group_recall: EventDataGroupRecall;
|
|
400
|
-
private_request: EventDataPrivateRequest;
|
|
401
|
-
group_request: EventDataGroupRequest;
|
|
402
|
-
private_add: EventDataPrivateAdd;
|
|
403
|
-
group_increase: EventDataGroupIncrease;
|
|
404
|
-
group_decrease: EventDataGroupDecrease;
|
|
405
|
-
group_admin: EventDataGroupAdmin;
|
|
406
|
-
group_ban: EventDataGroupBan;
|
|
407
|
-
}
|
|
408
|
-
export type EventCallback<T extends keyof EventType> = (data: EventType[T]) => void;
|
|
409
|
-
export type EventLists = {
|
|
410
|
-
type: keyof EventType;
|
|
411
|
-
callback: EventCallback<keyof EventType>;
|
|
412
|
-
}[];
|
|
413
|
-
export interface DevErrorExtra {
|
|
414
|
-
path: string;
|
|
415
|
-
type: 'warning' | 'info' | 'error';
|
|
416
|
-
}
|
|
417
|
-
export {};
|
package/lib/types.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.eventDataTargetIdSchema = exports.ModulePackageSchema = exports.kotoriConfigSchema = exports.globalConfigSchemaController = exports.globalOptions = exports.localeTypeSchema = exports.packageInfoSchema = exports.baseDirSchema = void 0;
|
|
7
|
-
const tsukiko_1 = __importDefault(require("tsukiko"));
|
|
8
|
-
const core_1 = require("./base/core");
|
|
9
|
-
const consts_1 = require("./consts");
|
|
10
|
-
exports.baseDirSchema = tsukiko_1.default.Object({
|
|
11
|
-
root: tsukiko_1.default.String(),
|
|
12
|
-
modules: tsukiko_1.default.String(),
|
|
13
|
-
});
|
|
14
|
-
exports.packageInfoSchema = tsukiko_1.default.Object({
|
|
15
|
-
name: tsukiko_1.default.String(),
|
|
16
|
-
version: tsukiko_1.default.String(),
|
|
17
|
-
description: tsukiko_1.default.String(),
|
|
18
|
-
main: tsukiko_1.default.String(),
|
|
19
|
-
license: tsukiko_1.default.Literal('GPL-3.0'),
|
|
20
|
-
author: tsukiko_1.default.String(),
|
|
21
|
-
});
|
|
22
|
-
exports.localeTypeSchema = tsukiko_1.default.Union([
|
|
23
|
-
tsukiko_1.default.Union([tsukiko_1.default.Literal('en_US'), tsukiko_1.default.Literal('ja_JP')]),
|
|
24
|
-
tsukiko_1.default.Union([tsukiko_1.default.Literal('zh_CN'), tsukiko_1.default.Literal('zh_TW')]),
|
|
25
|
-
]);
|
|
26
|
-
exports.globalOptions = tsukiko_1.default.Object({
|
|
27
|
-
env: tsukiko_1.default.Union([tsukiko_1.default.Literal('dev'), tsukiko_1.default.Literal('build')]).default('dev'),
|
|
28
|
-
});
|
|
29
|
-
const CommonConfigSchemaController = (lang = consts_1.DEFAULT_LANG, commandPrefix = consts_1.DEFAULT_COMMAND_PREFIX) => tsukiko_1.default.Object({
|
|
30
|
-
lang: exports.localeTypeSchema.default(lang),
|
|
31
|
-
'command-prefix': tsukiko_1.default.String().default(commandPrefix),
|
|
32
|
-
});
|
|
33
|
-
const GlobalConfigSchema = tsukiko_1.default.Intersection([
|
|
34
|
-
tsukiko_1.default.Object({
|
|
35
|
-
dirs: tsukiko_1.default.Array(tsukiko_1.default.String()).default([]),
|
|
36
|
-
}),
|
|
37
|
-
CommonConfigSchemaController(),
|
|
38
|
-
]);
|
|
39
|
-
const adapterConfigBaseSchemaController = (lang, commandPrefix) => tsukiko_1.default.Intersection([
|
|
40
|
-
tsukiko_1.default.Object({
|
|
41
|
-
extends: tsukiko_1.default.String(),
|
|
42
|
-
master: tsukiko_1.default.Union([tsukiko_1.default.Number(), tsukiko_1.default.String()]),
|
|
43
|
-
}),
|
|
44
|
-
CommonConfigSchemaController(lang, commandPrefix),
|
|
45
|
-
]);
|
|
46
|
-
const adapterConfigBaseSchema = adapterConfigBaseSchemaController();
|
|
47
|
-
const pluginConfigBaseSchema = tsukiko_1.default.Object({
|
|
48
|
-
priority: tsukiko_1.default.Number().min(0).default(100),
|
|
49
|
-
});
|
|
50
|
-
const globalConfigSchemaController = (lang, commandPrefix) => tsukiko_1.default.Object({
|
|
51
|
-
global: GlobalConfigSchema,
|
|
52
|
-
adapter: tsukiko_1.default.Object({}).index(adapterConfigBaseSchemaController(lang, commandPrefix)).default({}),
|
|
53
|
-
plugin: tsukiko_1.default.Object({}).index(pluginConfigBaseSchema),
|
|
54
|
-
});
|
|
55
|
-
exports.globalConfigSchemaController = globalConfigSchemaController;
|
|
56
|
-
const globalConfigSchema = (0, exports.globalConfigSchemaController)();
|
|
57
|
-
exports.kotoriConfigSchema = tsukiko_1.default.Object({
|
|
58
|
-
baseDir: exports.baseDirSchema.default({ root: consts_1.DEFAULT_ROOT_DIR, modules: consts_1.DEFAULT_MODULES_DIR }),
|
|
59
|
-
config: globalConfigSchema.default({
|
|
60
|
-
global: {
|
|
61
|
-
lang: consts_1.DEFAULT_LANG,
|
|
62
|
-
'command-prefix': consts_1.DEFAULT_COMMAND_PREFIX,
|
|
63
|
-
},
|
|
64
|
-
adapter: {},
|
|
65
|
-
}),
|
|
66
|
-
options: exports.globalOptions.default({
|
|
67
|
-
env: consts_1.DEFAULT_ENV,
|
|
68
|
-
}), // question
|
|
69
|
-
}).default(core_1.defaultConfig);
|
|
70
|
-
exports.ModulePackageSchema = tsukiko_1.default.Object({
|
|
71
|
-
name: tsukiko_1.default.String().regexp(/kotori-plugin-[a-z]([a-z,0-9]{3,13})\b/),
|
|
72
|
-
version: tsukiko_1.default.String(),
|
|
73
|
-
description: tsukiko_1.default.String(),
|
|
74
|
-
main: tsukiko_1.default.String(),
|
|
75
|
-
license: tsukiko_1.default.Literal('GPL-3.0'),
|
|
76
|
-
author: tsukiko_1.default.Union([tsukiko_1.default.String(), tsukiko_1.default.Array(tsukiko_1.default.String())]),
|
|
77
|
-
peerDependencies: tsukiko_1.default.Object({
|
|
78
|
-
'kotori-bot': tsukiko_1.default.String(),
|
|
79
|
-
}),
|
|
80
|
-
});
|
|
81
|
-
exports.eventDataTargetIdSchema = tsukiko_1.default.Union([tsukiko_1.default.String(), tsukiko_1.default.Number()]);
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { CommandParseResultExtra } from '../types';
|
|
2
|
-
export declare class CommandExtra {
|
|
3
|
-
value: CommandParseResultExtra[keyof CommandParseResultExtra];
|
|
4
|
-
constructor(value: CommandParseResultExtra[keyof CommandParseResultExtra]);
|
|
5
|
-
}
|
|
6
|
-
export default CommandExtra;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommandExtra = void 0;
|
|
4
|
-
class CommandExtra {
|
|
5
|
-
value;
|
|
6
|
-
constructor(value) {
|
|
7
|
-
this.value = value;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.CommandExtra = CommandExtra;
|
|
11
|
-
exports.default = CommandExtra;
|
package/lib/utils/i18n.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Locale as LocaleOrigin, LocaleType } from '@kotori-bot/i18n';
|
|
2
|
-
export * from '@kotori-bot/i18n';
|
|
3
|
-
export declare class Locale {
|
|
4
|
-
private readonly instance;
|
|
5
|
-
readonly locale: LocaleOrigin['locale'];
|
|
6
|
-
readonly set: LocaleOrigin['set'];
|
|
7
|
-
readonly get: LocaleOrigin['get'];
|
|
8
|
-
constructor(lang?: LocaleType);
|
|
9
|
-
private localePathList;
|
|
10
|
-
private loader;
|
|
11
|
-
use(data: Parameters<typeof this.instance.use>[0] | string): boolean;
|
|
12
|
-
}
|
|
13
|
-
export default Locale;
|
package/lib/utils/i18n.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.Locale = void 0;
|
|
21
|
-
const i18n_1 = require("@kotori-bot/i18n");
|
|
22
|
-
const path_1 = __importDefault(require("path"));
|
|
23
|
-
const tools_1 = require("@kotori-bot/tools");
|
|
24
|
-
const fs_1 = require("fs");
|
|
25
|
-
const tsukiko_1 = __importDefault(require("tsukiko"));
|
|
26
|
-
__exportStar(require("@kotori-bot/i18n"), exports);
|
|
27
|
-
class Locale {
|
|
28
|
-
instance;
|
|
29
|
-
locale;
|
|
30
|
-
set;
|
|
31
|
-
get;
|
|
32
|
-
constructor(lang = 'en_US') {
|
|
33
|
-
this.instance = new i18n_1.Locale(lang);
|
|
34
|
-
this.locale = (val, lang) => this.instance.locale(val, lang);
|
|
35
|
-
this.set = lang => this.instance.set(lang);
|
|
36
|
-
this.get = () => this.instance.get();
|
|
37
|
-
}
|
|
38
|
-
localePathList = [];
|
|
39
|
-
loader(dirPath) {
|
|
40
|
-
let state = true;
|
|
41
|
-
Object.values(i18n_1.LocaleIdentifier).forEach(type => {
|
|
42
|
-
if (typeof type !== 'string')
|
|
43
|
-
return;
|
|
44
|
-
const locales = (0, tools_1.loadConfig)(path_1.default.join(dirPath, `${type}.json`), 'json');
|
|
45
|
-
if (!tsukiko_1.default.Object({}).index(tsukiko_1.default.String()).check(locales)) {
|
|
46
|
-
state = false;
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
this.instance.use({ type: type, locales });
|
|
50
|
-
});
|
|
51
|
-
return state;
|
|
52
|
-
}
|
|
53
|
-
use(data) {
|
|
54
|
-
if (typeof data !== 'string') {
|
|
55
|
-
this.instance.use(data);
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
if (!(0, fs_1.existsSync)(data) || !(0, fs_1.statSync)(data).isDirectory())
|
|
59
|
-
return false;
|
|
60
|
-
this.localePathList.push(data);
|
|
61
|
-
return this.loader(data);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.Locale = Locale;
|
|
65
|
-
exports.default = Locale;
|
|
File without changes
|