@kotori-bot/core 1.6.5 → 1.7.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 → LICENSE.md} +674 -674
- package/lib/app/common.js +8 -10
- package/lib/app/config.js +9 -10
- package/lib/app/core.js +8 -10
- package/lib/app/index.js +8 -10
- package/lib/app/message.js +17 -19
- package/lib/components/adapter.js +8 -10
- package/lib/components/api.js +18 -16
- package/lib/components/cache.js +8 -10
- package/lib/components/command.js +8 -10
- package/lib/components/elements.js +8 -10
- package/lib/components/filter.js +8 -10
- package/lib/components/index.js +8 -10
- package/lib/components/messages.js +8 -10
- package/lib/components/session.js +27 -17
- package/lib/decorators/index.js +8 -10
- package/lib/decorators/plugin.js +8 -10
- package/lib/decorators/utils.js +14 -12
- package/lib/global/constants.js +8 -10
- package/lib/global/index.js +8 -10
- package/lib/global/symbols.js +8 -10
- package/lib/index.js +23 -23
- package/lib/types/adapter.js +8 -10
- package/lib/types/api.js +8 -10
- package/lib/types/command.js +8 -10
- package/lib/types/config.js +8 -10
- package/lib/types/events.js +8 -10
- package/lib/types/filter.js +8 -10
- package/lib/types/index.js +8 -10
- package/lib/types/message.js +8 -10
- package/lib/types/session.js +8 -10
- package/lib/utils/container.js +8 -10
- package/lib/utils/error.js +8 -10
- package/lib/utils/factory.js +10 -11
- package/lib/utils/internal.js +8 -10
- package/lib/utils/jsx.js +97 -0
- package/package.json +5 -4
- package/lib/app/common.d.ts +0 -6
- package/lib/app/config.d.ts +0 -32
- package/lib/app/core.d.ts +0 -139
- package/lib/app/index.d.ts +0 -3
- package/lib/app/message.d.ts +0 -34
- package/lib/components/adapter.d.ts +0 -122
- package/lib/components/api.d.ts +0 -417
- package/lib/components/cache.d.ts +0 -37
- package/lib/components/command.d.ts +0 -153
- package/lib/components/elements.d.ts +0 -144
- package/lib/components/filter.d.ts +0 -22
- package/lib/components/index.d.ts +0 -8
- package/lib/components/messages.d.ts +0 -186
- package/lib/components/session.d.ts +0 -177
- package/lib/decorators/index.d.ts +0 -7
- package/lib/decorators/plugin.d.ts +0 -7
- package/lib/decorators/utils.d.ts +0 -60
- package/lib/global/constants.d.ts +0 -8
- package/lib/global/index.d.ts +0 -2
- package/lib/global/symbols.d.ts +0 -15
- package/lib/index.d.ts +0 -12
- package/lib/types/adapter.d.ts +0 -22
- package/lib/types/api.d.ts +0 -72
- package/lib/types/command.d.ts +0 -78
- package/lib/types/config.d.ts +0 -21
- package/lib/types/events.d.ts +0 -3
- package/lib/types/filter.d.ts +0 -51
- package/lib/types/index.d.ts +0 -7
- package/lib/types/message.d.ts +0 -176
- package/lib/types/session.d.ts +0 -349
- package/lib/utils/container.d.ts +0 -9
- package/lib/utils/error.d.ts +0 -49
- package/lib/utils/factory.d.ts +0 -12
- package/lib/utils/internal.d.ts +0 -46
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { type EventDataApiBase, type Message, MessageScope, type MessageQuick, type CommandResult, type EventDataPrivateMsg, type EventDataGroupMsg, type EventDataChannelMsg } from '../types';
|
|
2
|
-
import type { Adapter } from './adapter';
|
|
3
|
-
import { formatFactory } from '../utils/factory';
|
|
4
|
-
import { CommandError } from '../utils/error';
|
|
5
|
-
import type { Api } from './api';
|
|
6
|
-
import type { Elements } from './elements';
|
|
7
|
-
import type { I18n } from '@kotori-bot/i18n';
|
|
8
|
-
declare class SessionOrigin<T extends EventDataApiBase = EventDataApiBase> implements EventDataApiBase {
|
|
9
|
-
/**
|
|
10
|
-
* Api instance of current session.
|
|
11
|
-
*
|
|
12
|
-
* @readonly
|
|
13
|
-
*/
|
|
14
|
-
readonly api: Api;
|
|
15
|
-
/**
|
|
16
|
-
* Elements instance of current session.
|
|
17
|
-
*
|
|
18
|
-
* @readonly
|
|
19
|
-
*/
|
|
20
|
-
readonly el: Elements;
|
|
21
|
-
/**
|
|
22
|
-
* I18n instance of current session.
|
|
23
|
-
*
|
|
24
|
-
* @readonly
|
|
25
|
-
*/
|
|
26
|
-
readonly i18n: I18n;
|
|
27
|
-
/**
|
|
28
|
-
* Session unique id, generated base on `type`. `userId`, `groupId`, `guildId`, `channelId`.
|
|
29
|
-
*
|
|
30
|
-
* @readonly
|
|
31
|
-
*/
|
|
32
|
-
readonly id: string;
|
|
33
|
-
/**
|
|
34
|
-
* Send message to current session.
|
|
35
|
-
*
|
|
36
|
-
* @param message - Message to send
|
|
37
|
-
* @returns Message id and sent time
|
|
38
|
-
*/
|
|
39
|
-
send(message: Message): Promise<import("../types").SendMessageResponse>;
|
|
40
|
-
/**
|
|
41
|
-
* Format message template with data.
|
|
42
|
-
*
|
|
43
|
-
* @param template - Message template
|
|
44
|
-
* @param data - Data to format
|
|
45
|
-
* @returns Formatted message
|
|
46
|
-
*/
|
|
47
|
-
readonly format: ReturnType<typeof formatFactory>;
|
|
48
|
-
/**
|
|
49
|
-
* Send message to current session, it's packed base on `session.send()`, `session.i18n` and `session.format()`.
|
|
50
|
-
*
|
|
51
|
-
* @param message - Message to send
|
|
52
|
-
* @returns Message id and sent time
|
|
53
|
-
*
|
|
54
|
-
* @async
|
|
55
|
-
*/
|
|
56
|
-
quick(message: MessageQuick): Promise<void>;
|
|
57
|
-
/**
|
|
58
|
-
* Get message from current session.
|
|
59
|
-
*
|
|
60
|
-
* @param message - Message to get
|
|
61
|
-
* @returns Message id and sent time
|
|
62
|
-
*/
|
|
63
|
-
json(message: unknown): Promise<string | import("../types").SendMessageResponse>;
|
|
64
|
-
/**
|
|
65
|
-
* Prompt message to current session.
|
|
66
|
-
*
|
|
67
|
-
* @param message - Message to prompt
|
|
68
|
-
* @returns Message from current session
|
|
69
|
-
*
|
|
70
|
-
* @async
|
|
71
|
-
*/
|
|
72
|
-
prompt(message?: Message): Promise<Message>;
|
|
73
|
-
/**
|
|
74
|
-
* Confirm message to current session.
|
|
75
|
-
*
|
|
76
|
-
* @param options - Options to confirm
|
|
77
|
-
* @returns Message from current session
|
|
78
|
-
*
|
|
79
|
-
* @async
|
|
80
|
-
*/
|
|
81
|
-
confirm(options?: {
|
|
82
|
-
message: Message;
|
|
83
|
-
sure: Message;
|
|
84
|
-
}): Promise<boolean>;
|
|
85
|
-
/**
|
|
86
|
-
* Create a command error.
|
|
87
|
-
*
|
|
88
|
-
* @param type - Error type
|
|
89
|
-
* @param data - Error data
|
|
90
|
-
* @returns Command error
|
|
91
|
-
*/
|
|
92
|
-
error<K extends keyof CommandResult>(type: K, data?: CommandResult[K]): CommandError;
|
|
93
|
-
readonly t: I18n['t'];
|
|
94
|
-
/**
|
|
95
|
-
* Session type
|
|
96
|
-
*
|
|
97
|
-
* @readonly
|
|
98
|
-
*/
|
|
99
|
-
readonly type: EventDataApiBase['type'];
|
|
100
|
-
/**
|
|
101
|
-
* Session time, milliseconds timestamp.
|
|
102
|
-
*
|
|
103
|
-
* @readonly
|
|
104
|
-
*/
|
|
105
|
-
readonly time: number;
|
|
106
|
-
/**
|
|
107
|
-
* Session related user id if exists.
|
|
108
|
-
*
|
|
109
|
-
* @readonly
|
|
110
|
-
*/
|
|
111
|
-
readonly userId?: string;
|
|
112
|
-
/**
|
|
113
|
-
* Session related operator id if exists.
|
|
114
|
-
*
|
|
115
|
-
* @readonly
|
|
116
|
-
*/
|
|
117
|
-
readonly operatorId?: string;
|
|
118
|
-
/**
|
|
119
|
-
* Session related message id if exists.
|
|
120
|
-
*
|
|
121
|
-
* @readonly
|
|
122
|
-
*/
|
|
123
|
-
readonly messageId?: string;
|
|
124
|
-
/**
|
|
125
|
-
* Session related group id if exists.
|
|
126
|
-
*
|
|
127
|
-
* @readonly
|
|
128
|
-
*/
|
|
129
|
-
readonly groupId?: string;
|
|
130
|
-
/**
|
|
131
|
-
* Session related channel id if exists.
|
|
132
|
-
*
|
|
133
|
-
* @readonly
|
|
134
|
-
*/
|
|
135
|
-
readonly channelId?: string;
|
|
136
|
-
/**
|
|
137
|
-
* Session related guild id if exists.
|
|
138
|
-
*
|
|
139
|
-
* @readonly
|
|
140
|
-
*/
|
|
141
|
-
readonly guildId?: string;
|
|
142
|
-
/**
|
|
143
|
-
* Session related meta data if exists, it is customized by the specific adapter.
|
|
144
|
-
*
|
|
145
|
-
* @readonly
|
|
146
|
-
*/
|
|
147
|
-
readonly meta?: EventDataApiBase['meta'];
|
|
148
|
-
/**
|
|
149
|
-
* Create a session instance.
|
|
150
|
-
*
|
|
151
|
-
* @param data - Session data
|
|
152
|
-
* @param adapter - Adapter instance
|
|
153
|
-
*
|
|
154
|
-
* @constructor
|
|
155
|
-
*/
|
|
156
|
-
constructor(data: T, adapter: Adapter);
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Session instance.
|
|
160
|
-
*
|
|
161
|
-
* @class Session
|
|
162
|
-
* @extends {SessionOrigin}
|
|
163
|
-
* @template T
|
|
164
|
-
*/
|
|
165
|
-
export type Session<T extends EventDataApiBase = EventDataApiBase> = SessionOrigin<T> & T;
|
|
166
|
-
export type SessionMsg = Session<EventDataPrivateMsg | EventDataGroupMsg | EventDataChannelMsg>;
|
|
167
|
-
export type SessionMsgPrivate = Session<EventDataPrivateMsg>;
|
|
168
|
-
export type SessionMsgGroup = Session<EventDataGroupMsg>;
|
|
169
|
-
export type SessionMsgChannel = Session<EventDataChannelMsg>;
|
|
170
|
-
/**
|
|
171
|
-
* Session event.
|
|
172
|
-
*
|
|
173
|
-
* @class
|
|
174
|
-
* @template T - Session event data type
|
|
175
|
-
*/
|
|
176
|
-
export declare const Session: new <T extends EventDataApiBase<MessageScope> = EventDataApiBase<MessageScope>>(data: T, bot: Adapter) => Session<T>;
|
|
177
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Context } from '../app';
|
|
2
|
-
export declare abstract class KotoriPlugin<T extends object | undefined = undefined> {
|
|
3
|
-
protected readonly ctx: Context;
|
|
4
|
-
protected readonly config: T;
|
|
5
|
-
constructor(ctx: Context, config: T);
|
|
6
|
-
}
|
|
7
|
-
export default KotoriPlugin;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
import { type EventsList, type ModuleConfig } from 'fluoro';
|
|
3
|
-
import { type Constructor, Parser } from 'tsukiko';
|
|
4
|
-
import { Symbols } from '../global';
|
|
5
|
-
import type { CommandConfig } from '../types';
|
|
6
|
-
import type { KotoriPlugin } from './plugin';
|
|
7
|
-
import type { Context } from '../app';
|
|
8
|
-
declare module '../types/events' {
|
|
9
|
-
interface EventsMapping {
|
|
10
|
-
literal_ready_module_decorator(name: string, config: ModuleConfig): void;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
interface EventOption {
|
|
14
|
-
type: keyof EventsList;
|
|
15
|
-
isOnce?: boolean;
|
|
16
|
-
}
|
|
17
|
-
interface CommandOption extends Omit<CommandConfig, 'action'> {
|
|
18
|
-
template: string;
|
|
19
|
-
options?: [string, string][];
|
|
20
|
-
}
|
|
21
|
-
interface MidwareOption {
|
|
22
|
-
priority?: number;
|
|
23
|
-
}
|
|
24
|
-
interface RegexpOption {
|
|
25
|
-
match: RegExp;
|
|
26
|
-
}
|
|
27
|
-
type TaskOption = Exclude<Parameters<Context['task']>[0], string>;
|
|
28
|
-
type Fn = (...args: any[]) => any;
|
|
29
|
-
interface PluginMetaAll {
|
|
30
|
-
name: string;
|
|
31
|
-
lang?: string;
|
|
32
|
-
inject: string[];
|
|
33
|
-
schema?: Parser<object>;
|
|
34
|
-
events: [Fn, EventOption, boolean][];
|
|
35
|
-
midwares: [Fn, MidwareOption, boolean][];
|
|
36
|
-
commands: [Fn, CommandOption, boolean][];
|
|
37
|
-
regexps: [Fn, RegexpOption, boolean][];
|
|
38
|
-
tasks: [Fn, TaskOption, boolean][];
|
|
39
|
-
}
|
|
40
|
-
type KotoriPluginChild = new (...args: ConstructorParameters<typeof KotoriPlugin>) => KotoriPlugin;
|
|
41
|
-
export declare class Decorators {
|
|
42
|
-
static [Symbols.decorator]: Map<string, KotoriPluginChild>;
|
|
43
|
-
static getMeta(target: object | string): PluginMetaAll | undefined;
|
|
44
|
-
static setup(ctx: Context): void;
|
|
45
|
-
static load(ctx: Context, target: string | Constructor, config: ModuleConfig): boolean;
|
|
46
|
-
private readonly pkgName;
|
|
47
|
-
private error;
|
|
48
|
-
private getMeta;
|
|
49
|
-
constructor(pkgName: string);
|
|
50
|
-
readonly import: (target: object) => void;
|
|
51
|
-
readonly lang: <T extends object>(target: T, name: keyof T) => void;
|
|
52
|
-
readonly inject: <T extends object>(target: T, name: keyof T) => void;
|
|
53
|
-
readonly schema: <T extends object>(target: T, name: keyof T) => void;
|
|
54
|
-
on(options: EventOption): <T extends object>(target: T, key: keyof T) => void;
|
|
55
|
-
midware(options?: MidwareOption): <T extends object>(target: T, key: keyof T) => void;
|
|
56
|
-
command(options: CommandOption): <T extends object>(target: T, key: keyof T) => void;
|
|
57
|
-
regexp(options: RegexpOption): <T extends object>(target: T, key: keyof T) => void;
|
|
58
|
-
task(options: TaskOption): <T extends object>(target: T, key: keyof T) => void;
|
|
59
|
-
}
|
|
60
|
-
export default Decorators;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const DEFAULT_CORE_CONFIG: {
|
|
2
|
-
global: {
|
|
3
|
-
lang: "common" | "en_US" | "en_GB" | "en_AU" | "zh_CN" | "zh_HK" | "zh_TW" | "zh_SG" | "es_ES" | "es_MX" | "ar_EG" | "ar_AE" | "ru_RU" | "fr_FR" | "fr_CA" | "de_DE" | "de_CH" | "it_IT" | "it_CH" | "hi_IN" | "pt_BR" | "pt_PT" | "tr_TR" | "ja_JP" | "id_ID" | "uk_UA" | "vi_VN" | "th_TH" | "sv_SE" | "nb_NO" | "da_DK" | "fi_FI" | "he_IL" | "sk_SK" | "bg_BG" | "lt_LT" | "sl_SI" | "sr_RS" | "mk_MK" | "sq_AL" | "et_EE" | "mt_MT";
|
|
4
|
-
commandPrefix: string;
|
|
5
|
-
};
|
|
6
|
-
adapter: {};
|
|
7
|
-
plugin: {};
|
|
8
|
-
};
|
package/lib/global/index.d.ts
DELETED
package/lib/global/symbols.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare namespace Symbols {
|
|
2
|
-
const adapter: unique symbol;
|
|
3
|
-
const bot: unique symbol;
|
|
4
|
-
const midware: unique symbol;
|
|
5
|
-
const command: unique symbol;
|
|
6
|
-
const regexp: unique symbol;
|
|
7
|
-
const task: unique symbol;
|
|
8
|
-
const filter: unique symbol;
|
|
9
|
-
const promise: unique symbol;
|
|
10
|
-
const decorator: unique symbol;
|
|
11
|
-
const modules: unique symbol;
|
|
12
|
-
const getInstance: unique symbol;
|
|
13
|
-
const setInstance: unique symbol;
|
|
14
|
-
}
|
|
15
|
-
export default Symbols;
|
package/lib/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
export * from './app';
|
|
3
|
-
export * from './components';
|
|
4
|
-
export * from './decorators';
|
|
5
|
-
export * from './utils/error';
|
|
6
|
-
export * from './utils/factory';
|
|
7
|
-
export * from './utils/container';
|
|
8
|
-
export * from './global';
|
|
9
|
-
export * from './types';
|
|
10
|
-
export * from '@kotori-bot/tools';
|
|
11
|
-
export * from '@kotori-bot/i18n';
|
|
12
|
-
export * from 'tsukiko';
|
package/lib/types/adapter.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Context } from '../app';
|
|
2
|
-
import type { Adapter } from '../components';
|
|
3
|
-
import type { AdapterConfig } from './config';
|
|
4
|
-
declare module './events' {
|
|
5
|
-
interface EventsMapping {
|
|
6
|
-
connect(data: EventDataConnect): void;
|
|
7
|
-
status(data: EventDataStatus): void;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
interface EventDataConnect {
|
|
11
|
-
adapter: Adapter;
|
|
12
|
-
type: 'connect' | 'disconnect';
|
|
13
|
-
normal: boolean;
|
|
14
|
-
mode: 'ws' | 'ws-reverse' | 'other';
|
|
15
|
-
address: string;
|
|
16
|
-
}
|
|
17
|
-
interface EventDataStatus {
|
|
18
|
-
adapter: Adapter;
|
|
19
|
-
status: Adapter['status']['value'];
|
|
20
|
-
}
|
|
21
|
-
export type AdapterClass = new (ctx: Context, config: AdapterConfig, identity: string) => Adapter;
|
|
22
|
-
export {};
|
package/lib/types/api.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/** Response for sending message */
|
|
3
|
-
export interface SendMessageResponse {
|
|
4
|
-
/** Message id */
|
|
5
|
-
messageId: string;
|
|
6
|
-
/** Send time (milliseconds timestamp) */
|
|
7
|
-
time: number;
|
|
8
|
-
}
|
|
9
|
-
/** Response for bot self information */
|
|
10
|
-
export interface SelfInfoResponse {
|
|
11
|
-
/** User id */
|
|
12
|
-
userId: string;
|
|
13
|
-
/** User name or nickname */
|
|
14
|
-
username: string;
|
|
15
|
-
/** The display name, or empty string if none */
|
|
16
|
-
userDisplayname: string;
|
|
17
|
-
}
|
|
18
|
-
/** Response for user information */
|
|
19
|
-
export interface UserInfoResponse extends SelfInfoResponse {
|
|
20
|
-
/** The remark name set set by current bot account, or empty string if none */
|
|
21
|
-
userRemark: string;
|
|
22
|
-
}
|
|
23
|
-
/** Response for group information */
|
|
24
|
-
export interface GroupInfoResponse {
|
|
25
|
-
/** Group id */
|
|
26
|
-
groupId: string;
|
|
27
|
-
/** Group name */
|
|
28
|
-
groupName: string;
|
|
29
|
-
}
|
|
30
|
-
/** Response for guild information */
|
|
31
|
-
export interface GuildInfoResponse {
|
|
32
|
-
/** Guild id */
|
|
33
|
-
guildId: string;
|
|
34
|
-
/** Guild name */
|
|
35
|
-
guildName: string;
|
|
36
|
-
}
|
|
37
|
-
/** Response for channel information */
|
|
38
|
-
export interface ChannelInfoResponse {
|
|
39
|
-
/** Channel id */
|
|
40
|
-
channelId: string;
|
|
41
|
-
/** Channel name */
|
|
42
|
-
channelName: string;
|
|
43
|
-
}
|
|
44
|
-
/** Response for file upload */
|
|
45
|
-
export interface UploadFileResponse {
|
|
46
|
-
/** File id */
|
|
47
|
-
filedId: string;
|
|
48
|
-
}
|
|
49
|
-
/** Response for file get */
|
|
50
|
-
export interface GetFileResponse {
|
|
51
|
-
/** File name */
|
|
52
|
-
name: string;
|
|
53
|
-
/** File data (origin binary)'s SHA256 checksum, all lowercase, optional */
|
|
54
|
-
sha256?: string;
|
|
55
|
-
}
|
|
56
|
-
/** Response for file get url */
|
|
57
|
-
export interface GetFileUrlResponse extends GetFileResponse {
|
|
58
|
-
/** File url */
|
|
59
|
-
url: string;
|
|
60
|
-
/** File download url headers, or empty object if none */
|
|
61
|
-
headers: Record<string, string>;
|
|
62
|
-
}
|
|
63
|
-
/** Response for file get path */
|
|
64
|
-
export interface GetFilePathResponse extends GetFileResponse {
|
|
65
|
-
/** File path */
|
|
66
|
-
path: string;
|
|
67
|
-
}
|
|
68
|
-
/** Response for file get data */
|
|
69
|
-
export interface GetFileDataResponse extends GetFileResponse {
|
|
70
|
-
/** File data */
|
|
71
|
-
data: Buffer;
|
|
72
|
-
}
|
package/lib/types/command.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import Tsu from 'tsukiko';
|
|
2
|
-
import type { TsuError } from 'tsukiko';
|
|
3
|
-
import type { MessageQuick, MessageScope, UserAccess } from './message';
|
|
4
|
-
import type { SessionMsg, SessionMsgChannel, SessionMsgGroup, SessionMsgPrivate } from '../components';
|
|
5
|
-
export type ArgsOrigin = CommandArgType[];
|
|
6
|
-
export type OptsOrigin = Record<string, CommandArgType>;
|
|
7
|
-
export type CommandAction<Args = ArgsOrigin, Opts = OptsOrigin, Scope = 'all'> = (data: {
|
|
8
|
-
args: Args;
|
|
9
|
-
options: Opts;
|
|
10
|
-
}, session: Scope extends MessageScope.PRIVATE ? SessionMsgPrivate : Scope extends MessageScope.GROUP ? SessionMsgGroup : Scope extends MessageScope.CHANNEL ? SessionMsgChannel : SessionMsg) => MessageQuick;
|
|
11
|
-
export type CommandArgType = string | number | boolean;
|
|
12
|
-
export declare const commandArgTypeSignSchema: import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"string">, import("tsukiko").LiteralParser<"number">, import("tsukiko").LiteralParser<"boolean">]>;
|
|
13
|
-
export type CommandArgTypeSign = Tsu.infer<typeof commandArgTypeSignSchema>;
|
|
14
|
-
/** Command instance config */
|
|
15
|
-
export interface CommandConfig {
|
|
16
|
-
/** Command alias (need bring command prefix) */
|
|
17
|
-
alias?: string[];
|
|
18
|
-
/** Command shortcut (needn't bring command prefix) */
|
|
19
|
-
shortcut?: string[];
|
|
20
|
-
/** Command required message scope (session type) */
|
|
21
|
-
scope?: MessageScope | 'all';
|
|
22
|
-
/** Command required user access level */
|
|
23
|
-
access?: UserAccess;
|
|
24
|
-
/** Command help message (have more details than command description) */
|
|
25
|
-
help?: string;
|
|
26
|
-
/** Command action */
|
|
27
|
-
action?: CommandAction;
|
|
28
|
-
}
|
|
29
|
-
interface CommandParseResult {
|
|
30
|
-
option_error: {
|
|
31
|
-
expected: CommandArgTypeSign;
|
|
32
|
-
reality: CommandArgTypeSign;
|
|
33
|
-
target: string;
|
|
34
|
-
};
|
|
35
|
-
arg_error: {
|
|
36
|
-
expected: CommandArgTypeSign;
|
|
37
|
-
reality: CommandArgTypeSign;
|
|
38
|
-
index: number;
|
|
39
|
-
};
|
|
40
|
-
arg_many: {
|
|
41
|
-
expected: number;
|
|
42
|
-
reality: number;
|
|
43
|
-
};
|
|
44
|
-
arg_few: CommandParseResult['arg_many'];
|
|
45
|
-
syntax: {
|
|
46
|
-
index: number;
|
|
47
|
-
char: string;
|
|
48
|
-
};
|
|
49
|
-
unknown: {
|
|
50
|
-
input: string;
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
export interface CommandResult extends CommandParseResult {
|
|
54
|
-
error: {
|
|
55
|
-
error: unknown;
|
|
56
|
-
};
|
|
57
|
-
data_error: {
|
|
58
|
-
target: string | number;
|
|
59
|
-
};
|
|
60
|
-
res_error: {
|
|
61
|
-
error: TsuError;
|
|
62
|
-
};
|
|
63
|
-
num_error: null;
|
|
64
|
-
no_access_manger: null;
|
|
65
|
-
no_access_admin: null;
|
|
66
|
-
disable: null;
|
|
67
|
-
exists: {
|
|
68
|
-
target: string;
|
|
69
|
-
};
|
|
70
|
-
no_exists: CommandResult['exists'];
|
|
71
|
-
}
|
|
72
|
-
type CommandResultNoArgs = 'num_error' | 'no_access_manger' | 'no_access_admin' | 'disable';
|
|
73
|
-
export type CommandResultExtra = {
|
|
74
|
-
[K in keyof CommandResult]: {
|
|
75
|
-
type: K;
|
|
76
|
-
} & (K extends CommandResultNoArgs ? object : CommandResult[K]);
|
|
77
|
-
};
|
|
78
|
-
export {};
|
package/lib/types/config.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { LocaleType } from '@kotori-bot/i18n';
|
|
2
|
-
import type { ModuleConfig } from 'fluoro';
|
|
3
|
-
export interface CoreConfig {
|
|
4
|
-
global: GlobalConfig;
|
|
5
|
-
adapter: {
|
|
6
|
-
[propName: string]: AdapterConfig;
|
|
7
|
-
};
|
|
8
|
-
plugin: {
|
|
9
|
-
[propName: string]: ModuleConfig;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export interface GlobalConfig {
|
|
13
|
-
lang: LocaleType;
|
|
14
|
-
commandPrefix: string;
|
|
15
|
-
}
|
|
16
|
-
export interface AdapterConfig {
|
|
17
|
-
extends: string;
|
|
18
|
-
master: string;
|
|
19
|
-
lang: LocaleType;
|
|
20
|
-
commandPrefix: string;
|
|
21
|
-
}
|
package/lib/types/events.d.ts
DELETED
package/lib/types/filter.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
export declare enum FilterTestList {
|
|
2
|
-
PLATFORM = "platform",
|
|
3
|
-
USER_ID = "userId",
|
|
4
|
-
GROUP_ID = "groupId",
|
|
5
|
-
OPERATOR_ID = "operatorId",
|
|
6
|
-
MESSAGE_ID = "messageId",
|
|
7
|
-
SCOPE = "scope",
|
|
8
|
-
ACCESS = "access",
|
|
9
|
-
IDENTITY = "identity",
|
|
10
|
-
LOCALE_TYPE = "localeType",
|
|
11
|
-
SELF_ID = "selfId"
|
|
12
|
-
}
|
|
13
|
-
export type FilterOption = FilterOptionBase | FilterOptionGroup;
|
|
14
|
-
/** Single filter option */
|
|
15
|
-
export interface FilterOptionBase {
|
|
16
|
-
test: FilterTestList;
|
|
17
|
-
operator: '==' | '!=' | '>' | '<' | '>=' | '<=';
|
|
18
|
-
value: string | number | boolean;
|
|
19
|
-
}
|
|
20
|
-
/** Group filters option */
|
|
21
|
-
export interface FilterOptionGroup {
|
|
22
|
-
/** Match type, filters of all passed, filter of any one passed, filters of none passed */
|
|
23
|
-
type: 'all_of' | 'any_of' | 'none_of';
|
|
24
|
-
/** Filters list */
|
|
25
|
-
filters: FilterOption[];
|
|
26
|
-
}
|
|
27
|
-
export declare const filterOptionBaseSchema: import("tsukiko").ObjectParser<{
|
|
28
|
-
test: import("tsukiko").CustomParser<FilterTestList>;
|
|
29
|
-
operator: import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"==">, import("tsukiko").LiteralParser<"!=">, import("tsukiko").LiteralParser<">">, import("tsukiko").LiteralParser<"<">, import("tsukiko").LiteralParser<">=">, import("tsukiko").LiteralParser<"<=">]>;
|
|
30
|
-
value: import("tsukiko").UnionParser<[import("tsukiko").StringParser, import("tsukiko").NumberParser, import("tsukiko").BooleanParser]>;
|
|
31
|
-
}>;
|
|
32
|
-
export declare const filterOptionGroupSchema: import("tsukiko").ObjectParser<{
|
|
33
|
-
type: import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"all_of">, import("tsukiko").LiteralParser<"any_of">, import("tsukiko").LiteralParser<"none_of">]>;
|
|
34
|
-
filters: import("tsukiko").ArrayParser<import("tsukiko").ObjectParser<{
|
|
35
|
-
test: import("tsukiko").CustomParser<FilterTestList>;
|
|
36
|
-
operator: import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"==">, import("tsukiko").LiteralParser<"!=">, import("tsukiko").LiteralParser<">">, import("tsukiko").LiteralParser<"<">, import("tsukiko").LiteralParser<">=">, import("tsukiko").LiteralParser<"<=">]>;
|
|
37
|
-
value: import("tsukiko").UnionParser<[import("tsukiko").StringParser, import("tsukiko").NumberParser, import("tsukiko").BooleanParser]>;
|
|
38
|
-
}>>;
|
|
39
|
-
}>;
|
|
40
|
-
export declare const filterOptionSchema: import("tsukiko").UnionParser<[import("tsukiko").ObjectParser<{
|
|
41
|
-
test: import("tsukiko").CustomParser<FilterTestList>;
|
|
42
|
-
operator: import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"==">, import("tsukiko").LiteralParser<"!=">, import("tsukiko").LiteralParser<">">, import("tsukiko").LiteralParser<"<">, import("tsukiko").LiteralParser<">=">, import("tsukiko").LiteralParser<"<=">]>;
|
|
43
|
-
value: import("tsukiko").UnionParser<[import("tsukiko").StringParser, import("tsukiko").NumberParser, import("tsukiko").BooleanParser]>;
|
|
44
|
-
}>, import("tsukiko").ObjectParser<{
|
|
45
|
-
type: import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"all_of">, import("tsukiko").LiteralParser<"any_of">, import("tsukiko").LiteralParser<"none_of">]>;
|
|
46
|
-
filters: import("tsukiko").ArrayParser<import("tsukiko").ObjectParser<{
|
|
47
|
-
test: import("tsukiko").CustomParser<FilterTestList>;
|
|
48
|
-
operator: import("tsukiko").UnionParser<[import("tsukiko").LiteralParser<"==">, import("tsukiko").LiteralParser<"!=">, import("tsukiko").LiteralParser<">">, import("tsukiko").LiteralParser<"<">, import("tsukiko").LiteralParser<">=">, import("tsukiko").LiteralParser<"<=">]>;
|
|
49
|
-
value: import("tsukiko").UnionParser<[import("tsukiko").StringParser, import("tsukiko").NumberParser, import("tsukiko").BooleanParser]>;
|
|
50
|
-
}>>;
|
|
51
|
-
}>]>;
|