@kotori-bot/core 1.7.0 → 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.md +674 -166
- package/lib/app/common.js +3 -3
- package/lib/app/config.js +5 -4
- package/lib/app/core.js +3 -3
- package/lib/app/index.js +3 -3
- package/lib/app/message.js +4 -4
- package/lib/components/adapter.js +3 -3
- package/lib/components/api.js +3 -3
- package/lib/components/cache.js +3 -3
- package/lib/components/command.js +3 -3
- package/lib/components/elements.js +3 -3
- package/lib/components/filter.js +3 -3
- package/lib/components/index.js +3 -3
- package/lib/components/messages.js +3 -3
- package/lib/components/session.js +3 -3
- package/lib/decorators/index.js +3 -3
- package/lib/decorators/plugin.js +3 -3
- package/lib/decorators/utils.js +3 -3
- package/lib/global/constants.js +3 -3
- package/lib/global/index.js +3 -3
- package/lib/global/symbols.js +3 -3
- package/lib/index.js +17 -17
- package/lib/types/adapter.js +3 -3
- package/lib/types/api.js +3 -3
- package/lib/types/command.js +3 -3
- package/lib/types/config.js +3 -3
- package/lib/types/events.js +3 -3
- package/lib/types/filter.js +3 -3
- package/lib/types/index.js +3 -3
- package/lib/types/message.js +3 -3
- package/lib/types/session.js +3 -3
- package/lib/utils/container.js +3 -3
- package/lib/utils/error.js +3 -3
- package/lib/utils/factory.js +3 -3
- package/lib/utils/internal.js +3 -3
- package/lib/utils/jsx.js +3 -3
- package/package.json +4 -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 -421
- 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 -13
- 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
- package/lib/utils/jsx.d.ts +0 -57
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import type { Adapter } from './adapter';
|
|
2
|
-
import type { Message, MessageMapping } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Elements handler base class.
|
|
5
|
-
*
|
|
6
|
-
* @abstract
|
|
7
|
-
*/
|
|
8
|
-
export declare abstract class Elements {
|
|
9
|
-
/**
|
|
10
|
-
* Adapter instance.
|
|
11
|
-
*
|
|
12
|
-
* @readonly
|
|
13
|
-
*/
|
|
14
|
-
readonly adapter: Adapter<any, any, any>;
|
|
15
|
-
/**
|
|
16
|
-
* Decode a elements handler.
|
|
17
|
-
*
|
|
18
|
-
* @param adapter - Adapter instance
|
|
19
|
-
*/
|
|
20
|
-
constructor(adapter: Adapter<any, any, any>);
|
|
21
|
-
/**
|
|
22
|
-
* Encode raw message string to `Message`.
|
|
23
|
-
*
|
|
24
|
-
* @param raw - Raw message
|
|
25
|
-
* @param meta - Message metadata
|
|
26
|
-
* @returns Encoded message
|
|
27
|
-
*
|
|
28
|
-
* @abstract
|
|
29
|
-
*/
|
|
30
|
-
abstract encode(raw: string, meta?: object): Message;
|
|
31
|
-
/**
|
|
32
|
-
* Decode `Message` elements to string.
|
|
33
|
-
*
|
|
34
|
-
* @param message - Message to decode
|
|
35
|
-
* @param meta - Message metadata
|
|
36
|
-
* @returns Decoded message
|
|
37
|
-
*
|
|
38
|
-
* @abstract
|
|
39
|
-
*/
|
|
40
|
-
abstract decode(message: Message, meta?: object): string;
|
|
41
|
-
/**
|
|
42
|
-
* Decode a mention message.
|
|
43
|
-
*
|
|
44
|
-
* @param userId - User id
|
|
45
|
-
* @param meta - Message metadata
|
|
46
|
-
* @returns Mention message
|
|
47
|
-
*
|
|
48
|
-
* @deprecated
|
|
49
|
-
*/
|
|
50
|
-
mention(userId: string, meta?: object): string;
|
|
51
|
-
/**
|
|
52
|
-
* Decode a mention all message.
|
|
53
|
-
*
|
|
54
|
-
* @param meta - Message metadata
|
|
55
|
-
* @returns Mention all message
|
|
56
|
-
*
|
|
57
|
-
* @deprecated
|
|
58
|
-
*/
|
|
59
|
-
mentionAll(meta?: object): string;
|
|
60
|
-
/**
|
|
61
|
-
* Decode an image message.
|
|
62
|
-
*
|
|
63
|
-
* @param content - Image content
|
|
64
|
-
* @param meta - Message metadata
|
|
65
|
-
* @returns Image message
|
|
66
|
-
*
|
|
67
|
-
* @deprecated
|
|
68
|
-
*/
|
|
69
|
-
image(content: string, meta?: object): string;
|
|
70
|
-
/**
|
|
71
|
-
* Decode a voice message.
|
|
72
|
-
*
|
|
73
|
-
* @param content - Voice content
|
|
74
|
-
* @param meta - Message metadata
|
|
75
|
-
* @returns Voice message
|
|
76
|
-
*
|
|
77
|
-
* @deprecated
|
|
78
|
-
*/
|
|
79
|
-
voice(content: string, meta?: object): string;
|
|
80
|
-
/**
|
|
81
|
-
* Decode an audio message.
|
|
82
|
-
*
|
|
83
|
-
* @param content - Audio content
|
|
84
|
-
* @param meta - Message metadata
|
|
85
|
-
* @returns Audio message
|
|
86
|
-
*
|
|
87
|
-
* @deprecated
|
|
88
|
-
*/
|
|
89
|
-
audio(content: string, meta?: object): string;
|
|
90
|
-
/**
|
|
91
|
-
* Decode a video message.
|
|
92
|
-
*
|
|
93
|
-
* @param content - Video content
|
|
94
|
-
* @param meta - Message metadata
|
|
95
|
-
* @returns Video message
|
|
96
|
-
*
|
|
97
|
-
* @deprecated
|
|
98
|
-
*/
|
|
99
|
-
video(content: string, meta?: object): string;
|
|
100
|
-
/**
|
|
101
|
-
* Decode a file message.
|
|
102
|
-
*
|
|
103
|
-
* @param content - File content
|
|
104
|
-
* @param meta - Message metadata
|
|
105
|
-
* @returns File message
|
|
106
|
-
*
|
|
107
|
-
* @deprecated
|
|
108
|
-
*/
|
|
109
|
-
file(content: string, meta?: object): string;
|
|
110
|
-
/**
|
|
111
|
-
* Decode a location message.
|
|
112
|
-
*
|
|
113
|
-
* @param latitude - Latitude
|
|
114
|
-
* @param longitude - Longitude
|
|
115
|
-
* @param title - Title
|
|
116
|
-
* @param content - Content
|
|
117
|
-
* @param meta - Message metadata
|
|
118
|
-
* @returns Location message
|
|
119
|
-
*
|
|
120
|
-
* @deprecated
|
|
121
|
-
*/
|
|
122
|
-
location(latitude: number, longitude: number, title: string, content: string, meta?: object): string;
|
|
123
|
-
/**
|
|
124
|
-
* Decode a reply message.
|
|
125
|
-
*
|
|
126
|
-
* @param messageId - Message id
|
|
127
|
-
* @param meta - Message metadata
|
|
128
|
-
* @returns Reply message
|
|
129
|
-
*
|
|
130
|
-
* @deprecated
|
|
131
|
-
*/
|
|
132
|
-
reply(messageId: string, meta?: object): string;
|
|
133
|
-
/**
|
|
134
|
-
* Get supported elements.
|
|
135
|
-
*
|
|
136
|
-
* @returns Supported elements
|
|
137
|
-
*
|
|
138
|
-
* @abstract
|
|
139
|
-
*
|
|
140
|
-
* @deprecated
|
|
141
|
-
*/
|
|
142
|
-
abstract getSupportsElements(): (keyof MessageMapping)[];
|
|
143
|
-
}
|
|
144
|
-
export default Elements;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Session } from '../components';
|
|
2
|
-
import { type FilterOption } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Session filter.
|
|
5
|
-
*
|
|
6
|
-
* @class
|
|
7
|
-
*/
|
|
8
|
-
export declare class Filter {
|
|
9
|
-
private static getTestDomain;
|
|
10
|
-
private static handleFilter;
|
|
11
|
-
private readonly option;
|
|
12
|
-
/**
|
|
13
|
-
* Create a filter.
|
|
14
|
-
*
|
|
15
|
-
* @param option - Filter options
|
|
16
|
-
*
|
|
17
|
-
* @constructor
|
|
18
|
-
*/
|
|
19
|
-
constructor(option: FilterOption);
|
|
20
|
-
test(session: Session): boolean;
|
|
21
|
-
}
|
|
22
|
-
export default Filter;
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import type { Message, MessageMapping } from '../types';
|
|
2
|
-
type MessageTypeList = {
|
|
3
|
-
[K in keyof MessageMapping]: {
|
|
4
|
-
type: K;
|
|
5
|
-
} & MessageMapping[K];
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Single message class.
|
|
9
|
-
*
|
|
10
|
-
* @template T - Message type
|
|
11
|
-
*/
|
|
12
|
-
export declare class MessageSingle<T extends keyof MessageMapping> extends String {
|
|
13
|
-
/**
|
|
14
|
-
* Message data.
|
|
15
|
-
*
|
|
16
|
-
* @readonly
|
|
17
|
-
*/
|
|
18
|
-
data: MessageTypeList[T];
|
|
19
|
-
/**
|
|
20
|
-
* Create a single message
|
|
21
|
-
*
|
|
22
|
-
* @param type - Message type
|
|
23
|
-
* @param data - Message data
|
|
24
|
-
*/
|
|
25
|
-
constructor(type: T, data: MessageMapping[T]);
|
|
26
|
-
/**
|
|
27
|
-
* Convert message to string.
|
|
28
|
-
*
|
|
29
|
-
* @param isStrict - Whether to strictly convert message, strict convert will ignore the elements else text
|
|
30
|
-
* @returns Message string
|
|
31
|
-
*/
|
|
32
|
-
toString(isStrict?: boolean): string;
|
|
33
|
-
/**
|
|
34
|
-
* Check whether the message is text.
|
|
35
|
-
*
|
|
36
|
-
* @returns Whether the message is text
|
|
37
|
-
*/
|
|
38
|
-
isText(): boolean;
|
|
39
|
-
}
|
|
40
|
-
declare class MessageListOrigin<T extends keyof MessageMapping> extends Array<MessageSingle<T>> {
|
|
41
|
-
/**
|
|
42
|
-
* Create a message list.
|
|
43
|
-
*
|
|
44
|
-
* @param messages - Message list
|
|
45
|
-
*/
|
|
46
|
-
constructor(...messages: Message<T>[]);
|
|
47
|
-
/**
|
|
48
|
-
* Convert message list to string.
|
|
49
|
-
*
|
|
50
|
-
* @param isStrict - Whether to strictly convert message, strict convert will ignore the elements else text
|
|
51
|
-
* @returns Message string
|
|
52
|
-
*/
|
|
53
|
-
toString(isStrict?: boolean): string;
|
|
54
|
-
/**
|
|
55
|
-
* Check whether the message list is pure.
|
|
56
|
-
*
|
|
57
|
-
* @param keys - Message type list
|
|
58
|
-
*
|
|
59
|
-
* @returns Whether the message list is pure
|
|
60
|
-
*/
|
|
61
|
-
isPure<T extends keyof MessageMapping>(...keys: T[]): boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Check whether the message list is text.
|
|
64
|
-
*
|
|
65
|
-
* @returns Whether the message list is text
|
|
66
|
-
*/
|
|
67
|
-
isText(): boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Pick message list.
|
|
70
|
-
*
|
|
71
|
-
* @param keys - Message type list
|
|
72
|
-
* @returns Message list
|
|
73
|
-
*/
|
|
74
|
-
pick<T extends keyof MessageMapping>(...keys: T[]): MessageList<T>;
|
|
75
|
-
/**
|
|
76
|
-
* Omit message list.
|
|
77
|
-
*
|
|
78
|
-
* @param keys - Message type list
|
|
79
|
-
* @returns Message list
|
|
80
|
-
*/
|
|
81
|
-
omit<T extends keyof MessageMapping>(...keys: T[]): MessageList<T>;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Message list class.
|
|
85
|
-
*
|
|
86
|
-
* @template T - Message type
|
|
87
|
-
* @class
|
|
88
|
-
*/
|
|
89
|
-
export type MessageList<T extends keyof MessageMapping> = (typeof String)['prototype'] & MessageListOrigin<T>;
|
|
90
|
-
export declare const MessageList: new <T extends keyof MessageMapping = keyof MessageMapping>(...args: ConstructorParameters<typeof MessageListOrigin>) => MessageList<T>;
|
|
91
|
-
/**
|
|
92
|
-
* Create a message list.
|
|
93
|
-
*
|
|
94
|
-
* @param messages - Message list
|
|
95
|
-
* @returns Message list
|
|
96
|
-
*/
|
|
97
|
-
export declare function Messages<T extends keyof MessageMapping = keyof MessageMapping>(...messages: Message<T>[]): MessageList<keyof MessageMapping>;
|
|
98
|
-
/**
|
|
99
|
-
* Messages namespace
|
|
100
|
-
*
|
|
101
|
-
* @namespace
|
|
102
|
-
*/
|
|
103
|
-
export declare namespace Messages {
|
|
104
|
-
/**
|
|
105
|
-
* Create a text message.
|
|
106
|
-
*
|
|
107
|
-
* @param text - Text string
|
|
108
|
-
* @returns Text message
|
|
109
|
-
*/
|
|
110
|
-
function text(text: string): MessageSingle<"text">;
|
|
111
|
-
/**
|
|
112
|
-
* Create a mention message.
|
|
113
|
-
*
|
|
114
|
-
* @param userId - User id
|
|
115
|
-
* @returns Mention message
|
|
116
|
-
*/
|
|
117
|
-
function mention(userId: string): MessageSingle<"mention">;
|
|
118
|
-
/**
|
|
119
|
-
* Create a mention all message.
|
|
120
|
-
*
|
|
121
|
-
* @returns Mention all message
|
|
122
|
-
*/
|
|
123
|
-
function mentionAll(): MessageSingle<"mentionAll">;
|
|
124
|
-
/**
|
|
125
|
-
* Create an image message.
|
|
126
|
-
*
|
|
127
|
-
* @param content - Image content
|
|
128
|
-
* @returns Image message
|
|
129
|
-
*/
|
|
130
|
-
function image(content: string): MessageSingle<"image">;
|
|
131
|
-
/**
|
|
132
|
-
* Create a voice message.
|
|
133
|
-
*
|
|
134
|
-
* @param content - Voice content
|
|
135
|
-
* @returns Voice message
|
|
136
|
-
*/
|
|
137
|
-
function voice(content: string): MessageSingle<"voice">;
|
|
138
|
-
/**
|
|
139
|
-
* Create an audio message.
|
|
140
|
-
*
|
|
141
|
-
* @param content - Audio content
|
|
142
|
-
* @returns Audio message
|
|
143
|
-
*/
|
|
144
|
-
function audio(content: string): MessageSingle<"audio">;
|
|
145
|
-
/**
|
|
146
|
-
* Create a video message.
|
|
147
|
-
*
|
|
148
|
-
* @param content - Video content
|
|
149
|
-
* @returns Video message
|
|
150
|
-
*/
|
|
151
|
-
function video(content: string): MessageSingle<"video">;
|
|
152
|
-
/**
|
|
153
|
-
* Create a file message.
|
|
154
|
-
*
|
|
155
|
-
* @param content - File content
|
|
156
|
-
* @returns File message
|
|
157
|
-
*/
|
|
158
|
-
function file(content: string): MessageSingle<"file">;
|
|
159
|
-
/**
|
|
160
|
-
* Create a location message.
|
|
161
|
-
*
|
|
162
|
-
* @param latitude - Latitude
|
|
163
|
-
* @param longitude - Longitude
|
|
164
|
-
* @param title - Title
|
|
165
|
-
* @param content - Content
|
|
166
|
-
* @returns Location message
|
|
167
|
-
*/
|
|
168
|
-
function location(latitude: number, longitude: number, title: string, content: string): MessageSingle<"location">;
|
|
169
|
-
/**
|
|
170
|
-
* Create a reply message.
|
|
171
|
-
*
|
|
172
|
-
* @param messageId - Message id
|
|
173
|
-
* @returns Reply message
|
|
174
|
-
*/
|
|
175
|
-
function reply(messageId: string): MessageSingle<"reply">;
|
|
176
|
-
/**
|
|
177
|
-
* Stringify message.
|
|
178
|
-
*
|
|
179
|
-
* @param type - Message type
|
|
180
|
-
* @param data - Message data
|
|
181
|
-
* @param isStrict - Whether to strictly convert message, strict convert will ignore the elements else text
|
|
182
|
-
* @returns Message string
|
|
183
|
-
*/
|
|
184
|
-
function stringify<T extends keyof MessageMapping>(type: T, data: MessageMapping[T], isStrict?: boolean): string;
|
|
185
|
-
}
|
|
186
|
-
export default Messages;
|
|
@@ -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<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,13 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
export * from './app';
|
|
3
|
-
export * from './components';
|
|
4
|
-
export * from './decorators';
|
|
5
|
-
export * from './utils/jsx';
|
|
6
|
-
export * from './utils/error';
|
|
7
|
-
export * from './utils/factory';
|
|
8
|
-
export * from './utils/container';
|
|
9
|
-
export * from './global';
|
|
10
|
-
export * from './types';
|
|
11
|
-
export * from '@kotori-bot/tools';
|
|
12
|
-
export * from '@kotori-bot/i18n';
|
|
13
|
-
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 {};
|