chz-telegram-bot 0.0.14 → 0.0.16
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/{transactionResult.js → actionExecutionResult.js} +3 -2
- package/dist/entities/actions/commandAction.d.ts +4 -4
- package/dist/entities/actions/commandAction.d.ts.map +1 -1
- package/dist/entities/actions/commandAction.js +12 -11
- package/dist/entities/actions/scheduledAction.d.ts +5 -5
- package/dist/entities/actions/scheduledAction.d.ts.map +1 -1
- package/dist/entities/actions/scheduledAction.js +10 -9
- package/dist/entities/{bot.d.ts → botInstance.d.ts} +5 -5
- package/dist/entities/botInstance.d.ts.map +1 -0
- package/dist/entities/{bot.js → botInstance.js} +18 -20
- package/dist/entities/cachedStateFactory.d.ts +1 -1
- package/dist/entities/cachedStateFactory.d.ts.map +1 -1
- package/dist/entities/cachedStateFactory.js +2 -1
- package/dist/entities/commandTriggerCheckResult.d.ts +1 -1
- package/dist/entities/commandTriggerCheckResult.d.ts.map +1 -1
- package/dist/entities/commandTriggerCheckResult.js +2 -1
- package/dist/entities/context/chatContext.d.ts +1 -1
- package/dist/entities/context/chatContext.d.ts.map +1 -1
- package/dist/entities/context/chatContext.js +8 -10
- package/dist/entities/context/messageContext.d.ts +3 -3
- package/dist/entities/context/messageContext.d.ts.map +1 -1
- package/dist/entities/context/messageContext.js +14 -16
- package/dist/entities/incomingMessage.d.ts +1 -1
- package/dist/entities/incomingMessage.d.ts.map +1 -1
- package/dist/entities/incomingMessage.js +2 -1
- package/dist/entities/responses/imageMessage.d.ts +2 -2
- package/dist/entities/responses/imageMessage.d.ts.map +1 -1
- package/dist/entities/responses/imageMessage.js +2 -1
- package/dist/entities/responses/reaction.d.ts +1 -1
- package/dist/entities/responses/reaction.d.ts.map +1 -1
- package/dist/entities/responses/reaction.js +2 -1
- package/dist/entities/responses/textMessage.d.ts +2 -2
- package/dist/entities/responses/textMessage.d.ts.map +1 -1
- package/dist/entities/responses/textMessage.js +2 -1
- package/dist/entities/responses/videoMessage.d.ts +2 -2
- package/dist/entities/responses/videoMessage.d.ts.map +1 -1
- package/dist/entities/responses/videoMessage.js +2 -1
- package/dist/entities/states/actionStateBase.d.ts +2 -2
- package/dist/entities/states/actionStateBase.d.ts.map +1 -1
- package/dist/entities/states/actionStateBase.js +2 -1
- package/dist/entities/taskRecord.d.ts +1 -1
- package/dist/entities/taskRecord.d.ts.map +1 -1
- package/dist/entities/taskRecord.js +2 -1
- package/dist/helpers/builders/commandActionBuilder.d.ts +3 -3
- package/dist/helpers/builders/commandActionBuilder.d.ts.map +1 -1
- package/dist/helpers/builders/commandActionBuilder.js +9 -12
- package/dist/helpers/builders/scheduledActionBuilder.d.ts +3 -3
- package/dist/helpers/builders/scheduledActionBuilder.d.ts.map +1 -1
- package/dist/helpers/builders/scheduledActionBuilder.js +8 -10
- package/dist/helpers/noop.d.ts +1 -2
- package/dist/helpers/noop.d.ts.map +1 -1
- package/dist/helpers/noop.js +2 -1
- package/dist/helpers/toArray.d.ts +1 -1
- package/dist/helpers/toArray.d.ts.map +1 -1
- package/dist/helpers/toArray.js +1 -1
- package/dist/index.d.ts +7 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -15
- package/dist/main.d.ts +5 -5
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +6 -9
- package/dist/services/jsonFileStorage.d.ts +5 -5
- package/dist/services/jsonFileStorage.d.ts.map +1 -1
- package/dist/services/jsonFileStorage.js +2 -1
- package/dist/services/logger.d.ts +3 -3
- package/dist/services/logger.d.ts.map +1 -1
- package/dist/services/logger.js +3 -2
- package/dist/services/taskScheduler.d.ts +3 -3
- package/dist/services/taskScheduler.d.ts.map +1 -1
- package/dist/services/taskScheduler.js +8 -10
- package/dist/services/telegramApi.d.ts +6 -6
- package/dist/services/telegramApi.d.ts.map +1 -1
- package/dist/services/telegramApi.js +17 -19
- package/dist/types/actionState.d.ts +1 -1
- package/dist/types/actionState.d.ts.map +1 -1
- package/dist/types/actionWithState.d.ts +2 -2
- package/dist/types/actionWithState.d.ts.map +1 -1
- package/dist/types/commandCondition.d.ts +2 -2
- package/dist/types/commandCondition.d.ts.map +1 -1
- package/dist/types/handlers.d.ts +3 -3
- package/dist/types/handlers.d.ts.map +1 -1
- package/dist/types/replyMessage.d.ts +1 -1
- package/dist/types/replyMessage.d.ts.map +1 -1
- package/dist/types/storage.d.ts +4 -4
- package/dist/types/storage.d.ts.map +1 -1
- package/entities/{transactionResult.ts → actionExecutionResult.ts} +2 -2
- package/entities/actions/commandAction.ts +10 -10
- package/entities/actions/scheduledAction.ts +13 -13
- package/entities/{bot.ts → botInstance.ts} +17 -17
- package/entities/cachedStateFactory.ts +1 -1
- package/entities/commandTriggerCheckResult.ts +1 -1
- package/entities/context/chatContext.ts +4 -4
- package/entities/context/messageContext.ts +8 -8
- package/entities/incomingMessage.ts +1 -1
- package/entities/responses/imageMessage.ts +2 -2
- package/entities/responses/reaction.ts +1 -1
- package/entities/responses/textMessage.ts +2 -2
- package/entities/responses/videoMessage.ts +2 -2
- package/entities/states/actionStateBase.ts +2 -2
- package/entities/taskRecord.ts +1 -1
- package/helpers/builders/commandActionBuilder.ts +5 -5
- package/helpers/builders/scheduledActionBuilder.ts +4 -4
- package/helpers/noop.ts +1 -3
- package/helpers/toArray.ts +1 -1
- package/index.ts +7 -30
- package/main.ts +9 -9
- package/package.json +1 -1
- package/services/jsonFileStorage.ts +6 -6
- package/services/logger.ts +2 -2
- package/services/taskScheduler.ts +6 -6
- package/services/telegramApi.ts +15 -15
- package/types/actionState.ts +1 -1
- package/types/actionWithState.ts +2 -2
- package/types/commandCondition.ts +2 -2
- package/types/handlers.ts +3 -3
- package/types/replyMessage.ts +1 -1
- package/types/storage.ts +4 -5
- package/dist/entities/bot.d.ts.map +0 -1
- package/dist/entities/transactionResult.d.ts +0 -7
- package/dist/entities/transactionResult.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actionExecutionResult.d.ts","sourceRoot":"","sources":["../../entities/actionExecutionResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,qBAAa,qBAAqB;IAC9B,IAAI,EAAE,YAAY,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;gBAEV,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO;CAIxD"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.ActionExecutionResult = void 0;
|
|
4
|
+
class ActionExecutionResult {
|
|
4
5
|
constructor(data, shouldUpdate) {
|
|
5
6
|
this.data = data;
|
|
6
7
|
this.shouldUpdate = shouldUpdate;
|
|
7
8
|
}
|
|
8
9
|
}
|
|
9
|
-
exports.
|
|
10
|
+
exports.ActionExecutionResult = ActionExecutionResult;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import MessageContext from '../context/messageContext';
|
|
2
|
-
import IActionWithState from '../../types/actionWithState';
|
|
3
|
-
import IActionState from '../../types/actionState';
|
|
4
1
|
import { CommandHandler } from '../../types/handlers';
|
|
5
2
|
import { CommandCondition } from '../../types/commandCondition';
|
|
6
3
|
import { Seconds } from '../../types/timeValues';
|
|
7
|
-
|
|
4
|
+
import { IActionState } from '../../types/actionState';
|
|
5
|
+
import { IActionWithState } from '../../types/actionWithState';
|
|
6
|
+
import { MessageContext } from '../context/messageContext';
|
|
7
|
+
export declare class CommandAction<TActionState extends IActionState> implements IActionWithState {
|
|
8
8
|
triggers: (string | RegExp)[];
|
|
9
9
|
handler: CommandHandler<TActionState>;
|
|
10
10
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/commandAction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commandAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/commandAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAGjD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAI3D,qBAAa,aAAa,CAAC,YAAY,SAAS,YAAY,CACxD,YAAW,gBAAgB;IAE3B,QAAQ,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC9B,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,OAAO,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC1C,gBAAgB,EAAE,MAAM,YAAY,CAAC;IACrC,GAAG,EAAE,MAAM,CAAC;gBAGR,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,EACxD,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,EACrC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,OAAO,EACjB,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,EAC7B,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,EAC3B,SAAS,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACzC,gBAAgB,EAAE,MAAM,YAAY;IAelC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,YAAY,CAAC;IAgD5C,OAAO,CAAC,YAAY;CA0CvB"}
|
|
@@ -3,15 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
6
|
+
exports.CommandAction = void 0;
|
|
7
7
|
const moment_1 = __importDefault(require("moment"));
|
|
8
|
-
const logger_1 = __importDefault(require("../../services/logger"));
|
|
9
|
-
const toArray_1 = __importDefault(require("../../helpers/toArray"));
|
|
10
|
-
const commandTriggerCheckResult_1 = __importDefault(require("../commandTriggerCheckResult"));
|
|
11
8
|
const timeConvertions_1 = require("../../helpers/timeConvertions");
|
|
9
|
+
const toArray_1 = require("../../helpers/toArray");
|
|
10
|
+
const commandTriggerCheckResult_1 = require("../commandTriggerCheckResult");
|
|
11
|
+
const logger_1 = require("../../services/logger");
|
|
12
|
+
const actionExecutionResult_1 = require("../actionExecutionResult");
|
|
12
13
|
class CommandAction {
|
|
13
14
|
constructor(trigger, handler, name, active, cooldown, chatsBlacklist, allowedUsers, condition, stateConstructor) {
|
|
14
|
-
this.triggers = (0, toArray_1.
|
|
15
|
+
this.triggers = (0, toArray_1.toArray)(trigger);
|
|
15
16
|
this.handler = handler;
|
|
16
17
|
this.name = name;
|
|
17
18
|
this.cooldownInSeconds = cooldown;
|
|
@@ -31,10 +32,10 @@ class CommandAction {
|
|
|
31
32
|
const state = await ctx.storage.getActionState(this, ctx.chatId);
|
|
32
33
|
const { shouldTrigger, matchResults, skipCooldown } = this.triggers
|
|
33
34
|
.map((x) => this.checkTrigger(ctx, x, state))
|
|
34
|
-
.reduce((acc, curr) => acc.mergeWith(curr), commandTriggerCheckResult_1.
|
|
35
|
+
.reduce((acc, curr) => acc.mergeWith(curr), commandTriggerCheckResult_1.CommandTriggerCheckResult.DoNotTrigger);
|
|
35
36
|
if (!shouldTrigger)
|
|
36
37
|
return;
|
|
37
|
-
logger_1.
|
|
38
|
+
logger_1.Logger.logWithTraceId(ctx.botName, ctx.traceId, ctx.chatName, ` - Executing [${this.name}] in ${ctx.chatId}`);
|
|
38
39
|
ctx.matchResults = matchResults;
|
|
39
40
|
await this.handler(ctx, state);
|
|
40
41
|
if (skipCooldown) {
|
|
@@ -44,13 +45,13 @@ class CommandAction {
|
|
|
44
45
|
state.lastExecutedDate = (0, moment_1.default)().valueOf();
|
|
45
46
|
}
|
|
46
47
|
ctx.updateActions.forEach((action) => action(state));
|
|
47
|
-
await ctx.storage.saveActionExecutionResult(this, ctx.chatId, new
|
|
48
|
+
await ctx.storage.saveActionExecutionResult(this, ctx.chatId, new actionExecutionResult_1.ActionExecutionResult(state, ctx.startCooldown && shouldTrigger));
|
|
48
49
|
}
|
|
49
50
|
checkTrigger(ctx, trigger, state) {
|
|
50
51
|
let shouldTrigger = false;
|
|
51
52
|
const matchResults = [];
|
|
52
53
|
if (!ctx.fromUserId)
|
|
53
|
-
return commandTriggerCheckResult_1.
|
|
54
|
+
return commandTriggerCheckResult_1.CommandTriggerCheckResult.DontTriggerAndSkipCooldown;
|
|
54
55
|
const isUserAllowed = this.allowedUsers.length == 0 ||
|
|
55
56
|
this.allowedUsers.includes(ctx.fromUserId);
|
|
56
57
|
const cooldownInMilliseconds = (0, timeConvertions_1.secondsToMilliseconds)(this.cooldownInSeconds);
|
|
@@ -72,7 +73,7 @@ class CommandAction {
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
return new commandTriggerCheckResult_1.
|
|
76
|
+
return new commandTriggerCheckResult_1.CommandTriggerCheckResult(shouldTrigger, matchResults, !isUserAllowed);
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
|
-
exports.
|
|
79
|
+
exports.CommandAction = CommandAction;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Sema as Semaphore } from 'async-sema';
|
|
2
|
-
import ChatContext from '../context/chatContext';
|
|
3
|
-
import IActionWithState from '../../types/actionWithState';
|
|
4
|
-
import ActionStateBase from '../states/actionStateBase';
|
|
5
2
|
import { ScheduledHandler } from '../../types/handlers';
|
|
6
|
-
import CachedStateFactory from '../cachedStateFactory';
|
|
7
3
|
import { HoursOfDay } from '../../types/timeValues';
|
|
8
|
-
|
|
4
|
+
import { IActionWithState } from '../../types/actionWithState';
|
|
5
|
+
import { CachedStateFactory } from '../cachedStateFactory';
|
|
6
|
+
import { ChatContext } from '../context/chatContext';
|
|
7
|
+
import { ActionStateBase } from '../states/actionStateBase';
|
|
8
|
+
export declare class ScheduledAction implements IActionWithState {
|
|
9
9
|
static semaphore: Semaphore;
|
|
10
10
|
name: string;
|
|
11
11
|
timeinHours: HoursOfDay;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduledAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/scheduledAction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scheduledAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/scheduledAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAK5D,qBAAa,eAAgB,YAAW,gBAAgB;IACpD,MAAM,CAAC,SAAS,YAAoB;IAEpC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,UAAU,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,GAAG,EAAE,MAAM,CAAC;IAEZ,WAAW,uBAA8B;IACzC,gBAAgB,wBAA+B;IAC/C,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACtD,OAAO,EAAE,gBAAgB,CAAC;gBAGtB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,EACzB,WAAW,EAAE,UAAU,EACvB,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EAAE,EACnB,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC;IAWnD,IAAI,CAAC,GAAG,EAAE,WAAW;YA4Bb,cAAc;IAqC5B,OAAO,CAAC,aAAa;CASxB"}
|
|
@@ -3,17 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
6
|
+
exports.ScheduledAction = void 0;
|
|
7
7
|
const moment_1 = __importDefault(require("moment"));
|
|
8
|
-
const logger_1 = __importDefault(require("../../services/logger"));
|
|
9
|
-
const taskScheduler_1 = __importDefault(require("../../services/taskScheduler"));
|
|
10
8
|
const async_sema_1 = require("async-sema");
|
|
11
|
-
const actionStateBase_1 = __importDefault(require("../states/actionStateBase"));
|
|
12
9
|
const timeConvertions_1 = require("../../helpers/timeConvertions");
|
|
10
|
+
const actionStateBase_1 = require("../states/actionStateBase");
|
|
11
|
+
const actionExecutionResult_1 = require("../actionExecutionResult");
|
|
12
|
+
const logger_1 = require("../../services/logger");
|
|
13
|
+
const taskScheduler_1 = require("../../services/taskScheduler");
|
|
13
14
|
class ScheduledAction {
|
|
14
15
|
constructor(name, handler, timeinHours, active, whitelist, cachedStateFactories) {
|
|
15
16
|
this.cachedState = new Map();
|
|
16
|
-
this.stateConstructor = () => new actionStateBase_1.
|
|
17
|
+
this.stateConstructor = () => new actionStateBase_1.ActionStateBase();
|
|
17
18
|
this.name = name;
|
|
18
19
|
this.handler = handler;
|
|
19
20
|
this.timeinHours = timeinHours;
|
|
@@ -28,10 +29,10 @@ class ScheduledAction {
|
|
|
28
29
|
const state = await ctx.storage.getActionState(this, ctx.chatId);
|
|
29
30
|
const isAllowedToTrigger = this.shouldTrigger(state);
|
|
30
31
|
if (isAllowedToTrigger) {
|
|
31
|
-
logger_1.
|
|
32
|
+
logger_1.Logger.logWithTraceId(ctx.botName, ctx.traceId, ctx.chatName, ` - Executing [${this.name}] in ${ctx.chatId}`);
|
|
32
33
|
await this.handler(ctx, (key) => this.getCachedValue(key, ctx.botName));
|
|
33
34
|
state.lastExecutedDate = (0, moment_1.default)().valueOf();
|
|
34
|
-
await ctx.storage.saveActionExecutionResult(this, ctx.chatId, new
|
|
35
|
+
await ctx.storage.saveActionExecutionResult(this, ctx.chatId, new actionExecutionResult_1.ActionExecutionResult(state, isAllowedToTrigger));
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
async getCachedValue(key, botName) {
|
|
@@ -46,7 +47,7 @@ class ScheduledAction {
|
|
|
46
47
|
const cachedItemFactory = this.cachedStateFactories.get(key);
|
|
47
48
|
const value = await cachedItemFactory.getValue();
|
|
48
49
|
this.cachedState.set(key, value);
|
|
49
|
-
taskScheduler_1.
|
|
50
|
+
taskScheduler_1.Scheduler.createOnetimeTask(`Drop cached value [${this.name} : ${key}]`, () => this.cachedState.delete(key), (0, timeConvertions_1.hoursToMilliseconds)(cachedItemFactory.invalidationTimeoutInHours), botName);
|
|
50
51
|
return value;
|
|
51
52
|
}
|
|
52
53
|
finally {
|
|
@@ -60,5 +61,5 @@ class ScheduledAction {
|
|
|
60
61
|
return isAllowedToTrigger && !hasTriggeredToday;
|
|
61
62
|
}
|
|
62
63
|
}
|
|
64
|
+
exports.ScheduledAction = ScheduledAction;
|
|
63
65
|
ScheduledAction.semaphore = new async_sema_1.Sema(1);
|
|
64
|
-
exports.default = ScheduledAction;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import CommandAction from './actions/commandAction';
|
|
2
|
-
import ScheduledAction from './actions/scheduledAction';
|
|
3
|
-
import IActionState from '../types/actionState';
|
|
4
1
|
import { IStorageClient } from '../types/storage';
|
|
5
|
-
|
|
2
|
+
import { IActionState } from '../types/actionState';
|
|
3
|
+
import { CommandAction } from './actions/commandAction';
|
|
4
|
+
import { ScheduledAction } from './actions/scheduledAction';
|
|
5
|
+
export declare class BotInstance {
|
|
6
6
|
name: string;
|
|
7
7
|
private api;
|
|
8
8
|
private telegraf;
|
|
@@ -24,4 +24,4 @@ export default class Bot {
|
|
|
24
24
|
private runScheduled;
|
|
25
25
|
private processMessages;
|
|
26
26
|
}
|
|
27
|
-
//# sourceMappingURL=
|
|
27
|
+
//# sourceMappingURL=botInstance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"botInstance.d.ts","sourceRoot":"","sources":["../../entities/botInstance.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAK5D,qBAAa,WAAW;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,GAAG,CAAqB;IAChC,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,QAAQ,CAAgC;IAChD,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,YAAY,CAAyB;IAC7C,OAAO,EAAE,cAAc,CAAC;gBAEZ,OAAO,EAAE;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,EAAE,CAAC;QACxC,SAAS,EAAE,eAAe,EAAE,CAAC;QAC7B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3B,aAAa,CAAC,EAAE,cAAc,CAAC;QAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;KACxB;IAuEK,IAAI,CAAC,IAAI,EAAE,MAAM;YAYT,YAAY;YAqBZ,eAAe;CAmBhC"}
|
|
@@ -1,51 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BotInstance = void 0;
|
|
6
4
|
const telegraf_1 = require("telegraf");
|
|
7
|
-
const telegramApi_1 = __importDefault(require("../services/telegramApi"));
|
|
8
|
-
const incomingMessage_1 = __importDefault(require("./incomingMessage"));
|
|
9
|
-
const taskScheduler_1 = __importDefault(require("../services/taskScheduler"));
|
|
10
|
-
const logger_1 = __importDefault(require("../services/logger"));
|
|
11
5
|
const timeConvertions_1 = require("../helpers/timeConvertions");
|
|
12
|
-
const jsonFileStorage_1 =
|
|
13
|
-
|
|
6
|
+
const jsonFileStorage_1 = require("../services/jsonFileStorage");
|
|
7
|
+
const telegramApi_1 = require("../services/telegramApi");
|
|
8
|
+
const logger_1 = require("../services/logger");
|
|
9
|
+
const taskScheduler_1 = require("../services/taskScheduler");
|
|
10
|
+
const incomingMessage_1 = require("./incomingMessage");
|
|
11
|
+
class BotInstance {
|
|
14
12
|
constructor(options) {
|
|
15
13
|
this.messageQueue = [];
|
|
16
14
|
this.name = options.name;
|
|
17
15
|
this.commands = options.commands;
|
|
18
16
|
this.scheduled = options.scheduled;
|
|
19
17
|
this.chats = options.chats;
|
|
20
|
-
logger_1.
|
|
18
|
+
logger_1.Logger.logWithTraceId(this.name, `System:Bot-${this.name}-Start`, 'System', 'Starting bot...');
|
|
21
19
|
this.telegraf = new telegraf_1.Telegraf(options.token);
|
|
22
20
|
this.storage =
|
|
23
21
|
options.storageClient ??
|
|
24
|
-
new jsonFileStorage_1.
|
|
25
|
-
this.api = new telegramApi_1.
|
|
22
|
+
new jsonFileStorage_1.JsonFileStorage(options.name, options.storagePath);
|
|
23
|
+
this.api = new telegramApi_1.TelegramApiService(this.name, this.telegraf, this.storage, this.chats);
|
|
26
24
|
this.telegraf.on('message', async (ctx) => {
|
|
27
|
-
const msg = new incomingMessage_1.
|
|
25
|
+
const msg = new incomingMessage_1.IncomingMessage(ctx.update.message);
|
|
28
26
|
const messageContent = msg.text || '<non-text message>';
|
|
29
27
|
const messageFromName = msg.from?.first_name ?? 'Unknown';
|
|
30
28
|
const messageFromId = msg.from?.id ?? 'Unknown';
|
|
31
|
-
logger_1.
|
|
29
|
+
logger_1.Logger.logWithTraceId(this.name, msg.traceId, msg.chatName, `${messageFromName} (${messageFromId}): ${messageContent}`);
|
|
32
30
|
if (msg.text) {
|
|
33
31
|
this.messageQueue.push(msg);
|
|
34
32
|
}
|
|
35
33
|
});
|
|
36
34
|
this.telegraf.launch();
|
|
37
|
-
taskScheduler_1.
|
|
35
|
+
taskScheduler_1.Scheduler.createTask('MessageProcessing', async () => {
|
|
38
36
|
while (this.messageQueue.length > 0) {
|
|
39
37
|
await this.processMessages();
|
|
40
38
|
}
|
|
41
39
|
}, (0, timeConvertions_1.secondsToMilliseconds)(0.3), false, this.name);
|
|
42
|
-
taskScheduler_1.
|
|
40
|
+
taskScheduler_1.Scheduler.createTask('ScheduledProcessing', async () => {
|
|
43
41
|
await this.runScheduled();
|
|
44
42
|
}, (0, timeConvertions_1.hoursToMilliseconds)(0.5), true, this.name);
|
|
45
43
|
this.storage.saveMetadata([...this.commands, ...this.scheduled], this.name);
|
|
46
44
|
}
|
|
47
45
|
async stop(code) {
|
|
48
|
-
logger_1.
|
|
46
|
+
logger_1.Logger.logWithTraceId(this.name, `System:Bot-${this.name}-Stop`, 'System', 'Stopping bot...');
|
|
49
47
|
await this.storage.close();
|
|
50
48
|
this.telegraf.stop(code);
|
|
51
49
|
}
|
|
@@ -58,7 +56,7 @@ class Bot {
|
|
|
58
56
|
}
|
|
59
57
|
catch (error) {
|
|
60
58
|
console.dir(error);
|
|
61
|
-
logger_1.
|
|
59
|
+
logger_1.Logger.errorWithTraceId(ctx.botName, ctx.traceId, chatName, error, ctx);
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
62
|
}
|
|
@@ -71,9 +69,9 @@ class Bot {
|
|
|
71
69
|
await cmd.exec(ctx);
|
|
72
70
|
}
|
|
73
71
|
catch (error) {
|
|
74
|
-
logger_1.
|
|
72
|
+
logger_1.Logger.errorWithTraceId(ctx.botName, ctx.traceId, ctx.chatName, error, ctx);
|
|
75
73
|
}
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
76
|
}
|
|
79
|
-
exports.
|
|
77
|
+
exports.BotInstance = BotInstance;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hours } from '../types/timeValues';
|
|
2
|
-
export
|
|
2
|
+
export declare class CachedStateFactory {
|
|
3
3
|
getValue: () => Promise<unknown>;
|
|
4
4
|
invalidationTimeoutInHours: Hours;
|
|
5
5
|
constructor(itemFactory: () => Promise<unknown>, invalidationTimeout: Hours);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cachedStateFactory.d.ts","sourceRoot":"","sources":["../../entities/cachedStateFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,
|
|
1
|
+
{"version":3,"file":"cachedStateFactory.d.ts","sourceRoot":"","sources":["../../entities/cachedStateFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,qBAAa,kBAAkB;IAC3B,QAAQ,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACjC,0BAA0B,EAAE,KAAK,CAAC;gBAG9B,WAAW,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,EACnC,mBAAmB,EAAE,KAAK;CAKjC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CachedStateFactory = void 0;
|
|
3
4
|
class CachedStateFactory {
|
|
4
5
|
constructor(itemFactory, invalidationTimeout) {
|
|
5
6
|
this.getValue = itemFactory;
|
|
6
7
|
this.invalidationTimeoutInHours = invalidationTimeout;
|
|
7
8
|
}
|
|
8
9
|
}
|
|
9
|
-
exports.
|
|
10
|
+
exports.CachedStateFactory = CachedStateFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandTriggerCheckResult.d.ts","sourceRoot":"","sources":["../../entities/commandTriggerCheckResult.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"commandTriggerCheckResult.d.ts","sourceRoot":"","sources":["../../entities/commandTriggerCheckResult.ts"],"names":[],"mappings":"AAAA,qBAAa,yBAAyB;IAClC,MAAM,KAAK,0BAA0B,8BAEpC;IACD,MAAM,KAAK,YAAY,8BAEtB;IAED,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,YAAY,EAAE,OAAO,CAAC;gBAGlB,aAAa,EAAE,OAAO,EACtB,YAAY,EAAE,eAAe,EAAE,EAC/B,YAAY,EAAE,OAAO;IAOzB,SAAS,CAAC,KAAK,EAAE,yBAAyB;CAO7C"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommandTriggerCheckResult = void 0;
|
|
3
4
|
class CommandTriggerCheckResult {
|
|
4
5
|
static get DontTriggerAndSkipCooldown() {
|
|
5
6
|
return new CommandTriggerCheckResult(false, [], true);
|
|
@@ -19,4 +20,4 @@ class CommandTriggerCheckResult {
|
|
|
19
20
|
return this;
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
|
-
exports.
|
|
23
|
+
exports.CommandTriggerCheckResult = CommandTriggerCheckResult;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IBotApiInteractions } from '../../services/telegramApi';
|
|
2
2
|
import { IStorageClient } from '../../types/storage';
|
|
3
|
-
export
|
|
3
|
+
export declare class ChatContext {
|
|
4
4
|
botName: string;
|
|
5
5
|
interactions: IBotApiInteractions;
|
|
6
6
|
chatId: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../../entities/context/chatContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../../entities/context/chatContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAKrD,qBAAa,WAAW;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,mBAAmB,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,OAAO,EAAE,cAAc,CAAC;gBAGpB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,mBAAmB,EACjC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,OAAO,EAAE,cAAc;IAU3B,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,OAAO;IAYxD,eAAe,CAAC,IAAI,EAAE,MAAM;IAY5B,eAAe,CAAC,IAAI,EAAE,MAAM;CAW/B"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
const textMessage_1 = __importDefault(require("../responses/textMessage"));
|
|
8
|
-
const videoMessage_1 = __importDefault(require("../responses/videoMessage"));
|
|
3
|
+
exports.ChatContext = void 0;
|
|
9
4
|
const path_1 = require("path");
|
|
5
|
+
const imageMessage_1 = require("../responses/imageMessage");
|
|
6
|
+
const textMessage_1 = require("../responses/textMessage");
|
|
7
|
+
const videoMessage_1 = require("../responses/videoMessage");
|
|
10
8
|
class ChatContext {
|
|
11
9
|
constructor(botName, interactions, chatId, chatName, traceId, storage) {
|
|
12
10
|
this.botName = botName;
|
|
@@ -17,15 +15,15 @@ class ChatContext {
|
|
|
17
15
|
this.storage = storage;
|
|
18
16
|
}
|
|
19
17
|
sendTextToChat(text, disableWebPreview) {
|
|
20
|
-
this.interactions.respond(new textMessage_1.
|
|
18
|
+
this.interactions.respond(new textMessage_1.TextMessage(text, this.chatId, undefined, this.traceId, disableWebPreview ?? false));
|
|
21
19
|
}
|
|
22
20
|
sendImageToChat(name) {
|
|
23
21
|
const filePath = `./content/${name}.png`;
|
|
24
|
-
this.interactions.respond(new imageMessage_1.
|
|
22
|
+
this.interactions.respond(new imageMessage_1.ImageMessage({ source: (0, path_1.resolve)(filePath) }, this.chatId, undefined, this.traceId));
|
|
25
23
|
}
|
|
26
24
|
sendVideoToChat(name) {
|
|
27
25
|
const filePath = `./content/${name}.mp4`;
|
|
28
|
-
this.interactions.respond(new videoMessage_1.
|
|
26
|
+
this.interactions.respond(new videoMessage_1.VideoMessage({ source: (0, path_1.resolve)(filePath) }, this.chatId, undefined, this.traceId));
|
|
29
27
|
}
|
|
30
28
|
}
|
|
31
|
-
exports.
|
|
29
|
+
exports.ChatContext = ChatContext;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import ChatContext from './chatContext';
|
|
2
|
-
import IActionState from '../../types/actionState';
|
|
3
1
|
import { IBotApiInteractions } from '../../services/telegramApi';
|
|
4
2
|
import { TelegramEmoji } from 'telegraf/types';
|
|
5
3
|
import { IStorageClient } from '../../types/storage';
|
|
6
|
-
|
|
4
|
+
import { IActionState } from '../../types/actionState';
|
|
5
|
+
import { ChatContext } from './chatContext';
|
|
6
|
+
export declare class MessageContext<TActionState extends IActionState> extends ChatContext {
|
|
7
7
|
messageId: number;
|
|
8
8
|
messageText: string;
|
|
9
9
|
matchResults: RegExpMatchArray[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageContext.d.ts","sourceRoot":"","sources":["../../../entities/context/messageContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"messageContext.d.ts","sourceRoot":"","sources":["../../../entities/context/messageContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAMvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,qBAAa,cAAc,CACvB,YAAY,SAAS,YAAY,CACnC,SAAQ,WAAW;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,gBAAgB,EAAE,CAAM;IACtC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,aAAa,EAAE,OAAO,CAAQ;IAC9B,aAAa,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC,CAAM;IACzD,YAAY,EAAE,MAAM,CAAC;gBAGjB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,mBAAmB,EACjC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,cAAc;IAUrB,WAAW,CAAC,mBAAmB,SAAS,YAAY,EACtD,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,mBAAmB,CAAC;IAU/B,WAAW,CAAC,iBAAiB,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI;IAM5D,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,OAAO;IAYvD,cAAc,CAAC,IAAI,EAAE,MAAM;IAY3B,cAAc,CAAC,IAAI,EAAE,MAAM;IAY3B,KAAK,CAAC,KAAK,EAAE,aAAa;CAK7B"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
const imageMessage_1 = __importDefault(require("../responses/imageMessage"));
|
|
8
|
-
const textMessage_1 = __importDefault(require("../responses/textMessage"));
|
|
9
|
-
const videoMessage_1 = __importDefault(require("../responses/videoMessage"));
|
|
10
|
-
const chatContext_1 = __importDefault(require("./chatContext"));
|
|
3
|
+
exports.MessageContext = void 0;
|
|
11
4
|
const path_1 = require("path");
|
|
12
|
-
const
|
|
13
|
-
|
|
5
|
+
const imageMessage_1 = require("../responses/imageMessage");
|
|
6
|
+
const reaction_1 = require("../responses/reaction");
|
|
7
|
+
const textMessage_1 = require("../responses/textMessage");
|
|
8
|
+
const videoMessage_1 = require("../responses/videoMessage");
|
|
9
|
+
const actionStateBase_1 = require("../states/actionStateBase");
|
|
10
|
+
const chatContext_1 = require("./chatContext");
|
|
11
|
+
class MessageContext extends chatContext_1.ChatContext {
|
|
14
12
|
constructor(botName, interactions, chatId, chatName, messageId, messageText, fromUserId, traceId, fromUserName, storage) {
|
|
15
13
|
super(botName, interactions, chatId, chatName, traceId, storage);
|
|
16
14
|
this.matchResults = [];
|
|
@@ -22,24 +20,24 @@ class MessageContext extends chatContext_1.default {
|
|
|
22
20
|
this.fromUserName = fromUserName;
|
|
23
21
|
}
|
|
24
22
|
async loadStateOf(commandName) {
|
|
25
|
-
return ((await this.storage.load(`command:${commandName.replace('.', '-')}`))[this.chatId] ?? new actionStateBase_1.
|
|
23
|
+
return ((await this.storage.load(`command:${commandName.replace('.', '-')}`))[this.chatId] ?? new actionStateBase_1.ActionStateBase());
|
|
26
24
|
}
|
|
27
25
|
updateState(stateUpdateAction) {
|
|
28
26
|
this.updateActions.push(stateUpdateAction);
|
|
29
27
|
}
|
|
30
28
|
replyWithText(text, disableWebPreview) {
|
|
31
|
-
this.interactions.respond(new textMessage_1.
|
|
29
|
+
this.interactions.respond(new textMessage_1.TextMessage(text, this.chatId, this.messageId, this.traceId, disableWebPreview ?? false));
|
|
32
30
|
}
|
|
33
31
|
replyWithImage(name) {
|
|
34
32
|
const filePath = `./content/${name}.png`;
|
|
35
|
-
this.interactions.respond(new imageMessage_1.
|
|
33
|
+
this.interactions.respond(new imageMessage_1.ImageMessage({ source: (0, path_1.resolve)(filePath) }, this.chatId, this.messageId, this.traceId));
|
|
36
34
|
}
|
|
37
35
|
replyWithVideo(name) {
|
|
38
36
|
const filePath = `./content/${name}.mp4`;
|
|
39
|
-
this.interactions.respond(new videoMessage_1.
|
|
37
|
+
this.interactions.respond(new videoMessage_1.VideoMessage({ source: (0, path_1.resolve)(filePath) }, this.chatId, this.messageId, this.traceId));
|
|
40
38
|
}
|
|
41
39
|
react(emoji) {
|
|
42
|
-
this.interactions.react(new reaction_1.
|
|
40
|
+
this.interactions.react(new reaction_1.Reaction(this.traceId, this.chatId, this.messageId, emoji));
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
|
-
exports.
|
|
43
|
+
exports.MessageContext = MessageContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"incomingMessage.d.ts","sourceRoot":"","sources":["../../entities/incomingMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAG5C,
|
|
1
|
+
{"version":3,"file":"incomingMessage.d.ts","sourceRoot":"","sources":["../../entities/incomingMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAG5C,qBAAa,eAAe;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,SAA2B;gBAEtB,UAAU,EAAE;QACpB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,IAAI,CAAC;QACX,IAAI,CAAC,EAAE,IAAI,CAAC;QACZ,IAAI,CAAC,EAAE,MAAM,CAAC;KACjB;CAUJ"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IncomingMessage = void 0;
|
|
3
4
|
const crypto_1 = require("crypto");
|
|
4
5
|
class IncomingMessage {
|
|
5
6
|
constructor(ctxMessage) {
|
|
@@ -14,4 +15,4 @@ class IncomingMessage {
|
|
|
14
15
|
: 'DM';
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
|
-
exports.
|
|
18
|
+
exports.IncomingMessage = IncomingMessage;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InputFile } from 'telegraf/types';
|
|
2
|
-
import IReplyMessage from '../../types/replyMessage';
|
|
3
|
-
export
|
|
2
|
+
import { IReplyMessage } from '../../types/replyMessage';
|
|
3
|
+
export declare class ImageMessage implements IReplyMessage<InputFile> {
|
|
4
4
|
content: InputFile;
|
|
5
5
|
chatId: number;
|
|
6
6
|
replyId: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageMessage.d.ts","sourceRoot":"","sources":["../../../entities/responses/imageMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,aAAa,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"imageMessage.d.ts","sourceRoot":"","sources":["../../../entities/responses/imageMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,qBAAa,YAAa,YAAW,aAAa,CAAC,SAAS,CAAC;IACzD,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,iBAAiB,UAAS;gBAGtB,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,MAAM;CAO/B"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImageMessage = void 0;
|
|
3
4
|
class ImageMessage {
|
|
4
5
|
constructor(image, chatId, replyId, traceId) {
|
|
5
6
|
this.disableWebPreview = false;
|
|
@@ -9,4 +10,4 @@ class ImageMessage {
|
|
|
9
10
|
this.traceId = traceId;
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
|
-
exports.
|
|
13
|
+
exports.ImageMessage = ImageMessage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reaction.d.ts","sourceRoot":"","sources":["../../../entities/responses/reaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,
|
|
1
|
+
{"version":3,"file":"reaction.d.ts","sourceRoot":"","sources":["../../../entities/responses/reaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,qBAAa,QAAQ;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,KAAK,EAAE,aAAa,CAAC;gBAGjB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,aAAa;CAO3B"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Reaction = void 0;
|
|
3
4
|
class Reaction {
|
|
4
5
|
constructor(traceId, chatId, messageId, emoji) {
|
|
5
6
|
this.chatId = chatId;
|
|
@@ -8,4 +9,4 @@ class Reaction {
|
|
|
8
9
|
this.traceId = traceId;
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
|
-
exports.
|
|
12
|
+
exports.Reaction = Reaction;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import IReplyMessage from '../../types/replyMessage';
|
|
2
|
-
export
|
|
1
|
+
import { IReplyMessage } from '../../types/replyMessage';
|
|
2
|
+
export declare class TextMessage implements IReplyMessage<string> {
|
|
3
3
|
content: string;
|
|
4
4
|
chatId: number;
|
|
5
5
|
replyId: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textMessage.d.ts","sourceRoot":"","sources":["../../../entities/responses/textMessage.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"textMessage.d.ts","sourceRoot":"","sources":["../../../entities/responses/textMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,qBAAa,WAAY,YAAW,aAAa,CAAC,MAAM,CAAC;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;gBAGvB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,iBAAiB,EAAE,OAAO;CAQjC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TextMessage = void 0;
|
|
3
4
|
class TextMessage {
|
|
4
5
|
constructor(text, chatId, replyId, traceId, disableWebPreview) {
|
|
5
6
|
this.content = text;
|
|
@@ -9,4 +10,4 @@ class TextMessage {
|
|
|
9
10
|
this.disableWebPreview = disableWebPreview;
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
|
-
exports.
|
|
13
|
+
exports.TextMessage = TextMessage;
|