chz-telegram-bot 0.4.0 → 0.5.0
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/bun.lock +301 -630
- package/dist/dtos/chatHistoryMessage.d.ts +3 -3
- package/dist/dtos/chatHistoryMessage.d.ts.map +1 -1
- package/dist/dtos/incomingMessage.d.ts +4 -4
- package/dist/dtos/incomingMessage.d.ts.map +1 -1
- package/dist/dtos/incomingMessage.js +1 -1
- package/dist/dtos/messageInfo.d.ts +3 -3
- package/dist/dtos/messageInfo.d.ts.map +1 -1
- package/dist/dtos/responses/inlineQueryResponse.d.ts +3 -3
- package/dist/dtos/responses/inlineQueryResponse.d.ts.map +1 -1
- package/dist/dtos/responses/reaction.d.ts +1 -1
- package/dist/dtos/responses/reaction.d.ts.map +1 -1
- package/dist/entities/context/inlineQueryContext.d.ts +3 -3
- package/dist/entities/context/inlineQueryContext.d.ts.map +1 -1
- package/dist/entities/context/messageContext.d.ts +2 -2
- package/dist/entities/context/messageContext.d.ts.map +1 -1
- package/dist/entities/context/replyContext.d.ts +2 -2
- package/dist/entities/context/replyContext.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/services/actionProcessingService.d.ts +1 -1
- package/dist/services/actionProcessingService.d.ts.map +1 -1
- package/dist/services/actionProcessingService.js +7 -9
- package/dist/services/actionProcessors/commandActionProcessor.d.ts +2 -2
- package/dist/services/actionProcessors/commandActionProcessor.d.ts.map +1 -1
- package/dist/services/actionProcessors/commandActionProcessor.js +3 -3
- package/dist/services/actionProcessors/inlineQueryActionProcessor.d.ts +1 -1
- package/dist/services/actionProcessors/inlineQueryActionProcessor.d.ts.map +1 -1
- package/dist/services/actionProcessors/inlineQueryActionProcessor.js +1 -1
- package/dist/services/telegramApi.d.ts +2 -2
- package/dist/services/telegramApi.d.ts.map +1 -1
- package/dist/services/telegramApi.js +15 -16
- package/dist/types/externalAliases.d.ts +11 -0
- package/dist/types/externalAliases.d.ts.map +1 -0
- package/dist/types/externalAliases.js +2 -0
- package/dtos/chatHistoryMessage.ts +2 -2
- package/dtos/incomingMessage.ts +7 -7
- package/dtos/messageInfo.ts +2 -2
- package/dtos/responses/inlineQueryResponse.ts +3 -3
- package/dtos/responses/reaction.ts +1 -1
- package/entities/context/inlineQueryContext.ts +3 -3
- package/entities/context/messageContext.ts +2 -2
- package/entities/context/replyContext.ts +2 -2
- package/index.ts +1 -0
- package/package.json +37 -40
- package/services/actionProcessingService.ts +10 -9
- package/services/actionProcessors/commandActionProcessor.ts +7 -7
- package/services/actionProcessors/inlineQueryActionProcessor.ts +2 -2
- package/services/telegramApi.ts +28 -25
- package/types/externalAliases.ts +17 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TelegramUser } from '../types/externalAliases';
|
|
2
2
|
import { MessageTypeValue } from '../types/messageTypes';
|
|
3
3
|
import { TraceId } from '../types/trace';
|
|
4
4
|
export declare class ChatHistoryMessage {
|
|
5
5
|
readonly id: number;
|
|
6
|
-
readonly from:
|
|
6
|
+
readonly from: TelegramUser | undefined;
|
|
7
7
|
readonly text: string;
|
|
8
8
|
readonly type: MessageTypeValue;
|
|
9
9
|
readonly traceId: TraceId;
|
|
10
10
|
readonly replyToId: number | undefined;
|
|
11
|
-
constructor(id: number, from:
|
|
11
|
+
constructor(id: number, from: TelegramUser | undefined, text: string, type: MessageTypeValue, traceId: TraceId, replyToId: number | undefined);
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=chatHistoryMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatHistoryMessage.d.ts","sourceRoot":"","sources":["../../dtos/chatHistoryMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"chatHistoryMessage.d.ts","sourceRoot":"","sources":["../../dtos/chatHistoryMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,qBAAa,kBAAkB;IAEvB,QAAQ,CAAC,EAAE,EAAE,MAAM;IACnB,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,SAAS;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,OAAO;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;gBAL7B,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,YAAY,GAAG,SAAS,EAC9B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,GAAG,SAAS;CAE7C"}
|
|
@@ -2,18 +2,18 @@ import { MessageTypeValue } from '../types/messageTypes';
|
|
|
2
2
|
import { ChatInfo } from './chatInfo';
|
|
3
3
|
import { TraceId } from '../types/trace';
|
|
4
4
|
import { ChatHistoryMessage } from './chatHistoryMessage';
|
|
5
|
-
import {
|
|
5
|
+
import { TelegramMessage, TelegramUser } from '../types/externalAliases';
|
|
6
6
|
export declare class IncomingMessage {
|
|
7
7
|
readonly messageId: number;
|
|
8
8
|
readonly chatInfo: ChatInfo;
|
|
9
|
-
readonly from:
|
|
9
|
+
readonly from: TelegramUser | undefined;
|
|
10
10
|
readonly text: string;
|
|
11
11
|
readonly type: MessageTypeValue;
|
|
12
12
|
readonly traceId: TraceId;
|
|
13
13
|
readonly replyToMessageId: number | undefined;
|
|
14
|
-
readonly updateObject:
|
|
14
|
+
readonly updateObject: TelegramMessage;
|
|
15
15
|
private detectMessageType;
|
|
16
|
-
constructor(ctxMessage:
|
|
16
|
+
constructor(ctxMessage: TelegramMessage, botName: string, history: ChatHistoryMessage[]);
|
|
17
17
|
private getMessageText;
|
|
18
18
|
}
|
|
19
19
|
//# sourceMappingURL=incomingMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"incomingMessage.d.ts","sourceRoot":"","sources":["../../dtos/incomingMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"incomingMessage.d.ts","sourceRoot":"","sources":["../../dtos/incomingMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEzE,qBAAa,eAAe;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IAE9C,QAAQ,CAAC,YAAY,EAAE,eAAe,CAAC;IAEvC,OAAO,CAAC,iBAAiB;gBAmBrB,UAAU,EAAE,eAAe,EAC3B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,kBAAkB,EAAE;IAyBjC,OAAO,CAAC,cAAc;CAKzB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TelegramMessage } from '../types/externalAliases';
|
|
2
2
|
import { MessageTypeValue } from '../types/messageTypes';
|
|
3
3
|
export declare class MessageInfo {
|
|
4
4
|
/** Id of a message that triggered this action. */
|
|
@@ -8,7 +8,7 @@ export declare class MessageInfo {
|
|
|
8
8
|
/** Type of message being received */
|
|
9
9
|
readonly type: MessageTypeValue;
|
|
10
10
|
/** Message object recieved from Telegram */
|
|
11
|
-
readonly telegramUpdateObject:
|
|
11
|
+
readonly telegramUpdateObject: TelegramMessage;
|
|
12
12
|
constructor(
|
|
13
13
|
/** Id of a message that triggered this action. */
|
|
14
14
|
id: number,
|
|
@@ -17,6 +17,6 @@ export declare class MessageInfo {
|
|
|
17
17
|
/** Type of message being received */
|
|
18
18
|
type: MessageTypeValue,
|
|
19
19
|
/** Message object recieved from Telegram */
|
|
20
|
-
telegramUpdateObject:
|
|
20
|
+
telegramUpdateObject: TelegramMessage);
|
|
21
21
|
}
|
|
22
22
|
//# sourceMappingURL=messageInfo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageInfo.d.ts","sourceRoot":"","sources":["../../dtos/messageInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"messageInfo.d.ts","sourceRoot":"","sources":["../../dtos/messageInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,qBAAa,WAAW;IAEhB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,EAAE,MAAM;IACnB,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,qCAAqC;IACrC,QAAQ,CAAC,IAAI,EAAE,gBAAgB;IAC/B,4CAA4C;IAC5C,QAAQ,CAAC,oBAAoB,EAAE,eAAe;;IAP9C,kDAAkD;IACzC,EAAE,EAAE,MAAM;IACnB,oDAAoD;IAC3C,IAAI,EAAE,MAAM;IACrB,qCAAqC;IAC5B,IAAI,EAAE,gBAAgB;IAC/B,4CAA4C;IACnC,oBAAoB,EAAE,eAAe;CAErD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InlineQueryResult } from 'node-telegram-bot-api';
|
|
2
1
|
import { InlineQueryAction } from '../../entities/actions/inlineQueryAction';
|
|
2
|
+
import { TelegramInlineQueryResult } from '../../types/externalAliases';
|
|
3
3
|
import { TraceId } from '../../types/trace';
|
|
4
4
|
export declare class InlineQueryResponse {
|
|
5
5
|
readonly kind: "inlineQuery";
|
|
@@ -7,7 +7,7 @@ export declare class InlineQueryResponse {
|
|
|
7
7
|
readonly queryId: string;
|
|
8
8
|
readonly traceId: TraceId;
|
|
9
9
|
readonly action: InlineQueryAction;
|
|
10
|
-
readonly queryResults:
|
|
11
|
-
constructor(queryResult:
|
|
10
|
+
readonly queryResults: TelegramInlineQueryResult[];
|
|
11
|
+
constructor(queryResult: TelegramInlineQueryResult[], queryId: string, traceId: TraceId, action: InlineQueryAction);
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=inlineQueryResponse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inlineQueryResponse.d.ts","sourceRoot":"","sources":["../../../dtos/responses/inlineQueryResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"inlineQueryResponse.d.ts","sourceRoot":"","sources":["../../../dtos/responses/inlineQueryResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,qBAAa,mBAAmB;IAC5B,QAAQ,CAAC,IAAI,gBAAgC;IAC7C,QAAQ,CAAC,SAAS,SAAc;IAEhC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,yBAAyB,EAAE,CAAC;gBAG/C,WAAW,EAAE,yBAAyB,EAAE,EACxC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,iBAAiB;CAOhC"}
|
|
@@ -2,7 +2,7 @@ import { IChatResponse } from '../../types/response';
|
|
|
2
2
|
import { IAction } from '../../types/action';
|
|
3
3
|
import { ChatInfo } from '../chatInfo';
|
|
4
4
|
import { TraceId } from '../../types/trace';
|
|
5
|
-
import { TelegramEmoji } from '
|
|
5
|
+
import { TelegramEmoji } from '../../types/externalAliases';
|
|
6
6
|
export declare class Reaction implements IChatResponse {
|
|
7
7
|
readonly kind: "react";
|
|
8
8
|
readonly createdAt: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reaction.d.ts","sourceRoot":"","sources":["../../../dtos/responses/reaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"reaction.d.ts","sourceRoot":"","sources":["../../../dtos/responses/reaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,qBAAa,QAAS,YAAW,aAAa;IAC1C,QAAQ,CAAC,IAAI,UAA0B;IACvC,QAAQ,CAAC,SAAS,SAAc;IAEhC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;gBAGrB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,OAAO;CAQtB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BotResponse } from '../../types/response';
|
|
2
2
|
import { InlineQueryAction } from '../actions/inlineQueryAction';
|
|
3
3
|
import { BaseContextInternal, BaseContextPropertiesToOmit } from './baseContext';
|
|
4
|
-
import {
|
|
4
|
+
import { TelegramInlineQueryResult } from '../../types/externalAliases';
|
|
5
5
|
export type InlineQueryContext = Omit<InlineQueryContextInternal, BaseContextPropertiesToOmit | 'queryResults' | 'queryId'>;
|
|
6
6
|
export declare class InlineQueryContextInternal extends BaseContextInternal<InlineQueryAction> {
|
|
7
|
-
queryResults:
|
|
7
|
+
queryResults: TelegramInlineQueryResult[];
|
|
8
8
|
/**
|
|
9
9
|
* Abort signal to be utilized in query handler.
|
|
10
10
|
* Signal will be aborted if new query comes from the same user.
|
|
@@ -22,6 +22,6 @@ export declare class InlineQueryContextInternal extends BaseContextInternal<Inli
|
|
|
22
22
|
* This result will be shown to user as a response to inline query.
|
|
23
23
|
* @param queryResult Inline query result to be shown to user.
|
|
24
24
|
*/
|
|
25
|
-
showInlineQueryResult(queryResult:
|
|
25
|
+
showInlineQueryResult(queryResult: TelegramInlineQueryResult): void;
|
|
26
26
|
}
|
|
27
27
|
//# sourceMappingURL=inlineQueryContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inlineQueryContext.d.ts","sourceRoot":"","sources":["../../../entities/context/inlineQueryContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EACH,mBAAmB,EACnB,2BAA2B,EAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"inlineQueryContext.d.ts","sourceRoot":"","sources":["../../../entities/context/inlineQueryContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EACH,mBAAmB,EACnB,2BAA2B,EAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACjC,0BAA0B,EAC1B,2BAA2B,GAAG,cAAc,GAAG,SAAS,CAC3D,CAAC;AAEF,qBAAa,0BAA2B,SAAQ,mBAAmB,CAAC,iBAAiB,CAAC;IAClF,YAAY,EAAE,yBAAyB,EAAE,CAAM;IAC/C;;;OAGG;IACH,WAAW,EAAG,WAAW,CAAC;IAE1B,uDAAuD;IACvD,IAAI,SAAS,IAAI,WAAW,EAAE,CAS7B;IACD,wBAAwB;IACxB,SAAS,EAAG,MAAM,CAAC;IACnB,wBAAwB;IACxB,OAAO,EAAG,MAAM,CAAC;IACjB,4HAA4H;IAC5H,YAAY,EAAE,gBAAgB,EAAE,CAAM;IAEtC;;;OAGG;IACH,qBAAqB,CAAC,WAAW,EAAE,yBAAyB;CAG/D"}
|
|
@@ -6,7 +6,7 @@ import { Seconds } from '../../types/timeValues';
|
|
|
6
6
|
import { BaseContextPropertiesToOmit } from './baseContext';
|
|
7
7
|
import { MessageInfo } from '../../dtos/messageInfo';
|
|
8
8
|
import { UserInfo } from '../../dtos/userInfo';
|
|
9
|
-
import {
|
|
9
|
+
import { BotInfo, TelegramEmoji } from '../../types/externalAliases';
|
|
10
10
|
export type MessageContext<TActionState extends IActionState> = Omit<MessageContextInternal<TActionState>, BaseContextPropertiesToOmit | 'startCooldown' | 'customCooldown'>;
|
|
11
11
|
/**
|
|
12
12
|
* Context of action executed in chat, in response to a message
|
|
@@ -21,7 +21,7 @@ export declare class MessageContextInternal<TActionState extends IActionState> e
|
|
|
21
21
|
/** Indicates if cooldown should be started after action is executed. Set to `true` by default. */
|
|
22
22
|
startCooldown: boolean;
|
|
23
23
|
/** Bot info from Telegram */
|
|
24
|
-
botInfo:
|
|
24
|
+
botInfo: BotInfo;
|
|
25
25
|
customCooldown: Seconds | undefined;
|
|
26
26
|
private getQuotePart;
|
|
27
27
|
private replyWithText;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageContext.d.ts","sourceRoot":"","sources":["../../../entities/context/messageContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAC5B,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"messageContext.d.ts","sourceRoot":"","sources":["../../../entities/context/messageContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAC5B,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAErE,MAAM,MAAM,cAAc,CAAC,YAAY,SAAS,YAAY,IAAI,IAAI,CAChE,sBAAsB,CAAC,YAAY,CAAC,EACpC,2BAA2B,GAAG,eAAe,GAAG,gBAAgB,CACnE,CAAC;AAEF;;GAEG;AACH,qBAAa,sBAAsB,CAC/B,YAAY,SAAS,YAAY,CACnC,SAAQ,mBAAmB,CAAC,YAAY,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IACpE,4DAA4D;IAC5D,QAAQ,EAAG,QAAQ,CAAC;IACpB,+DAA+D;IAC/D,WAAW,EAAG,WAAW,CAAC;IAC1B,4HAA4H;IAC5H,YAAY,EAAE,gBAAgB,EAAE,CAAM;IACtC,kGAAkG;IAClG,aAAa,EAAE,OAAO,CAAQ;IAC9B,6BAA6B;IAC7B,OAAO,EAAG,OAAO,CAAC;IAClB,cAAc,EAAE,OAAO,GAAG,SAAS,CAAC;IAEpC,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,aAAa;IAqBrB,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,cAAc;IAqBtB,YAAY;IAIZ,mBAAmB,CAAC,cAAc,EAAE,OAAO;IAK3C;;OAEG;IACH,KAAK;QACD;;;WAGG;;YAEC;;;;;eAKG;6BAEO,MAAM,UACJ,MAAM,YACJ,yBAAyB;YAEvC;;;;;eAKG;8BAEO,MAAM,UACJ,MAAM,YACJ,qBAAqB;YAGnC;;;;;eAKG;8BAEO,MAAM,UACJ,MAAM,YACJ,qBAAqB;;QAIvC;;;;;WAKG;yBACc,MAAM,YAAY,yBAAyB;QAE5D;;;;;WAKG;0BACe,MAAM,YAAY,qBAAqB;QAGzD;;;;;WAKG;0BACe,MAAM,YAAY,qBAAqB;QAGzD;;;;WAIG;8BACmB,aAAa;MAWrC;CACL"}
|
|
@@ -4,7 +4,7 @@ import { ReplyCaptureAction } from '../actions/replyCaptureAction';
|
|
|
4
4
|
import { BaseContextInternal, BaseContextPropertiesToOmit } from './baseContext';
|
|
5
5
|
import { UserInfo } from '../../dtos/userInfo';
|
|
6
6
|
import { MessageInfo } from '../../dtos/messageInfo';
|
|
7
|
-
import {
|
|
7
|
+
import { TelegramUser, TelegramEmoji } from '../../types/externalAliases';
|
|
8
8
|
export type ReplyContext<TActionState extends IActionState> = Omit<ReplyContextInternal<TActionState>, BaseContextPropertiesToOmit | 'messageId' | 'startCooldown' | 'customCooldown'>;
|
|
9
9
|
export declare class ReplyContextInternal<TParentActionState extends IActionState> extends BaseContextInternal<ReplyCaptureAction<TParentActionState>> {
|
|
10
10
|
/** Collection of Regexp match results on a message that triggered this action. Will be empty if trigger is not a Regexp. */
|
|
@@ -16,7 +16,7 @@ export declare class ReplyContextInternal<TParentActionState extends IActionStat
|
|
|
16
16
|
/** Information about the message that triggered this action */
|
|
17
17
|
messageInfo: MessageInfo;
|
|
18
18
|
/** Bot info from Telegram */
|
|
19
|
-
botInfo:
|
|
19
|
+
botInfo: TelegramUser;
|
|
20
20
|
isInitialized: boolean;
|
|
21
21
|
private getQuotePart;
|
|
22
22
|
private replyWithText;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replyContext.d.ts","sourceRoot":"","sources":["../../../entities/context/replyContext.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACH,yBAAyB,EACzB,qBAAqB,EACxB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EACH,mBAAmB,EACnB,2BAA2B,EAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"replyContext.d.ts","sourceRoot":"","sources":["../../../entities/context/replyContext.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACH,yBAAyB,EACzB,qBAAqB,EACxB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EACH,mBAAmB,EACnB,2BAA2B,EAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE1E,MAAM,MAAM,YAAY,CAAC,YAAY,SAAS,YAAY,IAAI,IAAI,CAC9D,oBAAoB,CAAC,YAAY,CAAC,EAChC,2BAA2B,GAC3B,WAAW,GACX,eAAe,GACf,gBAAgB,CACrB,CAAC;AAEF,qBAAa,oBAAoB,CAC7B,kBAAkB,SAAS,YAAY,CACzC,SAAQ,mBAAmB,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;IACjE,4HAA4H;IAC5H,YAAY,EAAG,eAAe,EAAE,CAAC;IACjC,kDAAkD;IAClD,cAAc,EAAG,MAAM,GAAG,SAAS,CAAC;IACpC,4DAA4D;IAC5D,QAAQ,EAAG,QAAQ,CAAC;IACpB,+DAA+D;IAC/D,WAAW,EAAG,WAAW,CAAC;IAC1B,6BAA6B;IAC7B,OAAO,EAAG,YAAY,CAAC;IAEvB,aAAa,UAAS;IAEtB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,aAAa;IAqBrB,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,cAAc;IAqBtB;;OAEG;IACH,WAAW;IAIX;;OAEG;IACH,KAAK;QACD;;;WAGG;;YAEC;;;;;eAKG;6BAEO,MAAM,UACJ,MAAM,YACJ,yBAAyB;YAIvC;;;;;eAKG;8BAEO,MAAM,UACJ,MAAM,YACJ,qBAAqB;YAKnC;;;;;eAKG;8BAEO,MAAM,UACJ,MAAM,YACJ,qBAAqB;;QAMvC;;;;;WAKG;yBACc,MAAM,YAAY,yBAAyB;QAG5D;;;;;WAKG;0BACe,MAAM,YAAY,qBAAqB;QAIzD;;;;;WAKG;0BACe,MAAM,YAAY,qBAAqB;QAIzD;;;;WAIG;8BACmB,aAAa;MAWrC;CACL"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './entities/states/actionStateBase';
|
|
|
7
7
|
export * from './types/messageTypes';
|
|
8
8
|
export * from './helpers/timeConvertions';
|
|
9
9
|
export * from './types/action';
|
|
10
|
+
export * from './types/externalAliases';
|
|
10
11
|
export { CommandAction } from './entities/actions/commandAction';
|
|
11
12
|
export { InlineQueryAction } from './entities/actions/inlineQueryAction';
|
|
12
13
|
export { ReplyCaptureAction } from './entities/actions/replyCaptureAction';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,6CAA6C,CAAC;AAC5D,cAAc,yCAAyC,CAAC;AACxD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qBAAqB,CAAC;AACpC,cAAc,mCAAmC,CAAC;AAClD,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,6CAA6C,CAAC;AAC5D,cAAc,yCAAyC,CAAC;AACxD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qBAAqB,CAAC;AACpC,cAAc,mCAAmC,CAAC;AAClD,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ __exportStar(require("./entities/states/actionStateBase"), exports);
|
|
|
24
24
|
__exportStar(require("./types/messageTypes"), exports);
|
|
25
25
|
__exportStar(require("./helpers/timeConvertions"), exports);
|
|
26
26
|
__exportStar(require("./types/action"), exports);
|
|
27
|
+
__exportStar(require("./types/externalAliases"), exports);
|
|
27
28
|
var commandAction_1 = require("./entities/actions/commandAction");
|
|
28
29
|
Object.defineProperty(exports, "CommandAction", { enumerable: true, get: function () { return commandAction_1.CommandAction; } });
|
|
29
30
|
var inlineQueryAction_1 = require("./entities/actions/inlineQueryAction");
|
|
@@ -20,6 +20,6 @@ export declare class ActionProcessingService {
|
|
|
20
20
|
scheduled: ScheduledAction<IActionState>[];
|
|
21
21
|
inlineQueries: InlineQueryAction[];
|
|
22
22
|
}, scheduledPeriod?: Seconds, verboseLoggingForIncomingMessage?: boolean): Promise<void>;
|
|
23
|
-
stop():
|
|
23
|
+
stop(): void;
|
|
24
24
|
}
|
|
25
25
|
//# sourceMappingURL=actionProcessingService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actionProcessingService.d.ts","sourceRoot":"","sources":["../../services/actionProcessingService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAuB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"actionProcessingService.d.ts","sourceRoot":"","sources":["../../services/actionProcessingService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAuB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAQtE,qBAAa,uBAAuB;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IAEjC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAyB;IAC1D,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA2B;IAC9D,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAA6B;IAElE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC,OAAO,CAAC,WAAW,CAAe;gBAG9B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,OAAO;IA4Bb,UAAU,CACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;QACL,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,EAAE,CAAC;QACxC,SAAS,EAAE,eAAe,CAAC,YAAY,CAAC,EAAE,CAAC;QAC3C,aAAa,EAAE,iBAAiB,EAAE,CAAC;KACtC,EACD,eAAe,CAAC,EAAE,OAAO,EACzB,gCAAgC,CAAC,EAAE,OAAO;IA2D9C,IAAI;CAGP"}
|
|
@@ -1,7 +1,4 @@
|
|
|
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
3
|
exports.ActionProcessingService = void 0;
|
|
7
4
|
const timeConvertions_1 = require("../helpers/timeConvertions");
|
|
@@ -10,7 +7,7 @@ const helpAction_1 = require("../builtin/helpAction");
|
|
|
10
7
|
const commandActionProcessor_1 = require("./actionProcessors/commandActionProcessor");
|
|
11
8
|
const inlineQueryActionProcessor_1 = require("./actionProcessors/inlineQueryActionProcessor");
|
|
12
9
|
const scheduledActionProcessor_1 = require("./actionProcessors/scheduledActionProcessor");
|
|
13
|
-
const
|
|
10
|
+
const telegraf_1 = require("telegraf");
|
|
14
11
|
class ActionProcessingService {
|
|
15
12
|
storage;
|
|
16
13
|
logger;
|
|
@@ -28,11 +25,11 @@ class ActionProcessingService {
|
|
|
28
25
|
this.botName = botName;
|
|
29
26
|
}
|
|
30
27
|
async initialize(token, actions, scheduledPeriod, verboseLoggingForIncomingMessage) {
|
|
31
|
-
this.telegramBot = new
|
|
32
|
-
const api = new telegramApi_1.TelegramApiService(this.botName, this.telegramBot, this.storage, this.logger, (capture, id, chatInfo, traceId) => {
|
|
28
|
+
this.telegramBot = new telegraf_1.Telegraf(token);
|
|
29
|
+
const api = new telegramApi_1.TelegramApiService(this.botName, this.telegramBot.telegram, this.storage, this.logger, (capture, id, chatInfo, traceId) => {
|
|
33
30
|
this.commandProcessor.captureRegistrationCallback(capture, id, chatInfo, traceId);
|
|
34
31
|
});
|
|
35
|
-
const botInfo = await this.telegramBot.getMe();
|
|
32
|
+
const botInfo = await this.telegramBot.telegram.getMe();
|
|
36
33
|
const commandActions = actions.commands.length > 0 && botInfo.username
|
|
37
34
|
? [
|
|
38
35
|
(0, helpAction_1.buildHelpCommand)(actions.commands
|
|
@@ -44,13 +41,14 @@ class ActionProcessingService {
|
|
|
44
41
|
this.commandProcessor.initialize(api, this.telegramBot, commandActions, verboseLoggingForIncomingMessage ?? false, botInfo);
|
|
45
42
|
this.inlineQueryProcessor.initialize(api, this.telegramBot, actions.inlineQueries, 300);
|
|
46
43
|
this.scheduledProcessor.initialize(api, actions.scheduled, scheduledPeriod ?? (0, timeConvertions_1.hoursToSeconds)(1));
|
|
44
|
+
void this.telegramBot.launch();
|
|
47
45
|
void this.storage.saveMetadata([
|
|
48
46
|
...actions.scheduled,
|
|
49
47
|
...commandActions
|
|
50
48
|
]);
|
|
51
49
|
}
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
stop() {
|
|
51
|
+
this.telegramBot.stop();
|
|
54
52
|
}
|
|
55
53
|
}
|
|
56
54
|
exports.ActionProcessingService = ActionProcessingService;
|
|
@@ -5,13 +5,13 @@ import { IReplyCapture } from '../../types/capture';
|
|
|
5
5
|
import { TraceId } from '../../types/trace';
|
|
6
6
|
import { ChatInfo } from '../../dtos/chatInfo';
|
|
7
7
|
import { BaseActionProcessor } from './baseProcessor';
|
|
8
|
-
import TelegramBot from '
|
|
8
|
+
import { BotInfo, TelegramBot } from '../../types/externalAliases';
|
|
9
9
|
export declare class CommandActionProcessor extends BaseActionProcessor {
|
|
10
10
|
private readonly replyCaptures;
|
|
11
11
|
private readonly chatHistory;
|
|
12
12
|
private botInfo;
|
|
13
13
|
private commands;
|
|
14
|
-
initialize(api: TelegramApiService, telegram: TelegramBot, commands: CommandAction<IActionState>[], verboseLoggingForIncomingMessage: boolean, botInfo:
|
|
14
|
+
initialize(api: TelegramApiService, telegram: TelegramBot, commands: CommandAction<IActionState>[], verboseLoggingForIncomingMessage: boolean, botInfo: BotInfo): void;
|
|
15
15
|
captureRegistrationCallback(capture: IReplyCapture, parentMessageId: number, chatInfo: ChatInfo, traceId: TraceId): void;
|
|
16
16
|
private processMessage;
|
|
17
17
|
private initializeReplyCaptureContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandActionProcessor.d.ts","sourceRoot":"","sources":["../../../services/actionProcessors/commandActionProcessor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAIrE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAM/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAKtD,OAAO,WAAW,MAAM,
|
|
1
|
+
{"version":3,"file":"commandActionProcessor.d.ts","sourceRoot":"","sources":["../../../services/actionProcessors/commandActionProcessor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAIrE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAM/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAKtD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAInE,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC3D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0C;IACxE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA2C;IACvE,OAAO,CAAC,OAAO,CAAW;IAE1B,OAAO,CAAC,QAAQ,CAKd;IAEF,UAAU,CACN,GAAG,EAAE,kBAAkB,EACvB,QAAQ,EAAE,WAAW,EACrB,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,EAAE,EACvC,gCAAgC,EAAE,OAAO,EACzC,OAAO,EAAE,OAAO;IA2DpB,2BAA2B,CACvB,OAAO,EAAE,aAAa,EACtB,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO;YAgCN,cAAc;IAoD5B,OAAO,CAAC,6BAA6B;IAiCrC,OAAO,CAAC,wBAAwB;CAmCnC"}
|
|
@@ -38,11 +38,11 @@ class CommandActionProcessor extends baseProcessor_1.BaseActionProcessor {
|
|
|
38
38
|
cmd.triggers.includes(messageTypes_1.MessageType.Any));
|
|
39
39
|
}
|
|
40
40
|
if (commands.length > 0) {
|
|
41
|
-
telegram.on('message', (
|
|
42
|
-
const internalMessage = new incomingMessage_1.IncomingMessage(
|
|
41
|
+
telegram.on('message', ({ message }) => {
|
|
42
|
+
const internalMessage = new incomingMessage_1.IncomingMessage(message, this.botName, (0, mapUtils_1.getOrSetIfNotExists)(this.chatHistory, message.chat.id, []));
|
|
43
43
|
const logger = this.logger.createScope(this.botName, internalMessage.traceId, internalMessage.chatInfo.name);
|
|
44
44
|
if (verboseLoggingForIncomingMessage) {
|
|
45
|
-
logger.logObjectWithTraceId(
|
|
45
|
+
logger.logObjectWithTraceId(message);
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
48
|
logger.logWithTraceId(`${internalMessage.from?.first_name ?? 'Unknown'} (${internalMessage.from?.id ?? 'Unknown'}): ${internalMessage.text || internalMessage.type}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import TelegramBot from 'node-telegram-bot-api';
|
|
2
1
|
import { InlineQueryAction } from '../../entities/actions/inlineQueryAction';
|
|
2
|
+
import { TelegramBot } from '../../types/externalAliases';
|
|
3
3
|
import { Milliseconds } from '../../types/timeValues';
|
|
4
4
|
import { TelegramApiService } from '../telegramApi';
|
|
5
5
|
import { BaseActionProcessor } from './baseProcessor';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inlineQueryActionProcessor.d.ts","sourceRoot":"","sources":["../../../services/actionProcessors/inlineQueryActionProcessor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inlineQueryActionProcessor.d.ts","sourceRoot":"","sources":["../../../services/actionProcessors/inlineQueryActionProcessor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAG7E,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,qBAAa,0BAA2B,SAAQ,mBAAmB;IAC/D,OAAO,CAAC,aAAa,CAAuB;IAE5C,UAAU,CACN,GAAG,EAAE,kBAAkB,EACvB,QAAQ,EAAE,WAAW,EACrB,aAAa,EAAE,iBAAiB,EAAE,EAClC,MAAM,EAAE,YAAY;IAuGxB,OAAO,CAAC,4BAA4B;CAqBvC"}
|
|
@@ -13,7 +13,7 @@ class InlineQueryActionProcessor extends baseProcessor_1.BaseActionProcessor {
|
|
|
13
13
|
let pendingInlineQueries = [];
|
|
14
14
|
const queriesInProcessing = new Map();
|
|
15
15
|
if (this.inlineQueries.length > 0) {
|
|
16
|
-
telegram.on('inline_query', (inlineQuery) => {
|
|
16
|
+
telegram.on('inline_query', ({ inlineQuery }) => {
|
|
17
17
|
const query = new incomingQuery_1.IncomingInlineQuery(inlineQuery.id, inlineQuery.query, inlineQuery.from.id, (0, traceFactory_1.createTrace)('InlineQuery', this.botName, inlineQuery.id));
|
|
18
18
|
const logger = this.logger.createScope(this.botName, query.traceId, 'Query');
|
|
19
19
|
logger.logWithTraceId(`${inlineQuery.from.username ?? 'Unknown'} (${inlineQuery.from.id}): Query for ${inlineQuery.query}`);
|
|
@@ -4,7 +4,7 @@ import { ILogger } from '../types/logger';
|
|
|
4
4
|
import { IReplyCapture } from '../types/capture';
|
|
5
5
|
import { TraceId } from '../types/trace';
|
|
6
6
|
import { ChatInfo } from '../dtos/chatInfo';
|
|
7
|
-
import
|
|
7
|
+
import { TelegramApiClient } from '../types/externalAliases';
|
|
8
8
|
export declare const TELEGRAM_ERROR_QUOTE_INVALID = "QUOTE_TEXT_INVALID";
|
|
9
9
|
export declare class TelegramApiService {
|
|
10
10
|
private readonly queue;
|
|
@@ -13,7 +13,7 @@ export declare class TelegramApiService {
|
|
|
13
13
|
private readonly logger;
|
|
14
14
|
private readonly captureRegistrationCallback;
|
|
15
15
|
private readonly botName;
|
|
16
|
-
constructor(botName: string, telegram:
|
|
16
|
+
constructor(botName: string, telegram: TelegramApiClient, storage: IStorageClient, logger: ILogger, captureRegistrationCallback: (capture: IReplyCapture, parentMessageId: number, chatInfo: ChatInfo, traceId: TraceId) => void);
|
|
17
17
|
enqueueBatchedResponses(responses: BotResponse[]): void;
|
|
18
18
|
flushResponses(): void;
|
|
19
19
|
private pinIfShould;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telegramApi.d.ts","sourceRoot":"","sources":["../../services/telegramApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,
|
|
1
|
+
{"version":3,"file":"telegramApi.d.ts","sourceRoot":"","sources":["../../services/telegramApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAmB,MAAM,0BAA0B,CAAC;AAE9E,eAAO,MAAM,4BAA4B,uBAAuB,CAAC;AAEjE,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiC;IACvD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;IAC7C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IACjC,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAKlC;IAEV,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAG7B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,OAAO,EACf,2BAA2B,EAAE,CACzB,OAAO,EAAE,aAAa,EACtB,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,KACf,IAAI;IASb,uBAAuB,CAAC,SAAS,EAAE,WAAW,EAAE;IAwDhD,cAAc;YAIA,WAAW;YAqBX,eAAe;CAqGhC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TelegramApiService = exports.TELEGRAM_ERROR_QUOTE_INVALID = void 0;
|
|
4
4
|
const responseProcessingQueue_1 = require("./responseProcessingQueue");
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
5
|
exports.TELEGRAM_ERROR_QUOTE_INVALID = 'QUOTE_TEXT_INVALID';
|
|
7
6
|
class TelegramApiService {
|
|
8
7
|
queue = new responseProcessingQueue_1.ResponseProcessingQueue();
|
|
@@ -86,33 +85,33 @@ class TelegramApiService {
|
|
|
86
85
|
});
|
|
87
86
|
break;
|
|
88
87
|
case 'image':
|
|
89
|
-
sentMessage = await this.telegram.sendPhoto(response.chatInfo.id,
|
|
88
|
+
sentMessage = await this.telegram.sendPhoto(response.chatInfo.id, response.content,
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
90
|
+
response.replyInfo?.id
|
|
90
91
|
? {
|
|
91
|
-
reply_to_message_id: response.replyInfo.id
|
|
92
|
+
reply_to_message_id: response.replyInfo.id // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
93
|
}
|
|
93
94
|
: undefined);
|
|
94
95
|
break;
|
|
95
96
|
case 'video':
|
|
96
|
-
sentMessage = await this.telegram.sendVideo(response.chatInfo.id,
|
|
97
|
+
sentMessage = await this.telegram.sendVideo(response.chatInfo.id, response.content,
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
99
|
+
response.replyInfo?.id
|
|
97
100
|
? {
|
|
98
|
-
reply_to_message_id: response.replyInfo.id
|
|
101
|
+
reply_to_message_id: response.replyInfo.id // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
102
|
}
|
|
100
103
|
: undefined);
|
|
101
104
|
break;
|
|
102
105
|
case 'react':
|
|
103
|
-
await this.telegram.setMessageReaction(response.chatInfo.id, response.messageId,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
]
|
|
110
|
-
});
|
|
106
|
+
await this.telegram.setMessageReaction(response.chatInfo.id, response.messageId, [
|
|
107
|
+
{
|
|
108
|
+
type: 'emoji',
|
|
109
|
+
emoji: response.emoji
|
|
110
|
+
}
|
|
111
|
+
]);
|
|
111
112
|
return;
|
|
112
113
|
case 'unpin':
|
|
113
|
-
await this.telegram.unpinChatMessage(response.chatInfo.id,
|
|
114
|
-
message_id: response.messageId
|
|
115
|
-
});
|
|
114
|
+
await this.telegram.unpinChatMessage(response.chatInfo.id, response.messageId);
|
|
116
115
|
await this.storage.updateStateFor(response.action, response.chatInfo.id, (state) => {
|
|
117
116
|
state.pinnedMessages = state.pinnedMessages.filter((x) => x != response.messageId);
|
|
118
117
|
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { User, Message, InlineQueryResult, TelegramEmoji as Emoji, UserFromGetMe } from 'telegraf/typings/core/types/typegram';
|
|
2
|
+
import { Telegraf } from 'telegraf';
|
|
3
|
+
import Telegram from 'telegraf/typings/telegram';
|
|
4
|
+
export type TelegramUser = User;
|
|
5
|
+
export type TelegramMessage = Message;
|
|
6
|
+
export type TelegramInlineQueryResult = InlineQueryResult;
|
|
7
|
+
export type TelegramEmoji = Emoji;
|
|
8
|
+
export type TelegramApiClient = Telegram;
|
|
9
|
+
export type BotInfo = UserFromGetMe;
|
|
10
|
+
export type TelegramBot = Telegraf;
|
|
11
|
+
//# sourceMappingURL=externalAliases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"externalAliases.d.ts","sourceRoot":"","sources":["../../types/externalAliases.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,IAAI,EACJ,OAAO,EACP,iBAAiB,EACjB,aAAa,IAAI,KAAK,EACtB,aAAa,EAChB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,QAAQ,MAAM,2BAA2B,CAAC;AAEjD,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC;AAChC,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC;AACtC,MAAM,MAAM,yBAAyB,GAAG,iBAAiB,CAAC;AAC1D,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC;AAClC,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AACzC,MAAM,MAAM,OAAO,GAAG,aAAa,CAAC;AACpC,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TelegramUser } from '../types/externalAliases';
|
|
2
2
|
import { MessageTypeValue } from '../types/messageTypes';
|
|
3
3
|
import { TraceId } from '../types/trace';
|
|
4
4
|
|
|
5
5
|
export class ChatHistoryMessage {
|
|
6
6
|
constructor(
|
|
7
7
|
readonly id: number,
|
|
8
|
-
readonly from:
|
|
8
|
+
readonly from: TelegramUser | undefined,
|
|
9
9
|
readonly text: string,
|
|
10
10
|
readonly type: MessageTypeValue,
|
|
11
11
|
readonly traceId: TraceId,
|
package/dtos/incomingMessage.ts
CHANGED
|
@@ -4,20 +4,20 @@ import { ChatInfo } from './chatInfo';
|
|
|
4
4
|
import { createTrace } from '../helpers/traceFactory';
|
|
5
5
|
import { TraceId } from '../types/trace';
|
|
6
6
|
import { ChatHistoryMessage } from './chatHistoryMessage';
|
|
7
|
-
import {
|
|
7
|
+
import { TelegramMessage, TelegramUser } from '../types/externalAliases';
|
|
8
8
|
|
|
9
9
|
export class IncomingMessage {
|
|
10
10
|
readonly messageId: number;
|
|
11
11
|
readonly chatInfo: ChatInfo;
|
|
12
|
-
readonly from:
|
|
12
|
+
readonly from: TelegramUser | undefined;
|
|
13
13
|
readonly text: string;
|
|
14
14
|
readonly type: MessageTypeValue;
|
|
15
15
|
readonly traceId: TraceId;
|
|
16
16
|
readonly replyToMessageId: number | undefined;
|
|
17
17
|
|
|
18
|
-
readonly updateObject:
|
|
18
|
+
readonly updateObject: TelegramMessage;
|
|
19
19
|
|
|
20
|
-
private detectMessageType(message:
|
|
20
|
+
private detectMessageType(message: TelegramMessage) {
|
|
21
21
|
if ('forward_origin' in message) return MessageType.Forward;
|
|
22
22
|
if ('text' in message) return MessageType.Text;
|
|
23
23
|
if ('video' in message) return MessageType.Video;
|
|
@@ -36,7 +36,7 @@ export class IncomingMessage {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
constructor(
|
|
39
|
-
ctxMessage:
|
|
39
|
+
ctxMessage: TelegramMessage,
|
|
40
40
|
botName: string,
|
|
41
41
|
history: ChatHistoryMessage[]
|
|
42
42
|
) {
|
|
@@ -63,8 +63,8 @@ export class IncomingMessage {
|
|
|
63
63
|
this.updateObject = ctxMessage;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
private getMessageText(ctxMessage:
|
|
67
|
-
if ('text' in ctxMessage) return ctxMessage.text
|
|
66
|
+
private getMessageText(ctxMessage: TelegramMessage) {
|
|
67
|
+
if ('text' in ctxMessage) return ctxMessage.text;
|
|
68
68
|
|
|
69
69
|
return 'caption' in ctxMessage ? ctxMessage.caption ?? '' : '';
|
|
70
70
|
}
|
package/dtos/messageInfo.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TelegramMessage } from '../types/externalAliases';
|
|
2
2
|
import { MessageTypeValue } from '../types/messageTypes';
|
|
3
3
|
|
|
4
4
|
export class MessageInfo {
|
|
@@ -10,6 +10,6 @@ export class MessageInfo {
|
|
|
10
10
|
/** Type of message being received */
|
|
11
11
|
readonly type: MessageTypeValue,
|
|
12
12
|
/** Message object recieved from Telegram */
|
|
13
|
-
readonly telegramUpdateObject:
|
|
13
|
+
readonly telegramUpdateObject: TelegramMessage
|
|
14
14
|
) {}
|
|
15
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InlineQueryResult } from 'node-telegram-bot-api';
|
|
2
1
|
import { InlineQueryAction } from '../../entities/actions/inlineQueryAction';
|
|
2
|
+
import { TelegramInlineQueryResult } from '../../types/externalAliases';
|
|
3
3
|
import { BotResponseTypes } from '../../types/response';
|
|
4
4
|
import { TraceId } from '../../types/trace';
|
|
5
5
|
|
|
@@ -10,10 +10,10 @@ export class InlineQueryResponse {
|
|
|
10
10
|
readonly queryId: string;
|
|
11
11
|
readonly traceId: TraceId;
|
|
12
12
|
readonly action: InlineQueryAction;
|
|
13
|
-
readonly queryResults:
|
|
13
|
+
readonly queryResults: TelegramInlineQueryResult[];
|
|
14
14
|
|
|
15
15
|
constructor(
|
|
16
|
-
queryResult:
|
|
16
|
+
queryResult: TelegramInlineQueryResult[],
|
|
17
17
|
queryId: string,
|
|
18
18
|
traceId: TraceId,
|
|
19
19
|
action: InlineQueryAction
|
|
@@ -2,7 +2,7 @@ import { BotResponseTypes, IChatResponse } from '../../types/response';
|
|
|
2
2
|
import { IAction } from '../../types/action';
|
|
3
3
|
import { ChatInfo } from '../chatInfo';
|
|
4
4
|
import { TraceId } from '../../types/trace';
|
|
5
|
-
import { TelegramEmoji } from '
|
|
5
|
+
import { TelegramEmoji } from '../../types/externalAliases';
|
|
6
6
|
|
|
7
7
|
export class Reaction implements IChatResponse {
|
|
8
8
|
readonly kind = BotResponseTypes.react;
|