chz-telegram-bot 0.0.45 → 0.0.46
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/entities/actionExecutionResult.d.ts +7 -0
- package/dist/entities/actionExecutionResult.d.ts.map +1 -0
- package/dist/entities/actionExecutionResult.js +10 -0
- package/dist/entities/actions/commandAction.d.ts +23 -0
- package/dist/entities/actions/commandAction.d.ts.map +1 -0
- package/dist/entities/actions/commandAction.js +91 -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 +81 -0
- package/dist/entities/botInstance.d.ts +31 -0
- package/dist/entities/botInstance.d.ts.map +1 -0
- package/dist/entities/botInstance.js +107 -0
- package/dist/entities/cachedStateFactory.d.ts +7 -0
- package/dist/entities/cachedStateFactory.d.ts.map +1 -0
- package/dist/entities/cachedStateFactory.js +10 -0
- package/dist/entities/commandTriggerCheckResult.d.ts +10 -0
- package/dist/entities/commandTriggerCheckResult.d.ts.map +1 -0
- package/dist/entities/commandTriggerCheckResult.js +23 -0
- package/dist/entities/context/chatContext.d.ts +54 -0
- package/dist/entities/context/chatContext.d.ts.map +1 -0
- package/dist/entities/context/chatContext.js +70 -0
- package/dist/entities/context/messageContext.d.ts +60 -0
- package/dist/entities/context/messageContext.d.ts.map +1 -0
- package/dist/entities/context/messageContext.js +82 -0
- package/dist/entities/incomingMessage.d.ts +14 -0
- package/dist/entities/incomingMessage.d.ts.map +1 -0
- package/dist/entities/incomingMessage.js +45 -0
- package/dist/entities/responses/imageMessage.d.ts +16 -0
- package/dist/entities/responses/imageMessage.d.ts.map +1 -0
- package/dist/entities/responses/imageMessage.js +17 -0
- package/dist/entities/responses/reaction.d.ts +13 -0
- package/dist/entities/responses/reaction.d.ts.map +1 -0
- package/dist/entities/responses/reaction.js +15 -0
- package/dist/entities/responses/textMessage.d.ts +15 -0
- package/dist/entities/responses/textMessage.d.ts.map +1 -0
- package/dist/entities/responses/textMessage.js +17 -0
- package/dist/entities/responses/unpin.d.ts +11 -0
- package/dist/entities/responses/unpin.d.ts.map +1 -0
- package/dist/entities/responses/unpin.js +14 -0
- package/dist/entities/responses/videoMessage.d.ts +16 -0
- package/dist/entities/responses/videoMessage.d.ts.map +1 -0
- package/dist/entities/responses/videoMessage.js +17 -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 +10 -0
- package/dist/entities/taskRecord.d.ts +8 -0
- package/dist/entities/taskRecord.d.ts.map +1 -0
- package/dist/entities/taskRecord.js +11 -0
- package/dist/helpers/builders/commandActionBuilder.d.ts +69 -0
- package/dist/helpers/builders/commandActionBuilder.d.ts.map +1 -0
- package/dist/helpers/builders/commandActionBuilder.js +96 -0
- package/dist/helpers/builders/scheduledActionBuilder.d.ts +60 -0
- package/dist/helpers/builders/scheduledActionBuilder.d.ts.map +1 -0
- package/dist/helpers/builders/scheduledActionBuilder.js +82 -0
- package/dist/helpers/inverseRecord.d.ts +2 -0
- package/dist/helpers/inverseRecord.d.ts.map +1 -0
- package/dist/helpers/inverseRecord.js +6 -0
- package/dist/helpers/noop.d.ts +6 -0
- package/dist/helpers/noop.d.ts.map +1 -0
- package/dist/helpers/noop.js +14 -0
- package/dist/helpers/reverseMap.d.ts +2 -0
- package/dist/helpers/reverseMap.d.ts.map +1 -0
- package/dist/helpers/reverseMap.js +6 -0
- package/dist/helpers/reverseRecord.d.ts +2 -0
- package/dist/helpers/reverseRecord.d.ts.map +1 -0
- package/dist/helpers/reverseRecord.js +6 -0
- package/dist/helpers/timeConvertions.d.ts +5 -0
- package/dist/helpers/timeConvertions.d.ts.map +1 -0
- package/dist/helpers/timeConvertions.js +14 -0
- package/dist/helpers/toArray.d.ts +2 -0
- package/dist/helpers/toArray.d.ts.map +1 -0
- package/dist/helpers/toArray.js +6 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/main.d.ts +35 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +43 -0
- package/dist/services/jsonFileStorage.d.ts +22 -0
- package/dist/services/jsonFileStorage.d.ts.map +1 -0
- package/dist/services/jsonFileStorage.js +102 -0
- package/dist/services/logger.d.ts +9 -0
- package/dist/services/logger.d.ts.map +1 -0
- package/dist/services/logger.js +28 -0
- package/dist/services/taskScheduler.d.ts +11 -0
- package/dist/services/taskScheduler.d.ts.map +1 -0
- package/dist/services/taskScheduler.js +33 -0
- package/dist/services/telegramApi.d.ts +36 -0
- package/dist/services/telegramApi.d.ts.map +1 -0
- package/dist/services/telegramApi.js +100 -0
- package/dist/types/actionState.d.ts +5 -0
- package/dist/types/actionState.d.ts.map +1 -0
- package/dist/types/actionState.js +2 -0
- package/dist/types/actionWithState.d.ts +9 -0
- package/dist/types/actionWithState.d.ts.map +1 -0
- package/dist/types/actionWithState.js +2 -0
- package/dist/types/cachedValueAccessor.d.ts +2 -0
- package/dist/types/cachedValueAccessor.d.ts.map +1 -0
- package/dist/types/cachedValueAccessor.js +2 -0
- package/dist/types/commandCondition.d.ts +4 -0
- package/dist/types/commandCondition.d.ts.map +1 -0
- package/dist/types/commandCondition.js +2 -0
- package/dist/types/commandTrigger.d.ts +3 -0
- package/dist/types/commandTrigger.d.ts.map +1 -0
- package/dist/types/commandTrigger.js +2 -0
- package/dist/types/daysOfTheWeek.d.ts +10 -0
- package/dist/types/daysOfTheWeek.d.ts.map +1 -0
- package/dist/types/daysOfTheWeek.js +13 -0
- package/dist/types/handlers.d.ts +17 -0
- package/dist/types/handlers.d.ts.map +1 -0
- package/dist/types/handlers.js +2 -0
- package/dist/types/messageSendingOptions.d.ts +7 -0
- package/dist/types/messageSendingOptions.d.ts.map +1 -0
- package/dist/types/messageSendingOptions.js +2 -0
- package/dist/types/messageTypes.d.ts +16 -0
- package/dist/types/messageTypes.d.ts.map +1 -0
- package/dist/types/messageTypes.js +17 -0
- package/dist/types/replyMessage.d.ts +8 -0
- package/dist/types/replyMessage.d.ts.map +1 -0
- package/dist/types/replyMessage.js +2 -0
- package/dist/types/response.d.ts +27 -0
- package/dist/types/response.d.ts.map +1 -0
- package/dist/types/response.js +10 -0
- package/dist/types/storage.d.ts +12 -0
- package/dist/types/storage.d.ts.map +1 -0
- package/dist/types/storage.js +2 -0
- package/dist/types/timeValues.d.ts +11 -0
- package/dist/types/timeValues.d.ts.map +1 -0
- package/dist/types/timeValues.js +2 -0
- package/package.json +29 -29
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TelegramApiService = void 0;
|
|
4
|
+
const inverseRecord_1 = require("../helpers/inverseRecord");
|
|
5
|
+
const logger_1 = require("./logger");
|
|
6
|
+
const promises_1 = require("timers/promises");
|
|
7
|
+
const TELEGRAM_RATELIMIT_DELAY = 35;
|
|
8
|
+
class TelegramApiService {
|
|
9
|
+
constructor(botName, telegram, storage, chats) {
|
|
10
|
+
this.isFlushing = false;
|
|
11
|
+
this.messageQueue = [];
|
|
12
|
+
this.telegram = telegram;
|
|
13
|
+
this.botName = botName;
|
|
14
|
+
this.chats = (0, inverseRecord_1.inverseRecord)(chats);
|
|
15
|
+
this.storage = storage;
|
|
16
|
+
this.interactions = {
|
|
17
|
+
react: (reaction) => this.enqueue(reaction),
|
|
18
|
+
respond: (response) => this.enqueue(response),
|
|
19
|
+
unpin: (unpinMessage) => this.enqueue(unpinMessage)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
async flushResponses() {
|
|
23
|
+
if (this.isFlushing)
|
|
24
|
+
return;
|
|
25
|
+
this.isFlushing = true;
|
|
26
|
+
while (this.messageQueue.length) {
|
|
27
|
+
const message = this.messageQueue.pop();
|
|
28
|
+
if (!message)
|
|
29
|
+
break;
|
|
30
|
+
try {
|
|
31
|
+
await this.processResponse(message);
|
|
32
|
+
await (0, promises_1.setTimeout)(TELEGRAM_RATELIMIT_DELAY);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
logger_1.Logger.errorWithTraceId(this.botName, message.traceId, this.chats[message.chatId], error, message);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
this.isFlushing = false;
|
|
39
|
+
}
|
|
40
|
+
async pinIfShould(response, sentMessage) {
|
|
41
|
+
if (response.shouldPin) {
|
|
42
|
+
await this.telegram.pinChatMessage(response.chatId, sentMessage.message_id, { disable_notification: true });
|
|
43
|
+
await this.storage.updateStateFor(response.action, response.chatId, async (state) => {
|
|
44
|
+
state.pinnedMessages.push(sentMessage.message_id);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async processResponse(response) {
|
|
49
|
+
let sentMessage;
|
|
50
|
+
switch (response.kind) {
|
|
51
|
+
case 'text':
|
|
52
|
+
sentMessage = await this.telegram.sendMessage(response.chatId, response.content, {
|
|
53
|
+
reply_to_message_id: response.replyId,
|
|
54
|
+
parse_mode: 'MarkdownV2',
|
|
55
|
+
disable_web_page_preview: response.disableWebPreview
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
});
|
|
58
|
+
await this.pinIfShould(response, sentMessage);
|
|
59
|
+
break;
|
|
60
|
+
case 'image':
|
|
61
|
+
sentMessage = await this.telegram.sendPhoto(response.chatId, response.content, response.replyId
|
|
62
|
+
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
|
+
{ reply_to_message_id: response.replyId }
|
|
64
|
+
: undefined);
|
|
65
|
+
await this.pinIfShould(response, sentMessage);
|
|
66
|
+
break;
|
|
67
|
+
case 'video':
|
|
68
|
+
sentMessage = await this.telegram.sendVideo(response.chatId, response.content, response.replyId
|
|
69
|
+
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
70
|
+
{ reply_to_message_id: response.replyId }
|
|
71
|
+
: undefined);
|
|
72
|
+
await this.pinIfShould(response, sentMessage);
|
|
73
|
+
break;
|
|
74
|
+
case 'react':
|
|
75
|
+
await this.telegram.setMessageReaction(response.chatId, response.messageId, [
|
|
76
|
+
{
|
|
77
|
+
type: 'emoji',
|
|
78
|
+
emoji: response.emoji
|
|
79
|
+
}
|
|
80
|
+
], true);
|
|
81
|
+
return;
|
|
82
|
+
case 'unpin':
|
|
83
|
+
await this.telegram.unpinChatMessage(response.chatId, response.messageId);
|
|
84
|
+
await this.storage.updateStateFor(response.action, response.chatId, async (state) => {
|
|
85
|
+
state.pinnedMessages = state.pinnedMessages.filter((x) => x != response.messageId);
|
|
86
|
+
});
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
enqueue(response) {
|
|
91
|
+
this.messageQueue.push(response);
|
|
92
|
+
}
|
|
93
|
+
initializeContextForMessage(ctx, incomingMessage, command) {
|
|
94
|
+
return ctx.initializeMessageContext(this.botName, command, this.interactions, incomingMessage, this.storage);
|
|
95
|
+
}
|
|
96
|
+
initializeContextForChat(ctx, chatId, scheduledAction) {
|
|
97
|
+
return ctx.initializeChatContext(this.botName, scheduledAction, this.interactions, chatId, this.chats[chatId], `Scheduled:${scheduledAction.key}:${chatId}`, this.storage);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.TelegramApiService = TelegramApiService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actionState.d.ts","sourceRoot":"","sources":["../../types/actionState.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actionWithState.d.ts","sourceRoot":"","sources":["../../types/actionWithState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC;AAE1D,MAAM,WAAW,gBAAgB;IAC7B,GAAG,EAAE,SAAS,CAAC;IACf,gBAAgB,EAAE,MAAM,YAAY,CAAC;CACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cachedValueAccessor.d.ts","sourceRoot":"","sources":["../../types/cachedValueAccessor.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { MessageContext } from '../entities/context/messageContext';
|
|
2
|
+
import { IActionState } from './actionState';
|
|
3
|
+
export type CommandCondition<TActionState extends IActionState> = (ctx: MessageContext<TActionState>) => Promise<boolean>;
|
|
4
|
+
//# sourceMappingURL=commandCondition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandCondition.d.ts","sourceRoot":"","sources":["../../types/commandCondition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,MAAM,gBAAgB,CAAC,YAAY,SAAS,YAAY,IAAI,CAC9D,GAAG,EAAE,cAAc,CAAC,YAAY,CAAC,KAChC,OAAO,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandTrigger.d.ts","sourceRoot":"","sources":["../../types/commandTrigger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG,MAAM,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daysOfTheWeek.d.ts","sourceRoot":"","sources":["../../types/daysOfTheWeek.ts"],"names":[],"mappings":"AAAA,oBAAY,GAAG;IACX,MAAM,IAAI;IACV,MAAM,IAAI;IACV,OAAO,IAAI;IACX,SAAS,IAAI;IACb,QAAQ,IAAI;IACZ,MAAM,IAAI;IACV,QAAQ,IAAI;CACf"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Day = void 0;
|
|
4
|
+
var Day;
|
|
5
|
+
(function (Day) {
|
|
6
|
+
Day[Day["Sunday"] = 0] = "Sunday";
|
|
7
|
+
Day[Day["Monday"] = 1] = "Monday";
|
|
8
|
+
Day[Day["Tuesday"] = 2] = "Tuesday";
|
|
9
|
+
Day[Day["Wednesday"] = 3] = "Wednesday";
|
|
10
|
+
Day[Day["Thursday"] = 4] = "Thursday";
|
|
11
|
+
Day[Day["Friday"] = 5] = "Friday";
|
|
12
|
+
Day[Day["Saturday"] = 6] = "Saturday";
|
|
13
|
+
})(Day || (exports.Day = Day = {}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ChatContext } from '../entities/context/chatContext';
|
|
2
|
+
import { MessageContext } from '../entities/context/messageContext';
|
|
3
|
+
import { IActionState } from './actionState';
|
|
4
|
+
import { CachedValueAccessor } from './cachedValueAccessor';
|
|
5
|
+
export type CommandHandler<TActionState extends IActionState> = (
|
|
6
|
+
/** Context of action executed in chat, in response to a message. */
|
|
7
|
+
ctx: MessageContext<TActionState>,
|
|
8
|
+
/** State of an action being executed. */
|
|
9
|
+
state: TActionState) => Promise<void>;
|
|
10
|
+
export type ScheduledHandler<TActionState extends IActionState> = (
|
|
11
|
+
/** Context of action executed in chat. */
|
|
12
|
+
ctx: ChatContext<TActionState>,
|
|
13
|
+
/** Function that will attempt to get value from cache. If there is no value found, corresponding cached state factory will be called. */
|
|
14
|
+
getCached: CachedValueAccessor,
|
|
15
|
+
/** State of an action being executed. */
|
|
16
|
+
state: TActionState) => Promise<void>;
|
|
17
|
+
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../types/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,MAAM,cAAc,CAAC,YAAY,SAAS,YAAY,IAAI;AAC5D,oEAAoE;AACpE,GAAG,EAAE,cAAc,CAAC,YAAY,CAAC;AACjC,yCAAyC;AACzC,KAAK,EAAE,YAAY,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,MAAM,MAAM,gBAAgB,CAAC,YAAY,SAAS,YAAY,IAAI;AAC9D,0CAA0C;AAC1C,GAAG,EAAE,WAAW,CAAC,YAAY,CAAC;AAC9B,yIAAyI;AACzI,SAAS,EAAE,mBAAmB;AAC9B,yCAAyC;AACzC,KAAK,EAAE,YAAY,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageSendingOptions.d.ts","sourceRoot":"","sources":["../../types/messageSendingOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IAClC,GAAG,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,yBAA0B,SAAQ,qBAAqB;IACpE,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const MessageType: {
|
|
2
|
+
readonly Text: "__msg:Text";
|
|
3
|
+
readonly Sticker: "__msg:Sticker";
|
|
4
|
+
readonly Animation: "__msg:Animation";
|
|
5
|
+
readonly Document: "__msg:Document";
|
|
6
|
+
readonly Voice: "__msg:Voice";
|
|
7
|
+
readonly Audio: "__msg:Audio";
|
|
8
|
+
readonly LeftChatMember: "__msg:LeftChatMember";
|
|
9
|
+
readonly NewChatMember: "__msg:NewChatMember";
|
|
10
|
+
readonly Poll: "__msg:Poll";
|
|
11
|
+
readonly Location: "__msg:Location";
|
|
12
|
+
readonly Photo: "__msg:Photo";
|
|
13
|
+
readonly Unknown: "__msg:Unknown";
|
|
14
|
+
};
|
|
15
|
+
export type MessageTypeValue = (typeof MessageType)[keyof typeof MessageType];
|
|
16
|
+
//# sourceMappingURL=messageTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageTypes.d.ts","sourceRoot":"","sources":["../../types/messageTypes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;;;;;;;;;;;CAad,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageType = void 0;
|
|
4
|
+
exports.MessageType = {
|
|
5
|
+
Text: '__msg:Text',
|
|
6
|
+
Sticker: '__msg:Sticker',
|
|
7
|
+
Animation: '__msg:Animation',
|
|
8
|
+
Document: '__msg:Document',
|
|
9
|
+
Voice: '__msg:Voice',
|
|
10
|
+
Audio: '__msg:Audio',
|
|
11
|
+
LeftChatMember: '__msg:LeftChatMember',
|
|
12
|
+
NewChatMember: '__msg:NewChatMember',
|
|
13
|
+
Poll: '__msg:Poll',
|
|
14
|
+
Location: '__msg:Location',
|
|
15
|
+
Photo: '__msg:Photo',
|
|
16
|
+
Unknown: '__msg:Unknown'
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replyMessage.d.ts","sourceRoot":"","sources":["../../types/replyMessage.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa,CAAC,KAAK;IAChC,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;CAC9B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ImageMessage } from '../entities/responses/imageMessage';
|
|
2
|
+
import { Reaction } from '../entities/responses/reaction';
|
|
3
|
+
import { TextMessage } from '../entities/responses/textMessage';
|
|
4
|
+
import { UnpinResponse } from '../entities/responses/unpin';
|
|
5
|
+
import { VideoMessage } from '../entities/responses/videoMessage';
|
|
6
|
+
import { IActionWithState } from './actionWithState';
|
|
7
|
+
export declare const BotResponseTypes: {
|
|
8
|
+
readonly unpin: "unpin";
|
|
9
|
+
readonly text: "text";
|
|
10
|
+
readonly image: "image";
|
|
11
|
+
readonly video: "video";
|
|
12
|
+
readonly react: "react";
|
|
13
|
+
};
|
|
14
|
+
export type BotResponse = UnpinResponse | Reaction | TextMessage | VideoMessage | ImageMessage;
|
|
15
|
+
export interface IChatResponse {
|
|
16
|
+
kind: keyof typeof BotResponseTypes;
|
|
17
|
+
chatId: number;
|
|
18
|
+
traceId: number | string;
|
|
19
|
+
action: IActionWithState;
|
|
20
|
+
}
|
|
21
|
+
export interface IReplyMessage<TType> extends IChatResponse {
|
|
22
|
+
content: TType;
|
|
23
|
+
replyId: number | undefined;
|
|
24
|
+
disableWebPreview: boolean;
|
|
25
|
+
shouldPin: boolean;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../types/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,eAAO,MAAM,gBAAgB;;;;;;CAMnB,CAAC;AAEX,MAAM,MAAM,WAAW,GACjB,aAAa,GACb,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,YAAY,CAAC;AAEnB,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,OAAO,gBAAgB,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzB,MAAM,EAAE,gBAAgB,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa,CAAC,KAAK,CAAE,SAAQ,aAAa;IACvD,OAAO,EAAE,KAAK,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;CACtB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ActionExecutionResult } from '../entities/actionExecutionResult';
|
|
2
|
+
import { IActionState } from './actionState';
|
|
3
|
+
import { ActionKey, IActionWithState } from './actionWithState';
|
|
4
|
+
export interface IStorageClient {
|
|
5
|
+
updateStateFor<TActionState extends IActionState>(action: IActionWithState, chatId: number, update: (state: TActionState) => Promise<void>): Promise<void>;
|
|
6
|
+
close(): Promise<void>;
|
|
7
|
+
load<TActionState extends IActionState>(key: ActionKey): Promise<Record<number, TActionState>>;
|
|
8
|
+
saveMetadata(actions: IActionWithState[], botName: string): Promise<void>;
|
|
9
|
+
getActionState<TActionState extends IActionState>(action: IActionWithState, chatId: number): Promise<TActionState>;
|
|
10
|
+
saveActionExecutionResult(action: IActionWithState, chatId: number, transactionResult: ActionExecutionResult): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../types/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,MAAM,WAAW,cAAc;IAC3B,cAAc,CAAC,YAAY,SAAS,YAAY,EAC5C,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,GAC/C,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,CAAC,YAAY,SAAS,YAAY,EAClC,GAAG,EAAE,SAAS,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IACzC,YAAY,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1E,cAAc,CAAC,YAAY,SAAS,YAAY,EAC5C,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,CAAC,CAAC;IACzB,yBAAyB,CACrB,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,qBAAqB,GACzC,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type Milliseconds = number & {
|
|
2
|
+
__brand: 'ms';
|
|
3
|
+
};
|
|
4
|
+
export type Seconds = number & {
|
|
5
|
+
__brand: 's';
|
|
6
|
+
};
|
|
7
|
+
export type Hours = number & {
|
|
8
|
+
__brand: 'h';
|
|
9
|
+
};
|
|
10
|
+
export type HoursOfDay = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23;
|
|
11
|
+
//# sourceMappingURL=timeValues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeValues.d.ts","sourceRoot":"","sources":["../../types/timeValues.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,CAAC;AACtD,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,GAAG,CAAA;CAAE,CAAC;AAChD,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,GAAG,CAAA;CAAE,CAAC;AAE9C,MAAM,MAAM,UAAU,GAChB,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "chz-telegram-bot",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"dependencies": {
|
|
6
|
-
"async-sema": "^3.1.1",
|
|
7
|
-
"moment": "^2.29.4",
|
|
8
|
-
"telegraf": "^4.16.3"
|
|
9
|
-
},
|
|
10
|
-
"main": "dist/index.js",
|
|
11
|
-
"types": "dist/index.d.ts",
|
|
12
|
-
"devDependencies": {
|
|
13
|
-
"@eslint/js": "^9.10.0",
|
|
14
|
-
"@types/markdown-escape": "^1.1.3",
|
|
15
|
-
"@types/node": "^22.5.5",
|
|
16
|
-
"eslint": "^9.10.0",
|
|
17
|
-
"typescript": "^5.6.2",
|
|
18
|
-
"typescript-eslint": "^8.5.0"
|
|
19
|
-
},
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "tsc",
|
|
22
|
-
"lint": "npx eslint && tsc --noEmit"
|
|
23
|
-
},
|
|
24
|
-
"overrides": {
|
|
25
|
-
"telegraf": {
|
|
26
|
-
"node-fetch": "3.3.2"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "chz-telegram-bot",
|
|
3
|
+
"version": "0.0.46",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"async-sema": "^3.1.1",
|
|
7
|
+
"moment": "^2.29.4",
|
|
8
|
+
"telegraf": "^4.16.3"
|
|
9
|
+
},
|
|
10
|
+
"main": "dist/index.js",
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@eslint/js": "^9.10.0",
|
|
14
|
+
"@types/markdown-escape": "^1.1.3",
|
|
15
|
+
"@types/node": "^22.5.5",
|
|
16
|
+
"eslint": "^9.10.0",
|
|
17
|
+
"typescript": "^5.6.2",
|
|
18
|
+
"typescript-eslint": "^8.5.0"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"lint": "npx eslint && tsc --noEmit"
|
|
23
|
+
},
|
|
24
|
+
"overrides": {
|
|
25
|
+
"telegraf": {
|
|
26
|
+
"node-fetch": "3.3.2"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|