chz-telegram-bot 0.7.13 → 0.7.15
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/dist/dtos/propertyProviderSets.d.ts +0 -1
- package/dist/dtos/propertyProviderSets.d.ts.map +1 -1
- package/dist/entities/actions/commandAction.d.ts +1 -1
- package/dist/entities/actions/commandAction.d.ts.map +1 -1
- package/dist/entities/actions/commandAction.js +2 -2
- package/dist/helpers/builders/commandActionBuilder.d.ts.map +1 -1
- package/dist/helpers/builders/commandActionBuilder.js +2 -3
- package/package.json +4 -1
- package/eslint.config.ts +0 -62
- package/src/builtin/helpAction.ts +0 -17
- package/src/dtos/chatHistoryMessage.ts +0 -22
- package/src/dtos/chatInfo.ts +0 -12
- package/src/dtos/commandTriggerCheckResult.ts +0 -40
- package/src/dtos/cooldownInfo.ts +0 -10
- package/src/dtos/incomingMessage.ts +0 -71
- package/src/dtos/incomingQuery.ts +0 -14
- package/src/dtos/messageInfo.ts +0 -15
- package/src/dtos/propertyProviderSets.ts +0 -21
- package/src/dtos/replyInfo.ts +0 -9
- package/src/dtos/responses/delay.ts +0 -28
- package/src/dtos/responses/imageMessage.ts +0 -41
- package/src/dtos/responses/inlineQueryResponse.ts +0 -26
- package/src/dtos/responses/reaction.ts +0 -30
- package/src/dtos/responses/textMessage.ts +0 -44
- package/src/dtos/responses/unpin.ts +0 -27
- package/src/dtos/responses/videoMessage.ts +0 -41
- package/src/dtos/userInfo.ts +0 -8
- package/src/entities/actions/commandAction.ts +0 -275
- package/src/entities/actions/inlineQueryAction.ts +0 -83
- package/src/entities/actions/replyCaptureAction.ts +0 -110
- package/src/entities/actions/scheduledAction.ts +0 -182
- package/src/entities/botInstance.ts +0 -92
- package/src/entities/cachedStateFactory.ts +0 -14
- package/src/entities/context/baseContext.ts +0 -111
- package/src/entities/context/chatContext.ts +0 -135
- package/src/entities/context/inlineQueryContext.ts +0 -63
- package/src/entities/context/messageContext.ts +0 -250
- package/src/entities/context/replyContext.ts +0 -260
- package/src/entities/states/actionStateBase.ts +0 -6
- package/src/entities/taskRecord.ts +0 -11
- package/src/helpers/builders/commandActionBuilder.ts +0 -214
- package/src/helpers/builders/inlineQueryActionBuilder.ts +0 -71
- package/src/helpers/builders/scheduledActionBuilder.ts +0 -143
- package/src/helpers/mapUtils.ts +0 -28
- package/src/helpers/noop.ts +0 -20
- package/src/helpers/objectFromEntries.ts +0 -7
- package/src/helpers/timeConvertions.ts +0 -13
- package/src/helpers/toArray.ts +0 -3
- package/src/helpers/traceFactory.ts +0 -11
- package/src/index.ts +0 -33
- package/src/main.ts +0 -76
- package/src/services/actionProcessingService.ts +0 -125
- package/src/services/actionProcessors/baseProcessor.ts +0 -67
- package/src/services/actionProcessors/commandActionProcessor.ts +0 -231
- package/src/services/actionProcessors/inlineQueryActionProcessor.ts +0 -165
- package/src/services/actionProcessors/scheduledActionProcessor.ts +0 -136
- package/src/services/jsonFileStorage.ts +0 -181
- package/src/services/nodeTimeoutScheduler.ts +0 -79
- package/src/services/responseProcessingQueue.ts +0 -57
- package/src/services/telegramApi.ts +0 -278
- package/src/types/action.ts +0 -15
- package/src/types/actionState.ts +0 -4
- package/src/types/cachedValueAccessor.ts +0 -1
- package/src/types/capture.ts +0 -33
- package/src/types/commandCondition.ts +0 -9
- package/src/types/commandTrigger.ts +0 -1
- package/src/types/events.ts +0 -286
- package/src/types/externalAliases.ts +0 -18
- package/src/types/handlers.ts +0 -26
- package/src/types/inputFile.ts +0 -4
- package/src/types/messageSendingOptions.ts +0 -10
- package/src/types/messageTypes.ts +0 -21
- package/src/types/propertyProvider.ts +0 -14
- package/src/types/response.ts +0 -51
- package/src/types/scheduler.ts +0 -20
- package/src/types/storage.ts +0 -23
- package/src/types/timeValues.ts +0 -33
- package/src/types/trace.ts +0 -5
- package/tests/dtos/commandTriggerCheckResult.test.ts +0 -301
- package/tests/entities/actions/inlineQueryAction.test.ts +0 -359
- package/tests/entities/actions/replyCaptureAction.test.ts +0 -501
- package/tests/entities/cachedStateFactory.test.ts +0 -98
- package/tests/entities/context/chatContext.test.ts +0 -606
- package/tests/entities/context/messageContext.test.ts +0 -370
- package/tests/entities/states/actionStateBase.test.ts +0 -138
- package/tests/entities/taskRecord.test.ts +0 -195
- package/tests/helpers/mapUtils.test.ts +0 -163
- package/tests/helpers/timeConvertions.test.ts +0 -129
- package/tests/services/actionProcessors/baseActionProcessor.test.ts +0 -359
- package/tests/services/actionProcessors/commandActionProcessor.test.ts +0 -268
- package/tests/services/actionProcessors/inlineQueryActionProcessor.test.ts +0 -616
- package/tests/services/actionProcessors/processorTestHelpers.ts +0 -147
- package/tests/services/actionProcessors/scheduledActionProcessor.test.ts +0 -153
- package/tests/services/jsonFileStorage.test.ts +0 -927
- package/tests/services/nodeTimeoutScheduler.test.ts +0 -421
- package/tests/services/responseProcessingQueue.test.ts +0 -388
- package/tsconfig.build.json +0 -8
- package/tsconfig.json +0 -118
package/src/types/events.ts
DELETED
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import { ChatInfo } from '../dtos/chatInfo';
|
|
2
|
-
import { IncomingMessage } from '../dtos/incomingMessage';
|
|
3
|
-
import { IncomingInlineQuery } from '../dtos/incomingQuery';
|
|
4
|
-
import { CommandAction } from '../entities/actions/commandAction';
|
|
5
|
-
import { ChatContext } from '../entities/context/chatContext';
|
|
6
|
-
import { InlineQueryContext } from '../entities/context/inlineQueryContext';
|
|
7
|
-
import { MessageContext } from '../entities/context/messageContext';
|
|
8
|
-
import { ReplyContext } from '../entities/context/replyContext';
|
|
9
|
-
import { IAction, IActionWithState } from './action';
|
|
10
|
-
import { IActionState } from './actionState';
|
|
11
|
-
import { BotInfo } from './externalAliases';
|
|
12
|
-
import { BotResponse } from './response';
|
|
13
|
-
import { Milliseconds } from './timeValues';
|
|
14
|
-
import { TraceId } from './trace';
|
|
15
|
-
|
|
16
|
-
export const BotEventType = {
|
|
17
|
-
error: 'error.generic',
|
|
18
|
-
|
|
19
|
-
messageRecieved: 'message.recieved',
|
|
20
|
-
messageProcessingStarted: 'message.processingStarted',
|
|
21
|
-
messageProcessingFinished: 'message.processingFinished',
|
|
22
|
-
beforeActionsExecuting: 'message.beforeActionsExecuting',
|
|
23
|
-
|
|
24
|
-
commandActionExecuting: 'command.actionExecuting',
|
|
25
|
-
commandActionExecuted: 'command.actionExecuted',
|
|
26
|
-
commandActionCaptureStarted: 'command.captionStarted',
|
|
27
|
-
commandActionCaptureAborted: 'command.captionAborted',
|
|
28
|
-
|
|
29
|
-
replyActionExecuting: 'reply.actionExecuting',
|
|
30
|
-
replyActionExecuted: 'reply.actionExecuted',
|
|
31
|
-
|
|
32
|
-
inlineProcessingStarted: 'inline.processingStarted',
|
|
33
|
-
inlineProcessingFinished: 'inline.processingFinished',
|
|
34
|
-
inlineQueryRecieved: 'inline.queryRecieved',
|
|
35
|
-
inlineActionExecuting: 'inline.actionExecuting',
|
|
36
|
-
inlineActionExecuted: 'inline.actionExecuted',
|
|
37
|
-
inlineProcessingAborting: 'inline.processingAborting',
|
|
38
|
-
inlineProcessingAborted: 'inline.processingAborted',
|
|
39
|
-
|
|
40
|
-
scheduledProcessingStarted: 'scheduled.processingStarted',
|
|
41
|
-
scheduledProcessingFinished: 'scheduled.processingFinished',
|
|
42
|
-
scheduledActionExecuting: 'scheduled.actionExecuting',
|
|
43
|
-
scheduledActionExecuted: 'scheduled.actionExecuted',
|
|
44
|
-
scheduledActionCacheValueReturned: 'scheduled.cachedValueReturned',
|
|
45
|
-
scheduledActionCacheValueCreating: 'scheduled.cachedValueCreating',
|
|
46
|
-
|
|
47
|
-
apiRequestSending: 'api.requestSending',
|
|
48
|
-
apiRequestSent: 'api.requestSent',
|
|
49
|
-
|
|
50
|
-
taskCreated: 'task.created',
|
|
51
|
-
taskRun: 'task.run',
|
|
52
|
-
|
|
53
|
-
botStarting: 'bot.starting',
|
|
54
|
-
botStopping: 'bot.stopping'
|
|
55
|
-
} as const;
|
|
56
|
-
|
|
57
|
-
type BotEventTypeKeys = (typeof BotEventType)[keyof typeof BotEventType];
|
|
58
|
-
// Exhaustiveness validation
|
|
59
|
-
const _checkBotEventMapExhaustive: Record<BotEventTypeKeys, unknown> =
|
|
60
|
-
null as unknown as BotEventMap;
|
|
61
|
-
|
|
62
|
-
export type BotEventMap = {
|
|
63
|
-
[BotEventType.error]: {
|
|
64
|
-
error: Error;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
[BotEventType.messageRecieved]: {
|
|
68
|
-
botInfo: BotInfo;
|
|
69
|
-
message: IncomingMessage;
|
|
70
|
-
};
|
|
71
|
-
[BotEventType.messageProcessingStarted]: {
|
|
72
|
-
botInfo: BotInfo;
|
|
73
|
-
message: IncomingMessage;
|
|
74
|
-
};
|
|
75
|
-
[BotEventType.messageProcessingFinished]: {
|
|
76
|
-
botInfo: BotInfo;
|
|
77
|
-
message: IncomingMessage;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
[BotEventType.beforeActionsExecuting]: {
|
|
81
|
-
botInfo: BotInfo;
|
|
82
|
-
message: IncomingMessage;
|
|
83
|
-
commands: Set<CommandAction<IActionState>>;
|
|
84
|
-
};
|
|
85
|
-
[BotEventType.commandActionExecuting]: {
|
|
86
|
-
action: IActionWithState<IActionState>;
|
|
87
|
-
ctx: MessageContext<IActionState>;
|
|
88
|
-
state: IActionState;
|
|
89
|
-
};
|
|
90
|
-
[BotEventType.commandActionExecuted]: {
|
|
91
|
-
action: IActionWithState<IActionState>;
|
|
92
|
-
ctx: MessageContext<IActionState>;
|
|
93
|
-
state: IActionState;
|
|
94
|
-
};
|
|
95
|
-
[BotEventType.commandActionCaptureStarted]: {
|
|
96
|
-
parentMessageId: number;
|
|
97
|
-
chatInfo: ChatInfo;
|
|
98
|
-
};
|
|
99
|
-
[BotEventType.commandActionCaptureAborted]: {
|
|
100
|
-
parentMessageId: number;
|
|
101
|
-
chatInfo: ChatInfo;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
[BotEventType.replyActionExecuting]: {
|
|
105
|
-
action: IAction;
|
|
106
|
-
ctx: ReplyContext<IActionState>;
|
|
107
|
-
};
|
|
108
|
-
[BotEventType.replyActionExecuted]: {
|
|
109
|
-
action: IAction;
|
|
110
|
-
ctx: ReplyContext<IActionState>;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
[BotEventType.inlineProcessingStarted]: {
|
|
114
|
-
botName: string;
|
|
115
|
-
};
|
|
116
|
-
[BotEventType.inlineProcessingFinished]: {
|
|
117
|
-
botName: string;
|
|
118
|
-
};
|
|
119
|
-
[BotEventType.inlineActionExecuting]: {
|
|
120
|
-
action: IAction;
|
|
121
|
-
ctx: InlineQueryContext;
|
|
122
|
-
};
|
|
123
|
-
[BotEventType.inlineActionExecuted]: {
|
|
124
|
-
action: IAction;
|
|
125
|
-
ctx: InlineQueryContext;
|
|
126
|
-
};
|
|
127
|
-
[BotEventType.inlineProcessingAborting]: {
|
|
128
|
-
abortedQuery: IncomingInlineQuery;
|
|
129
|
-
newQuery: IncomingInlineQuery;
|
|
130
|
-
};
|
|
131
|
-
[BotEventType.inlineProcessingAborted]: {
|
|
132
|
-
abortedQuery: IncomingInlineQuery;
|
|
133
|
-
};
|
|
134
|
-
[BotEventType.inlineQueryRecieved]: {
|
|
135
|
-
query: IncomingInlineQuery;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
[BotEventType.scheduledProcessingStarted]: {
|
|
139
|
-
botName: string;
|
|
140
|
-
};
|
|
141
|
-
[BotEventType.scheduledProcessingFinished]: { botName: string };
|
|
142
|
-
[BotEventType.scheduledActionExecuting]: {
|
|
143
|
-
action: IAction;
|
|
144
|
-
ctx: ChatContext<IActionState>;
|
|
145
|
-
state: IActionState;
|
|
146
|
-
};
|
|
147
|
-
[BotEventType.scheduledActionExecuted]: {
|
|
148
|
-
action: IAction;
|
|
149
|
-
ctx: ChatContext<IActionState>;
|
|
150
|
-
state: IActionState;
|
|
151
|
-
};
|
|
152
|
-
[BotEventType.scheduledActionCacheValueCreating]: {
|
|
153
|
-
action: IAction;
|
|
154
|
-
ctx: ChatContext<IActionState>;
|
|
155
|
-
key: string;
|
|
156
|
-
};
|
|
157
|
-
[BotEventType.scheduledActionCacheValueReturned]: {
|
|
158
|
-
action: IAction;
|
|
159
|
-
ctx: ChatContext<IActionState>;
|
|
160
|
-
key: string;
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
[BotEventType.apiRequestSending]: {
|
|
164
|
-
response: BotResponse | null;
|
|
165
|
-
telegramMethod: string | null;
|
|
166
|
-
};
|
|
167
|
-
[BotEventType.apiRequestSent]: {
|
|
168
|
-
response: BotResponse | null;
|
|
169
|
-
telegramMethod: string | null;
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
[BotEventType.taskCreated]: {
|
|
173
|
-
name: string;
|
|
174
|
-
ownerName: string;
|
|
175
|
-
delay?: Milliseconds;
|
|
176
|
-
interval?: Milliseconds;
|
|
177
|
-
};
|
|
178
|
-
[BotEventType.taskRun]: {
|
|
179
|
-
name: string;
|
|
180
|
-
ownerName: string;
|
|
181
|
-
delay?: Milliseconds;
|
|
182
|
-
interval?: Milliseconds;
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
[BotEventType.botStarting]: {
|
|
186
|
-
botName: string;
|
|
187
|
-
};
|
|
188
|
-
[BotEventType.botStopping]: {
|
|
189
|
-
botName: string;
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
type FullEventMap<TCustom extends Record<string, unknown>> = BotEventMap &
|
|
194
|
-
TCustom;
|
|
195
|
-
|
|
196
|
-
type ListenerArgs<
|
|
197
|
-
TMap extends Record<string, unknown>,
|
|
198
|
-
K extends keyof TMap
|
|
199
|
-
> = TMap[K] extends undefined
|
|
200
|
-
? []
|
|
201
|
-
: [
|
|
202
|
-
{
|
|
203
|
-
traceId: TraceId;
|
|
204
|
-
} & TMap[K]
|
|
205
|
-
];
|
|
206
|
-
|
|
207
|
-
export type Listener<
|
|
208
|
-
TMap extends Record<string, unknown>,
|
|
209
|
-
K extends keyof TMap
|
|
210
|
-
> = (timestamp: number, ...args: ListenerArgs<TMap, K>) => void;
|
|
211
|
-
|
|
212
|
-
export type EachListener<TMap extends Record<string, unknown> = BotEventMap> = (
|
|
213
|
-
event: keyof TMap & string,
|
|
214
|
-
timestamp: number,
|
|
215
|
-
data: unknown
|
|
216
|
-
) => void;
|
|
217
|
-
|
|
218
|
-
export class TypedEventEmitter<
|
|
219
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
220
|
-
TCustomEvents extends Record<string, unknown> = {}
|
|
221
|
-
> {
|
|
222
|
-
private readonly listeners = new Map<
|
|
223
|
-
keyof FullEventMap<TCustomEvents> | '*',
|
|
224
|
-
Set<
|
|
225
|
-
| Listener<
|
|
226
|
-
FullEventMap<TCustomEvents>,
|
|
227
|
-
keyof FullEventMap<TCustomEvents>
|
|
228
|
-
>
|
|
229
|
-
| EachListener<FullEventMap<TCustomEvents>>
|
|
230
|
-
>
|
|
231
|
-
>();
|
|
232
|
-
|
|
233
|
-
on<K extends keyof FullEventMap<TCustomEvents>>(
|
|
234
|
-
event: K,
|
|
235
|
-
fn: Listener<FullEventMap<TCustomEvents>, K>
|
|
236
|
-
) {
|
|
237
|
-
const set = this.listeners.get(event) ?? new Set();
|
|
238
|
-
set.add(
|
|
239
|
-
fn as Listener<
|
|
240
|
-
FullEventMap<TCustomEvents>,
|
|
241
|
-
keyof FullEventMap<TCustomEvents>
|
|
242
|
-
>
|
|
243
|
-
);
|
|
244
|
-
this.listeners.set(event, set);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
onEach(fn: EachListener<FullEventMap<TCustomEvents>>) {
|
|
248
|
-
const event = '*';
|
|
249
|
-
const set = this.listeners.get(event) ?? new Set();
|
|
250
|
-
set.add(fn);
|
|
251
|
-
this.listeners.set(event, set);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
emit<K extends keyof FullEventMap<TCustomEvents>>(
|
|
255
|
-
event: K,
|
|
256
|
-
...args: ListenerArgs<FullEventMap<TCustomEvents>, K>
|
|
257
|
-
): void {
|
|
258
|
-
const timestamp = Date.now();
|
|
259
|
-
const specific = this.listeners.get(event);
|
|
260
|
-
if (specific) {
|
|
261
|
-
for (const fn of specific) {
|
|
262
|
-
(fn as Listener<FullEventMap<TCustomEvents>, K>)(
|
|
263
|
-
timestamp,
|
|
264
|
-
...args
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
const anySet = this.listeners.get('*');
|
|
270
|
-
if (anySet) {
|
|
271
|
-
for (const fn of anySet) {
|
|
272
|
-
(
|
|
273
|
-
fn as unknown as (
|
|
274
|
-
e: K,
|
|
275
|
-
t: number,
|
|
276
|
-
...a: ListenerArgs<FullEventMap<TCustomEvents>, K>
|
|
277
|
-
) => void
|
|
278
|
-
)(event, timestamp, ...args);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
events(): (keyof FullEventMap<TCustomEvents> | '*')[] {
|
|
284
|
-
return [...this.listeners.keys()];
|
|
285
|
-
}
|
|
286
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Telegram, Telegraf } from 'telegraf';
|
|
2
|
-
import {
|
|
3
|
-
User,
|
|
4
|
-
Message,
|
|
5
|
-
InlineQueryResult,
|
|
6
|
-
UserFromGetMe,
|
|
7
|
-
TelegramEmoji as Emoji,
|
|
8
|
-
InlineKeyboardButton
|
|
9
|
-
} from 'telegraf/types';
|
|
10
|
-
|
|
11
|
-
export type TelegramUser = User;
|
|
12
|
-
export type TelegramMessage = Message;
|
|
13
|
-
export type TelegramInlineQueryResult = InlineQueryResult;
|
|
14
|
-
export type TelegramEmoji = Emoji;
|
|
15
|
-
export type TelegramApiClient = Telegram;
|
|
16
|
-
export type BotInfo = UserFromGetMe;
|
|
17
|
-
export type TelegramBot = Telegraf;
|
|
18
|
-
export type TelegramInlineKeyboardButton = InlineKeyboardButton;
|
package/src/types/handlers.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ChatContext } from '../entities/context/chatContext';
|
|
2
|
-
import { InlineQueryContext } from '../entities/context/inlineQueryContext';
|
|
3
|
-
import { MessageContext } from '../entities/context/messageContext';
|
|
4
|
-
import { IActionState } from './actionState';
|
|
5
|
-
import { CachedValueAccessor } from './cachedValueAccessor';
|
|
6
|
-
|
|
7
|
-
export type InlineQueryHandler = (
|
|
8
|
-
/** Context of inline query executed in chat, in response to a message. */
|
|
9
|
-
ctx: InlineQueryContext
|
|
10
|
-
) => Promise<void>;
|
|
11
|
-
|
|
12
|
-
export type CommandHandler<TActionState extends IActionState> = (
|
|
13
|
-
/** Context of action executed in chat, in response to a message. */
|
|
14
|
-
ctx: MessageContext<TActionState>,
|
|
15
|
-
/** State of an action being executed. */
|
|
16
|
-
state: TActionState
|
|
17
|
-
) => Promise<void> | void;
|
|
18
|
-
|
|
19
|
-
export type ScheduledHandler<TActionState extends IActionState> = (
|
|
20
|
-
/** Context of action executed in chat. */
|
|
21
|
-
ctx: ChatContext<TActionState>,
|
|
22
|
-
/** Function that will attempt to get value from cache. If there is no value found, corresponding cached state factory will be called. */
|
|
23
|
-
getCached: CachedValueAccessor,
|
|
24
|
-
/** State of an action being executed. */
|
|
25
|
-
state: TActionState
|
|
26
|
-
) => Promise<void>;
|
package/src/types/inputFile.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { TelegramInlineKeyboardButton } from './externalAliases';
|
|
2
|
-
|
|
3
|
-
export interface MessageSendingOptions {
|
|
4
|
-
pin?: boolean;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface TextMessageSendingOptions extends MessageSendingOptions {
|
|
8
|
-
disableWebPreview?: boolean;
|
|
9
|
-
keyboard?: TelegramInlineKeyboardButton[][];
|
|
10
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export const INTERNAL_MESSAGE_TYPE_PREFIX = `__msg:`;
|
|
2
|
-
|
|
3
|
-
export const MessageType = {
|
|
4
|
-
Any: `${INTERNAL_MESSAGE_TYPE_PREFIX}Any`,
|
|
5
|
-
Text: `${INTERNAL_MESSAGE_TYPE_PREFIX}Text`,
|
|
6
|
-
Sticker: `${INTERNAL_MESSAGE_TYPE_PREFIX}Sticker`,
|
|
7
|
-
Animation: `${INTERNAL_MESSAGE_TYPE_PREFIX}Animation`,
|
|
8
|
-
Document: `${INTERNAL_MESSAGE_TYPE_PREFIX}Document`,
|
|
9
|
-
Voice: `${INTERNAL_MESSAGE_TYPE_PREFIX}Voice`,
|
|
10
|
-
Audio: `${INTERNAL_MESSAGE_TYPE_PREFIX}Audio`,
|
|
11
|
-
LeftChatMember: `${INTERNAL_MESSAGE_TYPE_PREFIX}LeftChatMember`,
|
|
12
|
-
NewChatMember: `${INTERNAL_MESSAGE_TYPE_PREFIX}NewChatMember`,
|
|
13
|
-
Poll: `${INTERNAL_MESSAGE_TYPE_PREFIX}Poll`,
|
|
14
|
-
Location: `${INTERNAL_MESSAGE_TYPE_PREFIX}Location`,
|
|
15
|
-
Photo: `${INTERNAL_MESSAGE_TYPE_PREFIX}Photo`,
|
|
16
|
-
Forward: `${INTERNAL_MESSAGE_TYPE_PREFIX}Forward`,
|
|
17
|
-
Video: `${INTERNAL_MESSAGE_TYPE_PREFIX}Video`,
|
|
18
|
-
Unknown: `${INTERNAL_MESSAGE_TYPE_PREFIX}Unknown`
|
|
19
|
-
} as const;
|
|
20
|
-
|
|
21
|
-
export type MessageTypeValue = (typeof MessageType)[keyof typeof MessageType];
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ChatContext } from '../entities/context/chatContext';
|
|
2
|
-
import { InlineQueryContext } from '../entities/context/inlineQueryContext';
|
|
3
|
-
import { MessageContext } from '../entities/context/messageContext';
|
|
4
|
-
import { IActionState } from './actionState';
|
|
5
|
-
|
|
6
|
-
export type CommandActionPropertyProvider<T> = (
|
|
7
|
-
ctx: MessageContext<IActionState>
|
|
8
|
-
) => T;
|
|
9
|
-
|
|
10
|
-
export type InlineActionPropertyProvider<T> = (ctx: InlineQueryContext) => T;
|
|
11
|
-
|
|
12
|
-
export type ScheduledActionPropertyProvider<T> = (
|
|
13
|
-
ctx: ChatContext<IActionState>
|
|
14
|
-
) => T;
|
package/src/types/response.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { ChatInfo } from '../dtos/chatInfo';
|
|
2
|
-
import { DelayResponse } from '../dtos/responses/delay';
|
|
3
|
-
import { ImageMessage } from '../dtos/responses/imageMessage';
|
|
4
|
-
import { InlineQueryResponse } from '../dtos/responses/inlineQueryResponse';
|
|
5
|
-
import { Reaction } from '../dtos/responses/reaction';
|
|
6
|
-
import { TextMessage } from '../dtos/responses/textMessage';
|
|
7
|
-
import { UnpinResponse } from '../dtos/responses/unpin';
|
|
8
|
-
import { VideoMessage } from '../dtos/responses/videoMessage';
|
|
9
|
-
import { IReplyCapture } from './capture';
|
|
10
|
-
import { ReplyInfo } from '../dtos/replyInfo';
|
|
11
|
-
import { TraceId } from './trace';
|
|
12
|
-
import { IAction } from './action';
|
|
13
|
-
|
|
14
|
-
export const BotResponseTypes = {
|
|
15
|
-
unpin: 'unpin',
|
|
16
|
-
text: 'text',
|
|
17
|
-
image: 'image',
|
|
18
|
-
video: 'video',
|
|
19
|
-
react: 'react',
|
|
20
|
-
delay: 'delay',
|
|
21
|
-
inlineQuery: 'inlineQuery'
|
|
22
|
-
} as const;
|
|
23
|
-
|
|
24
|
-
export type BotResponse =
|
|
25
|
-
| UnpinResponse
|
|
26
|
-
| Reaction
|
|
27
|
-
| TextMessage
|
|
28
|
-
| VideoMessage
|
|
29
|
-
| DelayResponse
|
|
30
|
-
| InlineQueryResponse
|
|
31
|
-
| ImageMessage;
|
|
32
|
-
|
|
33
|
-
export interface IChatResponse {
|
|
34
|
-
readonly kind: keyof typeof BotResponseTypes;
|
|
35
|
-
readonly chatInfo: ChatInfo;
|
|
36
|
-
readonly traceId: TraceId;
|
|
37
|
-
readonly createdAt: number;
|
|
38
|
-
|
|
39
|
-
readonly action: IAction;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface IReplyResponse extends IChatResponse {
|
|
43
|
-
readonly captures: IReplyCapture[];
|
|
44
|
-
readonly replyInfo: ReplyInfo | undefined;
|
|
45
|
-
readonly disableWebPreview: boolean;
|
|
46
|
-
readonly shouldPin: boolean;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface IReplyResponseWithContent<TType> extends IReplyResponse {
|
|
50
|
-
readonly content: TType;
|
|
51
|
-
}
|
package/src/types/scheduler.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Milliseconds } from './timeValues';
|
|
2
|
-
|
|
3
|
-
export interface IScheduler {
|
|
4
|
-
stopAll(): void;
|
|
5
|
-
|
|
6
|
-
createTask(
|
|
7
|
-
name: string,
|
|
8
|
-
action: () => unknown,
|
|
9
|
-
interval: Milliseconds,
|
|
10
|
-
executeRightAway: boolean,
|
|
11
|
-
ownerName: string
|
|
12
|
-
): void;
|
|
13
|
-
|
|
14
|
-
createOnetimeTask(
|
|
15
|
-
name: string,
|
|
16
|
-
action: () => unknown,
|
|
17
|
-
delay: Milliseconds,
|
|
18
|
-
ownerName: string
|
|
19
|
-
): void;
|
|
20
|
-
}
|
package/src/types/storage.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { IActionState } from './actionState';
|
|
2
|
-
import { IActionWithState } from './action';
|
|
3
|
-
|
|
4
|
-
export interface IStorageClient {
|
|
5
|
-
updateStateFor<TActionState extends IActionState>(
|
|
6
|
-
action: IActionWithState<TActionState>,
|
|
7
|
-
chatId: number,
|
|
8
|
-
update: (state: TActionState) => Promise<void> | void
|
|
9
|
-
): Promise<void>;
|
|
10
|
-
close(): Promise<void>;
|
|
11
|
-
load<TActionState extends IActionState>(
|
|
12
|
-
action: IActionWithState<TActionState>
|
|
13
|
-
): Record<number, TActionState>;
|
|
14
|
-
getActionState<TActionState extends IActionState>(
|
|
15
|
-
action: IActionWithState<TActionState>,
|
|
16
|
-
chatId: number
|
|
17
|
-
): TActionState;
|
|
18
|
-
saveActionExecutionResult<TActionState extends IActionState>(
|
|
19
|
-
action: IActionWithState<TActionState>,
|
|
20
|
-
chatId: number,
|
|
21
|
-
state: TActionState
|
|
22
|
-
): Promise<void>;
|
|
23
|
-
}
|
package/src/types/timeValues.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
declare const millisecondsSymbol: unique symbol;
|
|
2
|
-
declare const secondsSymbol: unique symbol;
|
|
3
|
-
declare const hoursSymbol: unique symbol;
|
|
4
|
-
|
|
5
|
-
export type Milliseconds = number & { [millisecondsSymbol]: never };
|
|
6
|
-
export type Seconds = number & { [secondsSymbol]: never };
|
|
7
|
-
export type Hours = number & { [hoursSymbol]: never };
|
|
8
|
-
|
|
9
|
-
export type HoursOfDay =
|
|
10
|
-
| 0
|
|
11
|
-
| 1
|
|
12
|
-
| 2
|
|
13
|
-
| 3
|
|
14
|
-
| 4
|
|
15
|
-
| 5
|
|
16
|
-
| 6
|
|
17
|
-
| 7
|
|
18
|
-
| 8
|
|
19
|
-
| 9
|
|
20
|
-
| 10
|
|
21
|
-
| 11
|
|
22
|
-
| 12
|
|
23
|
-
| 13
|
|
24
|
-
| 14
|
|
25
|
-
| 15
|
|
26
|
-
| 16
|
|
27
|
-
| 17
|
|
28
|
-
| 18
|
|
29
|
-
| 19
|
|
30
|
-
| 20
|
|
31
|
-
| 21
|
|
32
|
-
| 22
|
|
33
|
-
| 23;
|