chz-telegram-bot 0.5.4 → 0.6.8
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 +41 -31
- package/dist/builtin/helpAction.d.ts +2 -0
- package/dist/builtin/helpAction.d.ts.map +1 -0
- package/dist/builtin/helpAction.js +14 -0
- package/dist/dtos/chatHistoryMessage.d.ts +35 -0
- package/dist/dtos/chatHistoryMessage.d.ts.map +1 -0
- package/dist/dtos/chatHistoryMessage.js +32 -0
- package/dist/dtos/chatInfo.d.ts +17 -0
- package/dist/dtos/chatInfo.d.ts.map +1 -0
- package/dist/dtos/chatInfo.js +16 -0
- package/dist/dtos/commandTriggerCheckResult.d.ts +24 -0
- package/dist/dtos/commandTriggerCheckResult.d.ts.map +1 -0
- package/dist/dtos/commandTriggerCheckResult.js +34 -0
- package/dist/dtos/cooldownInfo.d.ts +13 -0
- package/dist/dtos/cooldownInfo.d.ts.map +1 -0
- package/dist/dtos/cooldownInfo.js +12 -0
- package/dist/dtos/incomingMessage.d.ts +19 -0
- package/dist/dtos/incomingMessage.d.ts.map +1 -0
- package/dist/dtos/incomingMessage.js +63 -0
- package/dist/dtos/incomingQuery.d.ts +10 -0
- package/dist/dtos/incomingQuery.d.ts.map +1 -0
- package/dist/dtos/incomingQuery.js +14 -0
- package/dist/dtos/messageInfo.d.ts +22 -0
- package/dist/dtos/messageInfo.d.ts.map +1 -0
- package/dist/dtos/messageInfo.js +20 -0
- package/dist/dtos/propertyProviderSets.d.ts +16 -0
- package/dist/dtos/propertyProviderSets.d.ts.map +1 -0
- package/dist/dtos/propertyProviderSets.js +1 -0
- package/dist/dtos/replyInfo.d.ts +6 -0
- package/dist/dtos/replyInfo.d.ts.map +1 -0
- package/dist/dtos/replyInfo.js +8 -0
- package/dist/dtos/responses/delay.d.ts +16 -0
- package/dist/dtos/responses/delay.d.ts.map +1 -0
- package/dist/dtos/responses/delay.js +15 -0
- package/dist/dtos/responses/imageMessage.d.ts +22 -0
- package/dist/dtos/responses/imageMessage.d.ts.map +1 -0
- package/dist/dtos/responses/imageMessage.js +21 -0
- package/dist/dtos/responses/inlineQueryResponse.d.ts +13 -0
- package/dist/dtos/responses/inlineQueryResponse.d.ts.map +1 -0
- package/dist/dtos/responses/inlineQueryResponse.js +15 -0
- package/dist/dtos/responses/reaction.d.ts +16 -0
- package/dist/dtos/responses/reaction.d.ts.map +1 -0
- package/dist/dtos/responses/reaction.js +17 -0
- package/dist/dtos/responses/textMessage.d.ts +23 -0
- package/dist/dtos/responses/textMessage.d.ts.map +1 -0
- package/dist/dtos/responses/textMessage.js +24 -0
- package/dist/dtos/responses/unpin.d.ts +15 -0
- package/dist/dtos/responses/unpin.d.ts.map +1 -0
- package/dist/dtos/responses/unpin.js +15 -0
- package/dist/dtos/responses/videoMessage.d.ts +22 -0
- package/dist/dtos/responses/videoMessage.d.ts.map +1 -0
- package/dist/dtos/responses/videoMessage.js +21 -0
- package/dist/dtos/userInfo.d.ts +12 -0
- package/dist/dtos/userInfo.d.ts.map +1 -0
- package/dist/dtos/userInfo.js +12 -0
- package/dist/entities/actions/commandAction.d.ts +31 -0
- package/dist/entities/actions/commandAction.d.ts.map +1 -0
- package/dist/entities/actions/commandAction.js +149 -0
- package/dist/entities/actions/inlineQueryAction.d.ts +14 -0
- package/dist/entities/actions/inlineQueryAction.d.ts.map +1 -0
- package/dist/entities/actions/inlineQueryAction.js +51 -0
- package/dist/entities/actions/replyCaptureAction.d.ts +15 -0
- package/dist/entities/actions/replyCaptureAction.d.ts.map +1 -0
- package/dist/entities/actions/replyCaptureAction.js +66 -0
- package/dist/entities/actions/scheduledAction.d.ts +24 -0
- package/dist/entities/actions/scheduledAction.d.ts.map +1 -0
- package/dist/entities/actions/scheduledAction.js +92 -0
- package/dist/entities/botInstance.d.ts +36 -0
- package/dist/entities/botInstance.d.ts.map +1 -0
- package/dist/entities/botInstance.js +39 -0
- package/dist/entities/cachedStateFactory.d.ts +7 -0
- package/dist/entities/cachedStateFactory.d.ts.map +1 -0
- package/dist/entities/cachedStateFactory.js +8 -0
- package/dist/entities/context/baseContext.d.ts +39 -0
- package/dist/entities/context/baseContext.d.ts.map +1 -0
- package/dist/entities/context/baseContext.js +56 -0
- package/dist/entities/context/chatContext.d.ts +50 -0
- package/dist/entities/context/chatContext.d.ts.map +1 -0
- package/dist/entities/context/chatContext.js +65 -0
- package/dist/entities/context/inlineQueryContext.d.ts +27 -0
- package/dist/entities/context/inlineQueryContext.d.ts.map +1 -0
- package/dist/entities/context/inlineQueryContext.js +29 -0
- package/dist/entities/context/messageContext.d.ts +92 -0
- package/dist/entities/context/messageContext.d.ts.map +1 -0
- package/dist/entities/context/messageContext.js +116 -0
- package/dist/entities/context/replyContext.d.ts +89 -0
- package/dist/entities/context/replyContext.d.ts.map +1 -0
- package/dist/entities/context/replyContext.js +124 -0
- package/dist/entities/states/actionStateBase.d.ts +6 -0
- package/dist/entities/states/actionStateBase.d.ts.map +1 -0
- package/dist/entities/states/actionStateBase.js +4 -0
- package/dist/entities/taskRecord.d.ts +8 -0
- package/dist/entities/taskRecord.d.ts.map +1 -0
- package/dist/entities/taskRecord.js +10 -0
- package/dist/eslint.config.d.ts +3 -0
- package/dist/eslint.config.d.ts.map +1 -0
- package/dist/eslint.config.js +51 -0
- package/dist/helpers/builders/commandActionBuilder.d.ts +100 -0
- package/dist/helpers/builders/commandActionBuilder.d.ts.map +1 -0
- package/dist/helpers/builders/commandActionBuilder.js +146 -0
- package/dist/helpers/builders/inlineQueryActionBuilder.d.ts +37 -0
- package/dist/helpers/builders/inlineQueryActionBuilder.d.ts.map +1 -0
- package/dist/helpers/builders/inlineQueryActionBuilder.js +50 -0
- package/dist/helpers/builders/scheduledActionBuilder.d.ts +68 -0
- package/dist/helpers/builders/scheduledActionBuilder.d.ts.map +1 -0
- package/dist/helpers/builders/scheduledActionBuilder.js +95 -0
- package/dist/helpers/mapUtils.d.ts +10 -0
- package/dist/helpers/mapUtils.d.ts.map +1 -0
- package/dist/helpers/mapUtils.js +13 -0
- package/dist/helpers/noop.d.ts +9 -0
- package/dist/helpers/noop.d.ts.map +1 -0
- package/dist/helpers/noop.js +17 -0
- package/dist/helpers/objectFromEntries.d.ts +2 -0
- package/dist/helpers/objectFromEntries.d.ts.map +1 -0
- package/dist/helpers/objectFromEntries.js +3 -0
- package/dist/helpers/timeConvertions.d.ts +5 -0
- package/dist/helpers/timeConvertions.d.ts.map +1 -0
- package/dist/helpers/timeConvertions.js +9 -0
- package/dist/helpers/toArray.d.ts +2 -0
- package/dist/helpers/toArray.d.ts.map +1 -0
- package/dist/helpers/toArray.js +3 -0
- package/dist/helpers/traceFactory.d.ts +3 -0
- package/dist/helpers/traceFactory.d.ts.map +1 -0
- package/dist/helpers/traceFactory.js +3 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/main.d.ts +49 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +33 -0
- package/dist/services/actionProcessingService.d.ts +25 -0
- package/dist/services/actionProcessingService.d.ts.map +1 -0
- package/dist/services/actionProcessingService.js +50 -0
- package/dist/services/actionProcessors/baseProcessor.d.ts +18 -0
- package/dist/services/actionProcessors/baseProcessor.d.ts.map +1 -0
- package/dist/services/actionProcessors/baseProcessor.js +33 -0
- package/dist/services/actionProcessors/commandActionProcessor.d.ts +19 -0
- package/dist/services/actionProcessors/commandActionProcessor.d.ts.map +1 -0
- package/dist/services/actionProcessors/commandActionProcessor.js +130 -0
- package/dist/services/actionProcessors/inlineQueryActionProcessor.d.ts +11 -0
- package/dist/services/actionProcessors/inlineQueryActionProcessor.d.ts.map +1 -0
- package/dist/services/actionProcessors/inlineQueryActionProcessor.js +69 -0
- package/dist/services/actionProcessors/scheduledActionProcessor.d.ts +17 -0
- package/dist/services/actionProcessors/scheduledActionProcessor.d.ts.map +1 -0
- package/dist/services/actionProcessors/scheduledActionProcessor.js +55 -0
- package/dist/services/jsonFileStorage.d.ts +25 -0
- package/dist/services/jsonFileStorage.d.ts.map +1 -0
- package/dist/services/jsonFileStorage.js +133 -0
- package/dist/services/nodeTimeoutScheduler.d.ts +13 -0
- package/dist/services/nodeTimeoutScheduler.d.ts.map +1 -0
- package/dist/services/nodeTimeoutScheduler.js +50 -0
- package/dist/services/responseProcessingQueue.d.ts +12 -0
- package/dist/services/responseProcessingQueue.d.ts.map +1 -0
- package/dist/services/responseProcessingQueue.js +37 -0
- package/dist/services/telegramApi.d.ts +23 -0
- package/dist/services/telegramApi.d.ts.map +1 -0
- package/dist/services/telegramApi.js +163 -0
- package/dist/types/action.d.ts +14 -0
- package/dist/types/action.d.ts.map +1 -0
- package/dist/types/action.js +1 -0
- package/dist/types/actionState.d.ts +5 -0
- package/dist/types/actionState.d.ts.map +1 -0
- package/dist/types/actionState.js +1 -0
- package/dist/types/cachedValueAccessor.d.ts +2 -0
- package/dist/types/cachedValueAccessor.d.ts.map +1 -0
- package/dist/types/cachedValueAccessor.js +1 -0
- package/dist/types/capture.d.ts +24 -0
- package/dist/types/capture.d.ts.map +1 -0
- package/dist/types/capture.js +1 -0
- package/dist/types/commandCondition.d.ts +8 -0
- package/dist/types/commandCondition.d.ts.map +1 -0
- package/dist/types/commandCondition.js +1 -0
- package/dist/types/commandTrigger.d.ts +2 -0
- package/dist/types/commandTrigger.d.ts.map +1 -0
- package/dist/types/commandTrigger.js +1 -0
- package/dist/types/events.d.ts +193 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +69 -0
- package/dist/types/externalAliases.d.ts +11 -0
- package/dist/types/externalAliases.d.ts.map +1 -0
- package/dist/types/externalAliases.js +1 -0
- package/dist/types/handlers.d.ts +21 -0
- package/dist/types/handlers.d.ts.map +1 -0
- package/dist/types/handlers.js +1 -0
- package/dist/types/inputFile.d.ts +5 -0
- package/dist/types/inputFile.d.ts.map +1 -0
- package/dist/types/inputFile.js +1 -0
- package/dist/types/logger.d.ts +1 -0
- package/dist/types/logger.d.ts.map +1 -0
- package/dist/types/logger.js +1 -0
- package/dist/types/messageSendingOptions.d.ts +9 -0
- package/dist/types/messageSendingOptions.d.ts.map +1 -0
- package/dist/types/messageSendingOptions.js +1 -0
- package/dist/types/messageTypes.d.ts +20 -0
- package/dist/types/messageTypes.d.ts.map +1 -0
- package/dist/types/messageTypes.js +18 -0
- package/dist/types/propertyProvider.d.ts +8 -0
- package/dist/types/propertyProvider.d.ts.map +1 -0
- package/dist/types/propertyProvider.js +1 -0
- package/dist/types/response.d.ts +39 -0
- package/dist/types/response.d.ts.map +1 -0
- package/dist/types/response.js +9 -0
- package/dist/types/scheduler.d.ts +7 -0
- package/dist/types/scheduler.d.ts.map +1 -0
- package/dist/types/scheduler.js +1 -0
- package/dist/types/storage.d.ts +11 -0
- package/dist/types/storage.d.ts.map +1 -0
- package/dist/types/storage.js +1 -0
- package/dist/types/timeValues.d.ts +15 -0
- package/dist/types/timeValues.d.ts.map +1 -0
- package/dist/types/timeValues.js +1 -0
- package/dist/types/trace.d.ts +6 -0
- package/dist/types/trace.d.ts.map +1 -0
- package/dist/types/trace.js +1 -0
- package/entities/actions/commandAction.ts +11 -3
- package/entities/actions/inlineQueryAction.ts +9 -1
- package/entities/actions/replyCaptureAction.ts +9 -3
- package/entities/actions/scheduledAction.ts +31 -10
- package/entities/botInstance.ts +18 -25
- package/entities/context/baseContext.ts +9 -4
- package/index.ts +1 -1
- package/main.ts +1 -10
- package/package.json +38 -38
- package/services/actionProcessingService.ts +11 -15
- package/services/actionProcessors/baseProcessor.ts +9 -9
- package/services/actionProcessors/commandActionProcessor.ts +35 -46
- package/services/actionProcessors/inlineQueryActionProcessor.ts +24 -20
- package/services/actionProcessors/scheduledActionProcessor.ts +5 -10
- package/services/jsonFileStorage.ts +27 -1
- package/services/nodeTimeoutScheduler.ts +22 -22
- package/services/telegramApi.ts +53 -23
- package/types/events.ts +285 -0
- package/services/jsonLogger.ts +0 -112
- package/types/logger.ts +0 -39
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { CommandAction } from '../../entities/actions/commandAction';
|
|
2
|
+
import { ActionStateBase } from '../../entities/states/actionStateBase';
|
|
3
|
+
import { toArray } from '../toArray';
|
|
4
|
+
import { Noop } from '../noop';
|
|
5
|
+
import { CooldownInfo } from '../../dtos/cooldownInfo';
|
|
6
|
+
/**
|
|
7
|
+
* Builder for `CommandAction` with state represented by `TActionState`
|
|
8
|
+
*/
|
|
9
|
+
export class CommandActionBuilderWithState {
|
|
10
|
+
name;
|
|
11
|
+
trigger = [];
|
|
12
|
+
activeProvider = () => true;
|
|
13
|
+
cooldownSettingsProvider = () => new CooldownInfo(0);
|
|
14
|
+
blacklistProvider = () => [];
|
|
15
|
+
whitelistProvider = () => [];
|
|
16
|
+
allowedUsersProvider = () => [];
|
|
17
|
+
readmeFactory = Noop.emptyString;
|
|
18
|
+
stateConstructor;
|
|
19
|
+
handler = Noop.call;
|
|
20
|
+
condition = Noop.true;
|
|
21
|
+
maxAllowedSimultaniousExecutions = 0;
|
|
22
|
+
/**
|
|
23
|
+
* Builder for `CommandAction` with state represented by `TActionState`
|
|
24
|
+
* @param name Action name, will be used for logging and storage
|
|
25
|
+
* @param stateConstructor Function that creates default state object
|
|
26
|
+
*/
|
|
27
|
+
constructor(name, stateConstructor) {
|
|
28
|
+
this.name = name;
|
|
29
|
+
this.stateConstructor = stateConstructor;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Defines action trigger
|
|
33
|
+
* @param trigger If `string` or `string[]` is provided, will be triggered only on exact message match.
|
|
34
|
+
*
|
|
35
|
+
* If `RegExp` or `RegExp[]` is provided, will be triggered on successful match.
|
|
36
|
+
*/
|
|
37
|
+
on(trigger) {
|
|
38
|
+
this.trigger = trigger;
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
/** Defines id (or ids) of users that are allowed to trigger this action.
|
|
42
|
+
* @param id User id or ids
|
|
43
|
+
*/
|
|
44
|
+
from(id) {
|
|
45
|
+
const ids = toArray(id);
|
|
46
|
+
this.allowedUsersProvider = () => ids;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Sets chats whitelist for this action.
|
|
51
|
+
* @param chatIds Chats ids to allow.
|
|
52
|
+
*/
|
|
53
|
+
in(chatIds) {
|
|
54
|
+
this.whitelistProvider = () => chatIds;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Sets chats blacklist for this action.
|
|
59
|
+
* @param chatIds Chats ids to ignore.
|
|
60
|
+
*/
|
|
61
|
+
notIn(chatIds) {
|
|
62
|
+
this.blacklistProvider = () => chatIds;
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
/** Defines action logic itself, will be executed on trigger.
|
|
66
|
+
* @param handler Callback that will be called on trigger
|
|
67
|
+
*/
|
|
68
|
+
do(handler) {
|
|
69
|
+
this.handler = handler;
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
/** Defines condition that will be checked before trigger match check is executed.
|
|
73
|
+
* @param condition Condition check predicate
|
|
74
|
+
*/
|
|
75
|
+
when(condition) {
|
|
76
|
+
this.condition = condition;
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Sets factory method for readme (shown on /help) for this action.
|
|
81
|
+
* @param readmeFactory readme factory
|
|
82
|
+
*/
|
|
83
|
+
withHelp(readmeFactory) {
|
|
84
|
+
this.readmeFactory = readmeFactory;
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
/** If called during building, action is marked as disabled and never checked. */
|
|
88
|
+
disabled() {
|
|
89
|
+
this.activeProvider = () => false;
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
/** Sets maximum number of simultaniously executing handlers for this command per chat. 0 is treated as unlimited. */
|
|
93
|
+
withRatelimit(maxAllowedSimultaniousExecutions) {
|
|
94
|
+
this.maxAllowedSimultaniousExecutions =
|
|
95
|
+
maxAllowedSimultaniousExecutions;
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
/** Sets action cooldown settings.
|
|
99
|
+
* @param cooldownSettings Settings.
|
|
100
|
+
*/
|
|
101
|
+
withCooldown(cooldownSettings) {
|
|
102
|
+
const settings = new CooldownInfo(cooldownSettings.cooldown, cooldownSettings.message);
|
|
103
|
+
this.cooldownSettingsProvider = () => settings;
|
|
104
|
+
return this;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Configures action to use property value providers instead of static value to allow changes in runtime
|
|
108
|
+
*/
|
|
109
|
+
withConfiguration(configuration) {
|
|
110
|
+
if (typeof configuration == 'function') {
|
|
111
|
+
configuration = configuration();
|
|
112
|
+
}
|
|
113
|
+
if (configuration.cooldownProvider)
|
|
114
|
+
this.cooldownSettingsProvider = configuration.cooldownProvider;
|
|
115
|
+
if (configuration.chatsWhitelistProvider)
|
|
116
|
+
this.whitelistProvider = configuration.chatsWhitelistProvider;
|
|
117
|
+
if (configuration.chatsBlacklistProvider)
|
|
118
|
+
this.blacklistProvider = configuration.chatsBlacklistProvider;
|
|
119
|
+
if (configuration.usersWhitelistProvider)
|
|
120
|
+
this.allowedUsersProvider = configuration.usersWhitelistProvider;
|
|
121
|
+
if (configuration.isActiveProvider)
|
|
122
|
+
this.activeProvider = configuration.isActiveProvider;
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
125
|
+
/** Builds action */
|
|
126
|
+
build() {
|
|
127
|
+
return new CommandAction(this.trigger, this.handler, this.name, {
|
|
128
|
+
cooldownProvider: this.cooldownSettingsProvider,
|
|
129
|
+
isActiveProvider: this.activeProvider,
|
|
130
|
+
chatsBlacklistProvider: this.blacklistProvider,
|
|
131
|
+
chatsWhitelistProvider: this.whitelistProvider,
|
|
132
|
+
usersWhitelistProvider: this.allowedUsersProvider
|
|
133
|
+
}, this.maxAllowedSimultaniousExecutions, this.condition, this.stateConstructor, this.readmeFactory);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Builder for `CommandAction` with state represented by default state (containing only last execution date).
|
|
138
|
+
*/
|
|
139
|
+
export class CommandActionBuilder extends CommandActionBuilderWithState {
|
|
140
|
+
/**
|
|
141
|
+
* Builder for `CommandAction` with state represented by default state (containing only last execution date).
|
|
142
|
+
*/
|
|
143
|
+
constructor(name) {
|
|
144
|
+
super(name, () => new ActionStateBase());
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { InlineQueryHandler } from '../../types/handlers';
|
|
2
|
+
import { InlineQueryAction } from '../../entities/actions/inlineQueryAction';
|
|
3
|
+
import { InlineActionPropertyProvider } from '../../types/propertyProvider';
|
|
4
|
+
/**
|
|
5
|
+
* Builder for `InlineQueryAction`
|
|
6
|
+
*/
|
|
7
|
+
export declare class InlineQueryActionBuilder {
|
|
8
|
+
private readonly name;
|
|
9
|
+
private pattern;
|
|
10
|
+
private activeProvider;
|
|
11
|
+
private handler;
|
|
12
|
+
/**
|
|
13
|
+
* Builder for `InlineQueryAction`
|
|
14
|
+
* @param name Action name, will be used for logging and storage
|
|
15
|
+
*/
|
|
16
|
+
constructor(name: string);
|
|
17
|
+
/**
|
|
18
|
+
* Defines action pattern to check if action should be executed, if not setup, check will default to true
|
|
19
|
+
* @param trigger RegExp to check
|
|
20
|
+
*/
|
|
21
|
+
on(pattern: RegExp): this;
|
|
22
|
+
/** Defines action logic itself, will be executed.
|
|
23
|
+
* @param handler Callback that will be called
|
|
24
|
+
*/
|
|
25
|
+
do(handler: InlineQueryHandler): this;
|
|
26
|
+
/** If called during building, action is marked as disabled and never checked. */
|
|
27
|
+
disabled(): this;
|
|
28
|
+
/**
|
|
29
|
+
* Configures action to use property value providers instead of static value to allow changes in runtime
|
|
30
|
+
*/
|
|
31
|
+
withConfiguration(configuration: {
|
|
32
|
+
isActiveProvider?: InlineActionPropertyProvider<boolean>;
|
|
33
|
+
}): this;
|
|
34
|
+
/** Builds action */
|
|
35
|
+
build(): InlineQueryAction;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=inlineQueryActionBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inlineQueryActionBuilder.d.ts","sourceRoot":"","sources":["../../../helpers/builders/inlineQueryActionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAE5E;;GAEG;AACH,qBAAa,wBAAwB;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,OAAO,CAAkB;IAEjC,OAAO,CAAC,cAAc,CAAqD;IAC3E,OAAO,CAAC,OAAO,CAAiC;IAEhD;;;OAGG;gBACS,IAAI,EAAE,MAAM;IAIxB;;;OAGG;IACH,EAAE,CAAC,OAAO,EAAE,MAAM;IAMlB;;OAEG;IACH,EAAE,CAAC,OAAO,EAAE,kBAAkB;IAM9B,iFAAiF;IACjF,QAAQ;IAMR;;OAEG;IACH,iBAAiB,CAAC,aAAa,EAAE;QAC7B,gBAAgB,CAAC,EAAE,4BAA4B,CAAC,OAAO,CAAC,CAAC;KAC5D;IAOD,oBAAoB;IACpB,KAAK;CAQR"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Noop } from '../noop';
|
|
2
|
+
import { InlineQueryAction } from '../../entities/actions/inlineQueryAction';
|
|
3
|
+
/**
|
|
4
|
+
* Builder for `InlineQueryAction`
|
|
5
|
+
*/
|
|
6
|
+
export class InlineQueryActionBuilder {
|
|
7
|
+
name;
|
|
8
|
+
pattern = /.+/gi;
|
|
9
|
+
activeProvider = () => true;
|
|
10
|
+
handler = Noop.call;
|
|
11
|
+
/**
|
|
12
|
+
* Builder for `InlineQueryAction`
|
|
13
|
+
* @param name Action name, will be used for logging and storage
|
|
14
|
+
*/
|
|
15
|
+
constructor(name) {
|
|
16
|
+
this.name = name;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Defines action pattern to check if action should be executed, if not setup, check will default to true
|
|
20
|
+
* @param trigger RegExp to check
|
|
21
|
+
*/
|
|
22
|
+
on(pattern) {
|
|
23
|
+
this.pattern = pattern;
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
/** Defines action logic itself, will be executed.
|
|
27
|
+
* @param handler Callback that will be called
|
|
28
|
+
*/
|
|
29
|
+
do(handler) {
|
|
30
|
+
this.handler = handler;
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
/** If called during building, action is marked as disabled and never checked. */
|
|
34
|
+
disabled() {
|
|
35
|
+
this.activeProvider = () => false;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Configures action to use property value providers instead of static value to allow changes in runtime
|
|
40
|
+
*/
|
|
41
|
+
withConfiguration(configuration) {
|
|
42
|
+
if (configuration.isActiveProvider)
|
|
43
|
+
this.activeProvider = configuration.isActiveProvider;
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
/** Builds action */
|
|
47
|
+
build() {
|
|
48
|
+
return new InlineQueryAction(this.handler, this.name, this.activeProvider, this.pattern);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ScheduledAction } from '../../entities/actions/scheduledAction';
|
|
2
|
+
import { ActionStateBase } from '../../entities/states/actionStateBase';
|
|
3
|
+
import { IActionState } from '../../types/actionState';
|
|
4
|
+
import { ScheduledHandler } from '../../types/handlers';
|
|
5
|
+
import { ScheduledActionPropertyProvider } from '../../types/propertyProvider';
|
|
6
|
+
import { Hours, HoursOfDay } from '../../types/timeValues';
|
|
7
|
+
/**
|
|
8
|
+
* Builder for `ScheduledAction` with state represented by `TActionState`
|
|
9
|
+
*/
|
|
10
|
+
export declare class ScheduledActionBuilderWithState<TActionState extends IActionState> {
|
|
11
|
+
private readonly name;
|
|
12
|
+
private readonly cachedStateFactories;
|
|
13
|
+
private readonly stateConstructor;
|
|
14
|
+
private handler;
|
|
15
|
+
private whitelistProvider;
|
|
16
|
+
private activeProvider;
|
|
17
|
+
private timeinHoursProvider;
|
|
18
|
+
/**
|
|
19
|
+
* Builder for `ScheduledAction` with state represented by `TActionState`
|
|
20
|
+
* @param name Action name, will be used for logging and storage
|
|
21
|
+
* @param stateConstructor Function that creates default state object
|
|
22
|
+
*/
|
|
23
|
+
constructor(name: string, stateConstructor: () => TActionState);
|
|
24
|
+
/**
|
|
25
|
+
* Sets whitelist for this action.
|
|
26
|
+
* @param chatIds Chat ids to execute in.
|
|
27
|
+
*/
|
|
28
|
+
in(chatIds: number[]): this;
|
|
29
|
+
/**
|
|
30
|
+
* Defines time for scheduled item execution.
|
|
31
|
+
* @param time Time of day (0 - 23) to execute action.
|
|
32
|
+
*/
|
|
33
|
+
runAt(time: HoursOfDay): this;
|
|
34
|
+
/** Defines action logic itself, will be executed on timer.
|
|
35
|
+
* @param handler Callback that will be called on timer.
|
|
36
|
+
*/
|
|
37
|
+
do(handler: ScheduledHandler<TActionState>): this;
|
|
38
|
+
/**
|
|
39
|
+
* Defines process-wide cache, that is shared by all actions of this type (even in different bot instances).
|
|
40
|
+
* Can be used for fetch request de-duping, etc.
|
|
41
|
+
* @param key Key that will be used to retrieve value from cache.
|
|
42
|
+
* @param itemFactory Callback that will be executed once to create cached value.
|
|
43
|
+
* @param invalidationTimeoutInHours Timeout for cache invalidation.
|
|
44
|
+
*/
|
|
45
|
+
withSharedCache(key: string, itemFactory: () => Promise<unknown>, invalidationTimeoutInHours?: Hours): this;
|
|
46
|
+
/** If called during building, action is marked as disabled and never checked. */
|
|
47
|
+
disabled(): this;
|
|
48
|
+
/**
|
|
49
|
+
* Configures action to use property value providers instead of static value to allow changes in runtime
|
|
50
|
+
*/
|
|
51
|
+
withConfiguration(configuration: {
|
|
52
|
+
timeinHoursProvider?: ScheduledActionPropertyProvider<HoursOfDay>;
|
|
53
|
+
isActiveProvider?: ScheduledActionPropertyProvider<boolean>;
|
|
54
|
+
chatsWhitelistProvider?: ScheduledActionPropertyProvider<number[]>;
|
|
55
|
+
}): this;
|
|
56
|
+
/** Builds action */
|
|
57
|
+
build(): ScheduledAction<TActionState>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Builder for `ScheduledAction` with state represented by default state (containing only last execution date).
|
|
61
|
+
*/
|
|
62
|
+
export declare class ScheduledActionBuilder extends ScheduledActionBuilderWithState<ActionStateBase> {
|
|
63
|
+
/**
|
|
64
|
+
* Builder for `ScheduledAction` with state represented by default state (containing only last execution date).
|
|
65
|
+
*/
|
|
66
|
+
constructor(name: string);
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=scheduledActionBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduledActionBuilder.d.ts","sourceRoot":"","sources":["../../../helpers/builders/scheduledActionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAG3D;;GAEG;AACH,qBAAa,+BAA+B,CACxC,YAAY,SAAS,YAAY;IAEjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAGjC;IACJ,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAqB;IACtD,OAAO,CAAC,OAAO,CAA6C;IAE5D,OAAO,CAAC,iBAAiB,CACZ;IACb,OAAO,CAAC,cAAc,CACb;IACT,OAAO,CAAC,mBAAmB,CACf;IAEZ;;;;OAIG;gBACS,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,YAAY;IAK9D;;;OAGG;IACH,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE;IAMpB;;;OAGG;IACH,KAAK,CAAC,IAAI,EAAE,UAAU;IAMtB;;OAEG;IACH,EAAE,CAAC,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC;IAM1C;;;;;;OAMG;IACH,eAAe,CACX,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,EACnC,0BAA0B,GAAE,KAAmB;IAUnD,iFAAiF;IACjF,QAAQ;IAMR;;OAEG;IACH,iBAAiB,CAAC,aAAa,EAAE;QAC7B,mBAAmB,CAAC,EAAE,+BAA+B,CAAC,UAAU,CAAC,CAAC;QAClE,gBAAgB,CAAC,EAAE,+BAA+B,CAAC,OAAO,CAAC,CAAC;QAC5D,sBAAsB,CAAC,EAAE,+BAA+B,CAAC,MAAM,EAAE,CAAC,CAAC;KACtE;IAaD,oBAAoB;IACpB,KAAK;CAaR;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,+BAA+B,CAAC,eAAe,CAAC;IACxF;;OAEG;gBACS,IAAI,EAAE,MAAM;CAG3B"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ScheduledAction } from '../../entities/actions/scheduledAction';
|
|
2
|
+
import { CachedStateFactory } from '../../entities/cachedStateFactory';
|
|
3
|
+
import { ActionStateBase } from '../../entities/states/actionStateBase';
|
|
4
|
+
import { Noop } from '../noop';
|
|
5
|
+
/**
|
|
6
|
+
* Builder for `ScheduledAction` with state represented by `TActionState`
|
|
7
|
+
*/
|
|
8
|
+
export class ScheduledActionBuilderWithState {
|
|
9
|
+
name;
|
|
10
|
+
cachedStateFactories = new Map();
|
|
11
|
+
stateConstructor;
|
|
12
|
+
handler = Noop.call;
|
|
13
|
+
whitelistProvider = () => [];
|
|
14
|
+
activeProvider = () => true;
|
|
15
|
+
timeinHoursProvider = () => 0;
|
|
16
|
+
/**
|
|
17
|
+
* Builder for `ScheduledAction` with state represented by `TActionState`
|
|
18
|
+
* @param name Action name, will be used for logging and storage
|
|
19
|
+
* @param stateConstructor Function that creates default state object
|
|
20
|
+
*/
|
|
21
|
+
constructor(name, stateConstructor) {
|
|
22
|
+
this.name = name;
|
|
23
|
+
this.stateConstructor = stateConstructor;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Sets whitelist for this action.
|
|
27
|
+
* @param chatIds Chat ids to execute in.
|
|
28
|
+
*/
|
|
29
|
+
in(chatIds) {
|
|
30
|
+
this.whitelistProvider = () => chatIds;
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Defines time for scheduled item execution.
|
|
35
|
+
* @param time Time of day (0 - 23) to execute action.
|
|
36
|
+
*/
|
|
37
|
+
runAt(time) {
|
|
38
|
+
this.timeinHoursProvider = () => time;
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
/** Defines action logic itself, will be executed on timer.
|
|
42
|
+
* @param handler Callback that will be called on timer.
|
|
43
|
+
*/
|
|
44
|
+
do(handler) {
|
|
45
|
+
this.handler = handler;
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Defines process-wide cache, that is shared by all actions of this type (even in different bot instances).
|
|
50
|
+
* Can be used for fetch request de-duping, etc.
|
|
51
|
+
* @param key Key that will be used to retrieve value from cache.
|
|
52
|
+
* @param itemFactory Callback that will be executed once to create cached value.
|
|
53
|
+
* @param invalidationTimeoutInHours Timeout for cache invalidation.
|
|
54
|
+
*/
|
|
55
|
+
withSharedCache(key, itemFactory, invalidationTimeoutInHours = 20) {
|
|
56
|
+
this.cachedStateFactories.set(key, new CachedStateFactory(itemFactory, invalidationTimeoutInHours));
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
/** If called during building, action is marked as disabled and never checked. */
|
|
60
|
+
disabled() {
|
|
61
|
+
this.activeProvider = () => false;
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Configures action to use property value providers instead of static value to allow changes in runtime
|
|
66
|
+
*/
|
|
67
|
+
withConfiguration(configuration) {
|
|
68
|
+
if (configuration.chatsWhitelistProvider)
|
|
69
|
+
this.whitelistProvider = configuration.chatsWhitelistProvider;
|
|
70
|
+
if (configuration.timeinHoursProvider)
|
|
71
|
+
this.timeinHoursProvider = configuration.timeinHoursProvider;
|
|
72
|
+
if (configuration.isActiveProvider)
|
|
73
|
+
this.activeProvider = configuration.isActiveProvider;
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
/** Builds action */
|
|
77
|
+
build() {
|
|
78
|
+
return new ScheduledAction(this.name, this.handler, {
|
|
79
|
+
chatsWhitelistProvider: this.whitelistProvider,
|
|
80
|
+
isActiveProvider: this.activeProvider,
|
|
81
|
+
timeinHoursProvider: this.timeinHoursProvider
|
|
82
|
+
}, this.cachedStateFactories, this.stateConstructor);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Builder for `ScheduledAction` with state represented by default state (containing only last execution date).
|
|
87
|
+
*/
|
|
88
|
+
export class ScheduledActionBuilder extends ScheduledActionBuilderWithState {
|
|
89
|
+
/**
|
|
90
|
+
* Builder for `ScheduledAction` with state represented by default state (containing only last execution date).
|
|
91
|
+
*/
|
|
92
|
+
constructor(name) {
|
|
93
|
+
super(name, () => new ActionStateBase());
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type KeyedReadonlyCollection<K, V> = {
|
|
2
|
+
get: (key: K) => V | undefined;
|
|
3
|
+
};
|
|
4
|
+
type KeyedWriteableCollection<K, V> = KeyedReadonlyCollection<K, V> & {
|
|
5
|
+
set: (key: K, value: V) => KeyedWriteableCollection<K, V>;
|
|
6
|
+
};
|
|
7
|
+
export declare function getOrSetIfNotExists<K, V>(map: KeyedWriteableCollection<K, V>, key: K, fallback: V): V;
|
|
8
|
+
export declare function getOrThrow<K, V>(map: KeyedReadonlyCollection<K, V>, key: K, error?: string): NonNullable<V>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=mapUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapUtils.d.ts","sourceRoot":"","sources":["../../helpers/mapUtils.ts"],"names":[],"mappings":"AAAA,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI;IAAE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,SAAS,CAAA;CAAE,CAAC;AACxE,KAAK,wBAAwB,CAAC,CAAC,EAAE,CAAC,IAAI,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IAClE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAC7D,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,CAAC,EACpC,GAAG,EAAE,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC,EACnC,GAAG,EAAE,CAAC,EACN,QAAQ,EAAE,CAAC,KAQd;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAC3B,GAAG,EAAE,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,EAClC,GAAG,EAAE,CAAC,EACN,KAAK,GAAE,MAAsC,kBAMhD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function getOrSetIfNotExists(map, key, fallback) {
|
|
2
|
+
const existingValue = map.get(key);
|
|
3
|
+
if (existingValue)
|
|
4
|
+
return existingValue;
|
|
5
|
+
map.set(key, fallback);
|
|
6
|
+
return fallback;
|
|
7
|
+
}
|
|
8
|
+
export function getOrThrow(map, key, error = 'Key not found in collection') {
|
|
9
|
+
const existingValue = map.get(key);
|
|
10
|
+
if (existingValue)
|
|
11
|
+
return existingValue;
|
|
12
|
+
throw new Error(error);
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BotResponse } from '../types/response';
|
|
2
|
+
export declare class Noop {
|
|
3
|
+
static readonly NoResponse: BotResponse[];
|
|
4
|
+
static true(arg1: unknown): boolean;
|
|
5
|
+
static false(arg1: unknown): boolean;
|
|
6
|
+
static emptyString(): string;
|
|
7
|
+
static call(arg1: unknown): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=noop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../../helpers/noop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,qBAAa,IAAI;IACb,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,EAAE,CAAM;IAC/C,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO;IAGzB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO;IAG1B,MAAM,CAAC,WAAW;WAGL,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAIlD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
3
|
+
export class Noop {
|
|
4
|
+
static NoResponse = [];
|
|
5
|
+
static true(arg1) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
static false(arg1) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
static emptyString() {
|
|
12
|
+
return '';
|
|
13
|
+
}
|
|
14
|
+
static async call(arg1, arg2) {
|
|
15
|
+
return Promise.resolve();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectFromEntries.d.ts","sourceRoot":"","sources":["../../helpers/objectFromEntries.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,GAClC,KAAK,CAAC,CAAC,SAAS,aAAa,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,EAE9D,SAAS,CAAC,KACX,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAElC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Hours, Milliseconds, Seconds } from '../types/timeValues';
|
|
2
|
+
export declare function secondsToMilliseconds(value: Seconds): Milliseconds;
|
|
3
|
+
export declare function hoursToMilliseconds(value: Hours): Milliseconds;
|
|
4
|
+
export declare function hoursToSeconds(value: Hours): Seconds;
|
|
5
|
+
//# sourceMappingURL=timeConvertions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeConvertions.d.ts","sourceRoot":"","sources":["../../helpers/timeConvertions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAElE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,YAAY,CAE9D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAEpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toArray.d.ts","sourceRoot":"","sources":["../../helpers/toArray.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,EAAE,WAEpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traceFactory.d.ts","sourceRoot":"","sources":["../../helpers/traceFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,wBAAgB,WAAW,CACvB,UAAU,EAAE,MAAM,GAAG,MAAM,EAC3B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAIa,OAAO,CACxC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export * from './main';
|
|
2
|
+
export * from './helpers/builders/inlineQueryActionBuilder';
|
|
3
|
+
export * from './helpers/builders/commandActionBuilder';
|
|
4
|
+
export * from './helpers/builders/scheduledActionBuilder';
|
|
5
|
+
export * from './types/actionState';
|
|
6
|
+
export * from './entities/states/actionStateBase';
|
|
7
|
+
export * from './types/messageTypes';
|
|
8
|
+
export * from './helpers/timeConvertions';
|
|
9
|
+
export * from './types/action';
|
|
10
|
+
export * from './types/externalAliases';
|
|
11
|
+
export * from './types/storage';
|
|
12
|
+
export * from './types/scheduler';
|
|
13
|
+
export { CommandAction } from './entities/actions/commandAction';
|
|
14
|
+
export { InlineQueryAction } from './entities/actions/inlineQueryAction';
|
|
15
|
+
export { ReplyCaptureAction } from './entities/actions/replyCaptureAction';
|
|
16
|
+
export { ScheduledAction } from './entities/actions/scheduledAction';
|
|
17
|
+
export { Hours, Milliseconds, Seconds } from './types/timeValues';
|
|
18
|
+
export { ChatContext } from './entities/context/chatContext';
|
|
19
|
+
export { InlineQueryContext } from './entities/context/inlineQueryContext';
|
|
20
|
+
export { MessageContext } from './entities/context/messageContext';
|
|
21
|
+
export { ReplyContext } from './entities/context/replyContext';
|
|
22
|
+
export { ICaptureController } from './types/capture';
|
|
23
|
+
export { ChatInfo } from './dtos/chatInfo';
|
|
24
|
+
export { MessageInfo } from './dtos/messageInfo';
|
|
25
|
+
export { UserInfo } from './dtos/userInfo';
|
|
26
|
+
export { BotEventType } from './types/events';
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,6CAA6C,CAAC;AAC5D,cAAc,yCAAyC,CAAC;AACxD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qBAAqB,CAAC;AACpC,cAAc,mCAAmC,CAAC;AAClD,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './main';
|
|
2
|
+
export * from './helpers/builders/inlineQueryActionBuilder';
|
|
3
|
+
export * from './helpers/builders/commandActionBuilder';
|
|
4
|
+
export * from './helpers/builders/scheduledActionBuilder';
|
|
5
|
+
export * from './types/actionState';
|
|
6
|
+
export * from './entities/states/actionStateBase';
|
|
7
|
+
export * from './types/messageTypes';
|
|
8
|
+
export * from './helpers/timeConvertions';
|
|
9
|
+
export * from './types/action';
|
|
10
|
+
export * from './types/externalAliases';
|
|
11
|
+
export * from './types/storage';
|
|
12
|
+
export * from './types/scheduler';
|
|
13
|
+
export { CommandAction } from './entities/actions/commandAction';
|
|
14
|
+
export { InlineQueryAction } from './entities/actions/inlineQueryAction';
|
|
15
|
+
export { ReplyCaptureAction } from './entities/actions/replyCaptureAction';
|
|
16
|
+
export { ScheduledAction } from './entities/actions/scheduledAction';
|
|
17
|
+
export { ChatInfo } from './dtos/chatInfo';
|
|
18
|
+
export { MessageInfo } from './dtos/messageInfo';
|
|
19
|
+
export { UserInfo } from './dtos/userInfo';
|
|
20
|
+
export { BotEventType } from './types/events';
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { IStorageClient } from './types/storage';
|
|
2
|
+
import { CommandAction } from './entities/actions/commandAction';
|
|
3
|
+
import { ScheduledAction } from './entities/actions/scheduledAction';
|
|
4
|
+
import { BotInstance } from './entities/botInstance';
|
|
5
|
+
import { Seconds } from './types/timeValues';
|
|
6
|
+
import { IScheduler } from './types/scheduler';
|
|
7
|
+
import { InlineQueryAction } from './entities/actions/inlineQueryAction';
|
|
8
|
+
import { IActionState } from './types/actionState';
|
|
9
|
+
declare class BotOrchestrator {
|
|
10
|
+
bots: BotInstance[];
|
|
11
|
+
/**
|
|
12
|
+
* Starts bot
|
|
13
|
+
*/
|
|
14
|
+
startBot(options: {
|
|
15
|
+
/** Bot name, used in logging */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Path to file containing Telegram Bot token. */
|
|
18
|
+
tokenFilePath: string;
|
|
19
|
+
actions: {
|
|
20
|
+
/** Collection of actions that will be executed as a response to message from used. Created using `CommandActionBuilder`.*/
|
|
21
|
+
commands: CommandAction<IActionState>[];
|
|
22
|
+
/** Collection of actions that will be executed on timer. Created using `ScheduledActionBuilder`.*/
|
|
23
|
+
scheduled: ScheduledAction<IActionState>[];
|
|
24
|
+
/** Collection of actions that will handle inline queries */
|
|
25
|
+
inlineQueries: InlineQueryAction[];
|
|
26
|
+
};
|
|
27
|
+
/** Object containing chat name and chat id pairs. Used for logging and execution of scheduled action. */
|
|
28
|
+
chats: Record<string, number>;
|
|
29
|
+
/** Storage path for default `JsonFileStorage` client. Will be used only if `storageClient` is not provided. If not provided, default value of `./storage/` will be used.*/
|
|
30
|
+
storagePath?: string;
|
|
31
|
+
/** Period of time between execution of scheduled actions. */
|
|
32
|
+
scheduledPeriod?: Seconds;
|
|
33
|
+
/** If true, telegram API objects will be logged instead of message content. */
|
|
34
|
+
verboseLoggingForIncomingMessage?: boolean;
|
|
35
|
+
services?: {
|
|
36
|
+
/** Storage client for bot state storage. If not provided, default `JsonFileStorage` will be used. */
|
|
37
|
+
storageClient?: IStorageClient;
|
|
38
|
+
/** Scheduler client for bot scheduling. If not provided, default `NodeTimeoutScheduler` will be used. */
|
|
39
|
+
scheduler?: IScheduler;
|
|
40
|
+
};
|
|
41
|
+
}): Promise<BotInstance>;
|
|
42
|
+
/**
|
|
43
|
+
* Terminates all scheduled tasks, closes storage connections and stops all bots.
|
|
44
|
+
*/
|
|
45
|
+
stopBots(): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
export declare const botOrchestrator: BotOrchestrator;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,cAAM,eAAe;IACjB,IAAI,EAAE,WAAW,EAAE,CAAM;IAEzB;;OAEG;IACG,QAAQ,CAAC,OAAO,EAAE;QACpB,gCAAgC;QAChC,IAAI,EAAE,MAAM,CAAC;QACb,kDAAkD;QAClD,aAAa,EAAE,MAAM,CAAC;QACtB,OAAO,EAAE;YACL,2HAA2H;YAC3H,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,EAAE,CAAC;YACxC,mGAAmG;YACnG,SAAS,EAAE,eAAe,CAAC,YAAY,CAAC,EAAE,CAAC;YAC3C,4DAA4D;YAC5D,aAAa,EAAE,iBAAiB,EAAE,CAAC;SACtC,CAAC;QACF,yGAAyG;QACzG,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC9B,2KAA2K;QAC3K,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,6DAA6D;QAC7D,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,+EAA+E;QAC/E,gCAAgC,CAAC,EAAE,OAAO,CAAC;QAC3C,QAAQ,CAAC,EAAE;YACP,qGAAqG;YACrG,aAAa,CAAC,EAAE,cAAc,CAAC;YAC/B,yGAAyG;YACzG,SAAS,CAAC,EAAE,UAAU,CAAC;SAC1B,CAAC;KACL;IAoBD;;OAEG;IACG,QAAQ;CAKjB;AAED,eAAO,MAAM,eAAe,iBAAwB,CAAC"}
|