chz-telegram-bot 0.1.3 → 0.1.5
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 +74 -12
- package/dist/dtos/incomingQuery.d.ts +9 -0
- package/dist/dtos/incomingQuery.d.ts.map +1 -0
- package/dist/dtos/incomingQuery.js +12 -0
- package/dist/dtos/responses/delay.d.ts +1 -1
- package/dist/dtos/responses/delay.d.ts.map +1 -1
- package/dist/dtos/responses/imageMessage.d.ts +1 -1
- package/dist/dtos/responses/imageMessage.d.ts.map +1 -1
- 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 +1 -1
- package/dist/dtos/responses/reaction.d.ts.map +1 -1
- package/dist/dtos/responses/textMessage.d.ts +1 -1
- package/dist/dtos/responses/textMessage.d.ts.map +1 -1
- package/dist/dtos/responses/unpin.d.ts +1 -1
- package/dist/dtos/responses/unpin.d.ts.map +1 -1
- package/dist/dtos/responses/videoMessage.d.ts +1 -1
- package/dist/dtos/responses/videoMessage.d.ts.map +1 -1
- package/dist/entities/actions/commandAction.d.ts +1 -1
- package/dist/entities/actions/commandAction.d.ts.map +1 -1
- package/dist/entities/actions/inlineQueryAction.d.ts +14 -0
- package/dist/entities/actions/inlineQueryAction.d.ts.map +1 -0
- package/dist/entities/actions/inlineQueryAction.js +40 -0
- package/dist/entities/actions/scheduledAction.d.ts +1 -1
- package/dist/entities/actions/scheduledAction.d.ts.map +1 -1
- package/dist/entities/botInstance.d.ts +8 -2
- package/dist/entities/botInstance.d.ts.map +1 -1
- package/dist/entities/botInstance.js +34 -2
- package/dist/entities/context/chatContext.d.ts +1 -1
- package/dist/entities/context/chatContext.d.ts.map +1 -1
- package/dist/entities/context/inlineQueryContext.d.ts +38 -0
- package/dist/entities/context/inlineQueryContext.d.ts.map +1 -0
- package/dist/entities/context/inlineQueryContext.js +40 -0
- package/dist/entities/context/messageContext.d.ts +1 -1
- package/dist/entities/context/messageContext.d.ts.map +1 -1
- package/dist/helpers/builders/inlineQueryActionBuilder.d.ts +34 -0
- package/dist/helpers/builders/inlineQueryActionBuilder.d.ts.map +1 -0
- package/dist/helpers/builders/inlineQueryActionBuilder.js +48 -0
- package/dist/helpers/noop.d.ts +1 -0
- package/dist/helpers/noop.d.ts.map +1 -1
- package/dist/helpers/noop.js +1 -1
- package/dist/helpers/traceFactory.d.ts +1 -1
- package/dist/helpers/traceFactory.d.ts.map +1 -1
- package/dist/helpers/traceFactory.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/main.d.ts +43 -34
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +34 -31
- package/dist/services/jsonFileStorage.d.ts +1 -1
- package/dist/services/jsonFileStorage.d.ts.map +1 -1
- package/dist/services/telegramApi.d.ts.map +1 -1
- package/dist/services/telegramApi.js +6 -1
- package/dist/types/handlers.d.ts +4 -0
- package/dist/types/handlers.d.ts.map +1 -1
- package/dist/types/response.d.ts +4 -2
- package/dist/types/response.d.ts.map +1 -1
- package/dist/types/response.js +2 -1
- package/dist/types/statefulAction.d.ts +9 -0
- package/dist/types/statefulAction.d.ts.map +1 -0
- package/dist/types/statefulAction.js +2 -0
- package/dist/types/statelessAction.d.ts +5 -0
- package/dist/types/statelessAction.d.ts.map +1 -0
- package/dist/types/statelessAction.js +2 -0
- package/dist/types/storage.d.ts +1 -1
- package/dist/types/storage.d.ts.map +1 -1
- package/dtos/incomingQuery.ts +20 -0
- package/dtos/responses/delay.ts +1 -1
- package/dtos/responses/imageMessage.ts +1 -1
- package/dtos/responses/inlineQueryResponse.ts +26 -0
- package/dtos/responses/reaction.ts +1 -1
- package/dtos/responses/textMessage.ts +1 -1
- package/dtos/responses/unpin.ts +1 -1
- package/dtos/responses/videoMessage.ts +1 -1
- package/entities/actions/commandAction.ts +1 -1
- package/entities/actions/inlineQueryAction.ts +68 -0
- package/entities/actions/scheduledAction.ts +1 -1
- package/entities/botInstance.ts +86 -4
- package/entities/context/chatContext.ts +4 -4
- package/entities/context/inlineQueryContext.ts +83 -0
- package/entities/context/messageContext.ts +1 -1
- package/helpers/builders/inlineQueryActionBuilder.ts +62 -0
- package/helpers/noop.ts +3 -1
- package/helpers/traceFactory.ts +4 -2
- package/index.ts +2 -1
- package/main.ts +64 -57
- package/package.json +1 -1
- package/services/jsonFileStorage.ts +1 -1
- package/services/telegramApi.ts +10 -1
- package/types/handlers.ts +6 -0
- package/types/response.ts +5 -2
- package/types/statelessAction.ts +5 -0
- package/types/storage.ts +1 -1
- /package/types/{actionWithState.ts → statefulAction.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageContext.d.ts","sourceRoot":"","sources":["../../../entities/context/messageContext.ts"],"names":[],"mappings":"AACA,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;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAa,MAAM,
|
|
1
|
+
{"version":3,"file":"messageContext.d.ts","sourceRoot":"","sources":["../../../entities/context/messageContext.ts"],"names":[],"mappings":"AACA,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;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D;;;;;OAKG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAc5D;;;;OAIG;IACH,KAAK,CAAC,KAAK,EAAE,aAAa;CAW7B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { InlineQueryHandler } from '../../types/handlers';
|
|
2
|
+
import { Seconds } from '../../types/timeValues';
|
|
3
|
+
import { InlineQueryAction } from '../../entities/actions/inlineQueryAction';
|
|
4
|
+
/**
|
|
5
|
+
* Builder for `InlineQueryAction`
|
|
6
|
+
*/
|
|
7
|
+
export declare class InlineQueryActionBuilder {
|
|
8
|
+
name: string;
|
|
9
|
+
pattern: RegExp;
|
|
10
|
+
active: boolean;
|
|
11
|
+
cooldownSeconds: Seconds;
|
|
12
|
+
blacklist: number[];
|
|
13
|
+
allowedUsers: number[];
|
|
14
|
+
handler: InlineQueryHandler;
|
|
15
|
+
/**
|
|
16
|
+
* Builder for `InlineQueryAction`
|
|
17
|
+
* @param name Action name, will be used for logging and storage
|
|
18
|
+
*/
|
|
19
|
+
constructor(name: string);
|
|
20
|
+
/**
|
|
21
|
+
* Defines action pattern to check if action should be executed, if not setup, check will default to true
|
|
22
|
+
* @param trigger RegExp to check
|
|
23
|
+
*/
|
|
24
|
+
on(pattern: RegExp): this;
|
|
25
|
+
/** Defines action logic itself, will be executed.
|
|
26
|
+
* @param handler Callback that will be called
|
|
27
|
+
*/
|
|
28
|
+
do(handler: InlineQueryHandler): this;
|
|
29
|
+
/** If called during building, action is marked as disabled and never checked. */
|
|
30
|
+
disabled(): this;
|
|
31
|
+
/** Builds action */
|
|
32
|
+
build(): InlineQueryAction;
|
|
33
|
+
}
|
|
34
|
+
//# 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;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAE7E;;GAEG;AACH,qBAAa,wBAAwB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAU;IAEzB,MAAM,UAAQ;IACd,eAAe,EAAE,OAAO,CAAgB;IACxC,SAAS,EAAE,MAAM,EAAE,CAAM;IACzB,YAAY,EAAE,MAAM,EAAE,CAAM;IAC5B,OAAO,EAAE,kBAAkB,CAAa;IAExC;;;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,oBAAoB;IACpB,KAAK;CAQR"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InlineQueryActionBuilder = void 0;
|
|
4
|
+
const noop_1 = require("../noop");
|
|
5
|
+
const inlineQueryAction_1 = require("../../entities/actions/inlineQueryAction");
|
|
6
|
+
/**
|
|
7
|
+
* Builder for `InlineQueryAction`
|
|
8
|
+
*/
|
|
9
|
+
class InlineQueryActionBuilder {
|
|
10
|
+
/**
|
|
11
|
+
* Builder for `InlineQueryAction`
|
|
12
|
+
* @param name Action name, will be used for logging and storage
|
|
13
|
+
*/
|
|
14
|
+
constructor(name) {
|
|
15
|
+
this.pattern = /.+/gi;
|
|
16
|
+
this.active = true;
|
|
17
|
+
this.cooldownSeconds = 0;
|
|
18
|
+
this.blacklist = [];
|
|
19
|
+
this.allowedUsers = [];
|
|
20
|
+
this.handler = noop_1.Noop.call;
|
|
21
|
+
this.name = name;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Defines action pattern to check if action should be executed, if not setup, check will default to true
|
|
25
|
+
* @param trigger RegExp to check
|
|
26
|
+
*/
|
|
27
|
+
on(pattern) {
|
|
28
|
+
this.pattern = pattern;
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
/** Defines action logic itself, will be executed.
|
|
32
|
+
* @param handler Callback that will be called
|
|
33
|
+
*/
|
|
34
|
+
do(handler) {
|
|
35
|
+
this.handler = handler;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
/** If called during building, action is marked as disabled and never checked. */
|
|
39
|
+
disabled() {
|
|
40
|
+
this.active = false;
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
/** Builds action */
|
|
44
|
+
build() {
|
|
45
|
+
return new inlineQueryAction_1.InlineQueryAction(this.handler, this.name, this.active, this.pattern);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.InlineQueryActionBuilder = InlineQueryActionBuilder;
|
package/dist/helpers/noop.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare class Noop {
|
|
|
3
3
|
static NoResponse: BotResponse[];
|
|
4
4
|
static true<T1>(arg1: T1): boolean;
|
|
5
5
|
static false<T1>(arg1: T1): boolean;
|
|
6
|
+
static call<T1>(arg1: T1): Promise<void>;
|
|
6
7
|
static call<T1, T2>(arg1: T1, arg2: T2): Promise<void>;
|
|
7
8
|
}
|
|
8
9
|
//# sourceMappingURL=noop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../../helpers/noop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,qBAAa,IAAI;IACb,MAAM,CAAC,UAAU,EAAE,WAAW,EAAE,CAAM;IACtC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE;IAGxB,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../../helpers/noop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,qBAAa,IAAI;IACb,MAAM,CAAC,UAAU,EAAE,WAAW,EAAE,CAAM;IACtC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE;IAGxB,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE;WAIZ,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;WACjC,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAE/D"}
|
package/dist/helpers/noop.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TraceId } from '../types/trace';
|
|
2
|
-
export declare function createTrace<T extends object>(traceOwner: T, botName: string, traceName: string): TraceId;
|
|
2
|
+
export declare function createTrace<T extends object>(traceOwner: T | string, botName: string, traceName: string): TraceId;
|
|
3
3
|
//# sourceMappingURL=traceFactory.d.ts.map
|
|
@@ -1 +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,CAAC,CAAC,SAAS,MAAM,EACxC,UAAU,EAAE,CAAC,
|
|
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,CAAC,CAAC,SAAS,MAAM,EACxC,UAAU,EAAE,CAAC,GAAG,MAAM,EACtB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAIa,OAAO,CACxC"}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createTrace = createTrace;
|
|
4
4
|
function createTrace(traceOwner, botName, traceName) {
|
|
5
|
-
return `${traceOwner.constructor.name}:${botName}-${traceName}`;
|
|
5
|
+
return `${typeof traceOwner == 'string' ? traceOwner : traceOwner.constructor.name}:${botName}-${traceName}`;
|
|
6
6
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { botOrchestrator } from './main';
|
|
2
|
+
export { InlineQueryActionBuilder } from './helpers/builders/inlineQueryActionBuilder';
|
|
2
3
|
export { CommandActionBuilder } from './helpers/builders/commandActionBuilder';
|
|
3
4
|
export { CommandActionBuilderWithState } from './helpers/builders/commandActionBuilder';
|
|
4
5
|
export { IStorageClient } from './types/storage';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qBAAqB,CAAC;AACpC,cAAc,mCAAmC,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,10 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.MessageType = exports.CommandActionBuilderWithState = exports.CommandActionBuilder = exports.
|
|
17
|
+
exports.MessageType = exports.CommandActionBuilderWithState = exports.CommandActionBuilder = exports.InlineQueryActionBuilder = exports.botOrchestrator = void 0;
|
|
18
18
|
var main_1 = require("./main");
|
|
19
|
-
Object.defineProperty(exports, "
|
|
20
|
-
|
|
19
|
+
Object.defineProperty(exports, "botOrchestrator", { enumerable: true, get: function () { return main_1.botOrchestrator; } });
|
|
20
|
+
var inlineQueryActionBuilder_1 = require("./helpers/builders/inlineQueryActionBuilder");
|
|
21
|
+
Object.defineProperty(exports, "InlineQueryActionBuilder", { enumerable: true, get: function () { return inlineQueryActionBuilder_1.InlineQueryActionBuilder; } });
|
|
21
22
|
var commandActionBuilder_1 = require("./helpers/builders/commandActionBuilder");
|
|
22
23
|
Object.defineProperty(exports, "CommandActionBuilder", { enumerable: true, get: function () { return commandActionBuilder_1.CommandActionBuilder; } });
|
|
23
24
|
var commandActionBuilder_2 = require("./helpers/builders/commandActionBuilder");
|
package/dist/main.d.ts
CHANGED
|
@@ -6,38 +6,47 @@ import { Seconds } from './types/timeValues';
|
|
|
6
6
|
import { IScheduler } from './types/scheduler';
|
|
7
7
|
import { ILogger } from './types/logger';
|
|
8
8
|
import { ActionStateBase } from './entities/states/actionStateBase';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/** Storage
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
9
|
+
import { InlineQueryAction } from './entities/actions/inlineQueryAction';
|
|
10
|
+
declare class BotOrchestrator {
|
|
11
|
+
bots: BotInstance[];
|
|
12
|
+
/**
|
|
13
|
+
* Starts bot
|
|
14
|
+
*/
|
|
15
|
+
startBot(options: {
|
|
16
|
+
/** Bot name, used in logging */
|
|
17
|
+
name: string;
|
|
18
|
+
/** Path to file containing Telegram Bot token. */
|
|
19
|
+
tokenFilePath: string;
|
|
20
|
+
actions: {
|
|
21
|
+
/** Collection of actions that will be executed as a response to message from used. Created using `CommandActionBuilder`.*/
|
|
22
|
+
commands: CommandAction<ActionStateBase>[];
|
|
23
|
+
/** Collection of actions that will be executed on timer. Created using `ScheduledActionBuilder`.*/
|
|
24
|
+
scheduled: ScheduledAction<ActionStateBase>[];
|
|
25
|
+
/** Collection of actions that will handle inline queries */
|
|
26
|
+
inlineQueries: InlineQueryAction[];
|
|
27
|
+
};
|
|
28
|
+
/** Object containing chat name and chat id pairs. Used for logging and execution of scheduled action. */
|
|
29
|
+
chats: Record<string, number>;
|
|
30
|
+
/** 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.*/
|
|
31
|
+
storagePath?: string;
|
|
32
|
+
/** Period of time between execution of scheduled actions. */
|
|
33
|
+
scheduledPeriod?: Seconds;
|
|
34
|
+
/** If true, telegram API objects will be logged instead of message content. */
|
|
35
|
+
verboseLoggingForIncomingMessage?: boolean;
|
|
36
|
+
services?: {
|
|
37
|
+
/** Storage client for bot state storage. If not provided, default `JsonFileStorage` will be used. */
|
|
38
|
+
storageClient?: IStorageClient;
|
|
39
|
+
/** Logger client for bot logging. If not provided, default `JsonFileStorage` will be used. */
|
|
40
|
+
logger?: ILogger;
|
|
41
|
+
/** Scheduler client for bot scheduling. If not provided, default `NodeTimeoutScheduler` will be used. */
|
|
42
|
+
scheduler?: IScheduler;
|
|
43
|
+
};
|
|
44
|
+
}): Promise<BotInstance>;
|
|
45
|
+
/**
|
|
46
|
+
* Terminates all scheduled tasks, closes storage connections and stops all bots.
|
|
47
|
+
*/
|
|
48
|
+
stopBots(reason: string): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
export declare const botOrchestrator: BotOrchestrator;
|
|
51
|
+
export {};
|
|
43
52
|
//# sourceMappingURL=main.d.ts.map
|
package/dist/main.d.ts.map
CHANGED
|
@@ -1 +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,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../main.ts"],"names":[],"mappings":"AACA,OAA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GAAyG;YACzG,SAAS,CAAC,EAAE,UAAU,CAAC;SAC1B,CAAC;KACL;IAuBD;;OAEG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM;CAKhC;AAED,eAAO,MAAM,eAAe,iBAAwB,CAAC"}
|
package/dist/main.js
CHANGED
|
@@ -1,38 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.stopBots = stopBots;
|
|
3
|
+
exports.botOrchestrator = void 0;
|
|
5
4
|
const promises_1 = require("fs/promises");
|
|
6
5
|
const botInstance_1 = require("./entities/botInstance");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
token,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
class BotOrchestrator {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.bots = [];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Starts bot
|
|
12
|
+
*/
|
|
13
|
+
async startBot(options) {
|
|
14
|
+
const token = await (0, promises_1.readFile)(options.tokenFilePath, 'utf8');
|
|
15
|
+
const bot = new botInstance_1.BotInstance({
|
|
16
|
+
name: options.name,
|
|
17
|
+
token,
|
|
18
|
+
actions: options.actions,
|
|
19
|
+
chats: options.chats,
|
|
20
|
+
storagePath: options.storagePath,
|
|
21
|
+
scheduledPeriod: options.scheduledPeriod,
|
|
22
|
+
verboseLoggingForIncomingMessage: options.verboseLoggingForIncomingMessage,
|
|
23
|
+
services: {
|
|
24
|
+
storageClient: options.services?.storageClient,
|
|
25
|
+
logger: options.services?.logger,
|
|
26
|
+
scheduler: options.services?.scheduler
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
this.bots.push(bot);
|
|
30
|
+
return bot;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Terminates all scheduled tasks, closes storage connections and stops all bots.
|
|
34
|
+
*/
|
|
35
|
+
async stopBots(reason) {
|
|
36
|
+
for (const bot of this.bots) {
|
|
37
|
+
await bot.stop(reason);
|
|
26
38
|
}
|
|
27
|
-
});
|
|
28
|
-
bots.push(bot);
|
|
29
|
-
return bot;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Terminates all scheduled tasks, closes storage connections and stops all bots.
|
|
33
|
-
*/
|
|
34
|
-
async function stopBots(reason) {
|
|
35
|
-
for (const bot of bots) {
|
|
36
|
-
await bot.stop(reason);
|
|
37
39
|
}
|
|
38
40
|
}
|
|
41
|
+
exports.botOrchestrator = new BotOrchestrator();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IStorageClient } from '../types/storage';
|
|
2
2
|
import { IActionState } from '../types/actionState';
|
|
3
|
-
import { IActionWithState, ActionKey } from '../types/
|
|
3
|
+
import { IActionWithState, ActionKey } from '../types/statefulAction';
|
|
4
4
|
export declare class JsonFileStorage implements IStorageClient {
|
|
5
5
|
private readonly locks;
|
|
6
6
|
private readonly cache;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonFileStorage.d.ts","sourceRoot":"","sources":["../../services/jsonFileStorage.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"jsonFileStorage.d.ts","sourceRoot":"","sources":["../../services/jsonFileStorage.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EA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AAe;CAmFhC"}
|
|
@@ -23,7 +23,9 @@ class TelegramApiService {
|
|
|
23
23
|
await this.processResponse(response);
|
|
24
24
|
}
|
|
25
25
|
catch (error) {
|
|
26
|
-
this.logger.errorWithTraceId(this.botName, response.traceId,
|
|
26
|
+
this.logger.errorWithTraceId(this.botName, response.traceId, 'chatInfo' in response
|
|
27
|
+
? response.chatInfo.name
|
|
28
|
+
: 'Unknown', error, response);
|
|
27
29
|
}
|
|
28
30
|
},
|
|
29
31
|
priority: response.createdAt + offset
|
|
@@ -82,6 +84,9 @@ class TelegramApiService {
|
|
|
82
84
|
state.pinnedMessages = state.pinnedMessages.filter((x) => x != response.messageId);
|
|
83
85
|
});
|
|
84
86
|
break;
|
|
87
|
+
case 'inlineQuery':
|
|
88
|
+
await this.telegram.answerInlineQuery(response.queryId, response.queryResults, { cache_time: 3600 });
|
|
89
|
+
break;
|
|
85
90
|
case 'delay':
|
|
86
91
|
break;
|
|
87
92
|
}
|
package/dist/types/handlers.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { ChatContext } from '../entities/context/chatContext';
|
|
2
|
+
import { InlineQueryContext } from '../entities/context/inlineQueryContext';
|
|
2
3
|
import { MessageContext } from '../entities/context/messageContext';
|
|
3
4
|
import { IActionState } from './actionState';
|
|
4
5
|
import { CachedValueAccessor } from './cachedValueAccessor';
|
|
6
|
+
export type InlineQueryHandler = (
|
|
7
|
+
/** Context of inline query executed in chat, in response to a message. */
|
|
8
|
+
ctx: InlineQueryContext) => Promise<void>;
|
|
5
9
|
export type CommandHandler<TActionState extends IActionState> = (
|
|
6
10
|
/** Context of action executed in chat, in response to a message. */
|
|
7
11
|
ctx: MessageContext<TActionState>,
|
|
@@ -1 +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,cA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Y,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"}
|
package/dist/types/response.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ChatInfo } from '../dtos/chatInfo';
|
|
2
2
|
import { DelayResponse } from '../dtos/responses/delay';
|
|
3
3
|
import { ImageMessage } from '../dtos/responses/imageMessage';
|
|
4
|
+
import { InlineQueryResponse } from '../dtos/responses/inlineQueryResponse';
|
|
4
5
|
import { Reaction } from '../dtos/responses/reaction';
|
|
5
6
|
import { TextMessage } from '../dtos/responses/textMessage';
|
|
6
7
|
import { UnpinResponse } from '../dtos/responses/unpin';
|
|
7
8
|
import { VideoMessage } from '../dtos/responses/videoMessage';
|
|
8
9
|
import { IActionState } from './actionState';
|
|
9
|
-
import { IActionWithState } from './
|
|
10
|
+
import { IActionWithState } from './statefulAction';
|
|
10
11
|
import { TraceId } from './trace';
|
|
11
12
|
export declare const BotResponseTypes: {
|
|
12
13
|
readonly unpin: "unpin";
|
|
@@ -15,8 +16,9 @@ export declare const BotResponseTypes: {
|
|
|
15
16
|
readonly video: "video";
|
|
16
17
|
readonly react: "react";
|
|
17
18
|
readonly delay: "delay";
|
|
19
|
+
readonly inlineQuery: "inlineQuery";
|
|
18
20
|
};
|
|
19
|
-
export type BotResponse = UnpinResponse | Reaction | TextMessage | VideoMessage | DelayResponse | ImageMessage;
|
|
21
|
+
export type BotResponse = UnpinResponse | Reaction | TextMessage | VideoMessage | DelayResponse | InlineQueryResponse | ImageMessage;
|
|
20
22
|
export interface IChatResponse {
|
|
21
23
|
readonly kind: keyof typeof BotResponseTypes;
|
|
22
24
|
readonly chatInfo: ChatInfo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../types/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../types/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,eAAO,MAAM,gBAAgB;;;;;;;;CAQnB,CAAC;AAEX,MAAM,MAAM,WAAW,GACjB,aAAa,GACb,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,aAAa,GACb,mBAAmB,GACnB,YAAY,CAAC;AAEnB,MAAM,WAAW,aAAa;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,gBAAgB,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,aAAa,CAAC,KAAK,CAAE,SAAQ,aAAa;IACvD,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC/B"}
|
package/dist/types/response.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IActionState } from './actionState';
|
|
2
|
+
export type ActionKey = string & {
|
|
3
|
+
__brand: 'actionKey';
|
|
4
|
+
};
|
|
5
|
+
export interface IActionWithState<TActionState extends IActionState> {
|
|
6
|
+
readonly key: ActionKey;
|
|
7
|
+
readonly stateConstructor: () => TActionState;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=statefulAction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statefulAction.d.ts","sourceRoot":"","sources":["../../types/statefulAction.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,CAAC,YAAY,SAAS,YAAY;IAC/D,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,YAAY,CAAC;CACjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statelessAction.d.ts","sourceRoot":"","sources":["../../types/statelessAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,WAAW,mBAAmB;IAChC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;CAC3B"}
|
package/dist/types/storage.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IActionState } from './actionState';
|
|
2
|
-
import { ActionKey, IActionWithState } from './
|
|
2
|
+
import { ActionKey, IActionWithState } from './statefulAction';
|
|
3
3
|
export interface IStorageClient {
|
|
4
4
|
updateStateFor<TActionState extends IActionState>(action: IActionWithState<TActionState>, chatId: number, update: (state: TActionState) => Promise<void>): Promise<void>;
|
|
5
5
|
close(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../types/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../types/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE/D,MAAM,WAAW,cAAc;IAC3B,cAAc,CAAC,YAAY,SAAS,YAAY,EAC5C,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,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,YAAY,SAAS,YAAY,EAC1C,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,EAAE,EACzC,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,cAAc,CAAC,YAAY,SAAS,YAAY,EAC5C,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,MAAM,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,CAAC,CAAC;IACzB,yBAAyB,CAAC,YAAY,SAAS,YAAY,EACvD,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,GACpB,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TraceId } from '../types/trace';
|
|
2
|
+
|
|
3
|
+
export class IncomingInlineQuery {
|
|
4
|
+
readonly queryId: string;
|
|
5
|
+
readonly query: string;
|
|
6
|
+
readonly userId: number;
|
|
7
|
+
readonly traceId: TraceId;
|
|
8
|
+
|
|
9
|
+
constructor(
|
|
10
|
+
queryId: string,
|
|
11
|
+
query: string,
|
|
12
|
+
userId: number,
|
|
13
|
+
traceId: TraceId
|
|
14
|
+
) {
|
|
15
|
+
this.queryId = queryId;
|
|
16
|
+
this.query = query;
|
|
17
|
+
this.userId = userId;
|
|
18
|
+
this.traceId = traceId;
|
|
19
|
+
}
|
|
20
|
+
}
|
package/dtos/responses/delay.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IActionState } from '../../types/actionState';
|
|
2
|
-
import { IActionWithState } from '../../types/
|
|
2
|
+
import { IActionWithState } from '../../types/statefulAction';
|
|
3
3
|
import { BotResponseTypes, IChatResponse } from '../../types/response';
|
|
4
4
|
import { Milliseconds } from '../../types/timeValues';
|
|
5
5
|
import { TraceId } from '../../types/trace';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InputFile } from 'telegraf/types';
|
|
2
2
|
import { BotResponseTypes, IReplyMessage } from '../../types/response';
|
|
3
3
|
import { MessageSendingOptions } from '../../types/messageSendingOptions';
|
|
4
|
-
import { IActionWithState } from '../../types/
|
|
4
|
+
import { IActionWithState } from '../../types/statefulAction';
|
|
5
5
|
import { IActionState } from '../../types/actionState';
|
|
6
6
|
import { ChatInfo } from '../chatInfo';
|
|
7
7
|
import { TraceId } from '../../types/trace';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { InlineQueryResult } from 'telegraf/types';
|
|
2
|
+
import { InlineQueryAction } from '../../entities/actions/inlineQueryAction';
|
|
3
|
+
import { BotResponseTypes } from '../../types/response';
|
|
4
|
+
import { TraceId } from '../../types/trace';
|
|
5
|
+
|
|
6
|
+
export class InlineQueryResponse {
|
|
7
|
+
readonly kind = BotResponseTypes.inlineQuery;
|
|
8
|
+
readonly createdAt = Date.now();
|
|
9
|
+
|
|
10
|
+
readonly queryId: string;
|
|
11
|
+
readonly traceId: TraceId;
|
|
12
|
+
readonly action: InlineQueryAction;
|
|
13
|
+
readonly queryResults: InlineQueryResult[];
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
queryResult: InlineQueryResult[],
|
|
17
|
+
queryId: string,
|
|
18
|
+
traceId: TraceId,
|
|
19
|
+
action: InlineQueryAction
|
|
20
|
+
) {
|
|
21
|
+
this.queryResults = queryResult;
|
|
22
|
+
this.queryId = queryId;
|
|
23
|
+
this.traceId = traceId;
|
|
24
|
+
this.action = action;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TelegramEmoji } from 'telegraf/types';
|
|
2
2
|
import { BotResponseTypes, IChatResponse } from '../../types/response';
|
|
3
|
-
import { IActionWithState } from '../../types/
|
|
3
|
+
import { IActionWithState } from '../../types/statefulAction';
|
|
4
4
|
import { IActionState } from '../../types/actionState';
|
|
5
5
|
import { ChatInfo } from '../chatInfo';
|
|
6
6
|
import { TraceId } from '../../types/trace';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TextMessageSendingOptions } from '../../types/messageSendingOptions';
|
|
2
2
|
import { BotResponseTypes, IReplyMessage } from '../../types/response';
|
|
3
|
-
import { IActionWithState } from '../../types/
|
|
3
|
+
import { IActionWithState } from '../../types/statefulAction';
|
|
4
4
|
import { IActionState } from '../../types/actionState';
|
|
5
5
|
import { ChatInfo } from '../chatInfo';
|
|
6
6
|
import { TraceId } from '../../types/trace';
|
package/dtos/responses/unpin.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BotResponseTypes, IChatResponse } from '../../types/response';
|
|
2
|
-
import { IActionWithState } from '../../types/
|
|
2
|
+
import { IActionWithState } from '../../types/statefulAction';
|
|
3
3
|
import { IActionState } from '../../types/actionState';
|
|
4
4
|
import { ChatInfo } from '../chatInfo';
|
|
5
5
|
import { TraceId } from '../../types/trace';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InputFile } from 'telegraf/types';
|
|
2
2
|
import { BotResponseTypes, IReplyMessage } from '../../types/response';
|
|
3
3
|
import { MessageSendingOptions } from '../../types/messageSendingOptions';
|
|
4
|
-
import { IActionWithState } from '../../types/
|
|
4
|
+
import { IActionWithState } from '../../types/statefulAction';
|
|
5
5
|
import { IActionState } from '../../types/actionState';
|
|
6
6
|
import { ChatInfo } from '../chatInfo';
|
|
7
7
|
import { TraceId } from '../../types/trace';
|