chz-telegram-bot 0.7.14 → 0.7.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/services/jsonFileStorage.js +1 -1
- package/package.json +4 -1
- package/eslint.config.ts +0 -62
- package/src/builtin/helpAction.ts +0 -17
- package/src/dtos/chatHistoryMessage.ts +0 -22
- package/src/dtos/chatInfo.ts +0 -12
- package/src/dtos/commandTriggerCheckResult.ts +0 -40
- package/src/dtos/cooldownInfo.ts +0 -10
- package/src/dtos/incomingMessage.ts +0 -71
- package/src/dtos/incomingQuery.ts +0 -14
- package/src/dtos/messageInfo.ts +0 -15
- package/src/dtos/propertyProviderSets.ts +0 -20
- package/src/dtos/replyInfo.ts +0 -9
- package/src/dtos/responses/delay.ts +0 -28
- package/src/dtos/responses/imageMessage.ts +0 -41
- package/src/dtos/responses/inlineQueryResponse.ts +0 -26
- package/src/dtos/responses/reaction.ts +0 -30
- package/src/dtos/responses/textMessage.ts +0 -44
- package/src/dtos/responses/unpin.ts +0 -27
- package/src/dtos/responses/videoMessage.ts +0 -41
- package/src/dtos/userInfo.ts +0 -8
- package/src/entities/actions/commandAction.ts +0 -276
- package/src/entities/actions/inlineQueryAction.ts +0 -83
- package/src/entities/actions/replyCaptureAction.ts +0 -110
- package/src/entities/actions/scheduledAction.ts +0 -182
- package/src/entities/botInstance.ts +0 -92
- package/src/entities/cachedStateFactory.ts +0 -14
- package/src/entities/context/baseContext.ts +0 -111
- package/src/entities/context/chatContext.ts +0 -135
- package/src/entities/context/inlineQueryContext.ts +0 -63
- package/src/entities/context/messageContext.ts +0 -250
- package/src/entities/context/replyContext.ts +0 -260
- package/src/entities/states/actionStateBase.ts +0 -6
- package/src/entities/taskRecord.ts +0 -11
- package/src/helpers/builders/commandActionBuilder.ts +0 -213
- package/src/helpers/builders/inlineQueryActionBuilder.ts +0 -71
- package/src/helpers/builders/scheduledActionBuilder.ts +0 -143
- package/src/helpers/mapUtils.ts +0 -28
- package/src/helpers/noop.ts +0 -20
- package/src/helpers/objectFromEntries.ts +0 -7
- package/src/helpers/timeConvertions.ts +0 -13
- package/src/helpers/toArray.ts +0 -3
- package/src/helpers/traceFactory.ts +0 -11
- package/src/index.ts +0 -33
- package/src/main.ts +0 -76
- package/src/services/actionProcessingService.ts +0 -125
- package/src/services/actionProcessors/baseProcessor.ts +0 -67
- package/src/services/actionProcessors/commandActionProcessor.ts +0 -231
- package/src/services/actionProcessors/inlineQueryActionProcessor.ts +0 -165
- package/src/services/actionProcessors/scheduledActionProcessor.ts +0 -136
- package/src/services/jsonFileStorage.ts +0 -181
- package/src/services/nodeTimeoutScheduler.ts +0 -79
- package/src/services/responseProcessingQueue.ts +0 -57
- package/src/services/telegramApi.ts +0 -278
- package/src/types/action.ts +0 -15
- package/src/types/actionState.ts +0 -4
- package/src/types/cachedValueAccessor.ts +0 -1
- package/src/types/capture.ts +0 -33
- package/src/types/commandCondition.ts +0 -9
- package/src/types/commandTrigger.ts +0 -1
- package/src/types/events.ts +0 -286
- package/src/types/externalAliases.ts +0 -18
- package/src/types/handlers.ts +0 -26
- package/src/types/inputFile.ts +0 -4
- package/src/types/messageSendingOptions.ts +0 -10
- package/src/types/messageTypes.ts +0 -21
- package/src/types/propertyProvider.ts +0 -14
- package/src/types/response.ts +0 -51
- package/src/types/scheduler.ts +0 -20
- package/src/types/storage.ts +0 -23
- package/src/types/timeValues.ts +0 -33
- package/src/types/trace.ts +0 -5
- package/tests/dtos/commandTriggerCheckResult.test.ts +0 -301
- package/tests/entities/actions/inlineQueryAction.test.ts +0 -359
- package/tests/entities/actions/replyCaptureAction.test.ts +0 -501
- package/tests/entities/cachedStateFactory.test.ts +0 -98
- package/tests/entities/context/chatContext.test.ts +0 -606
- package/tests/entities/context/messageContext.test.ts +0 -370
- package/tests/entities/states/actionStateBase.test.ts +0 -138
- package/tests/entities/taskRecord.test.ts +0 -195
- package/tests/helpers/mapUtils.test.ts +0 -163
- package/tests/helpers/timeConvertions.test.ts +0 -129
- package/tests/services/actionProcessors/baseActionProcessor.test.ts +0 -359
- package/tests/services/actionProcessors/commandActionProcessor.test.ts +0 -268
- package/tests/services/actionProcessors/inlineQueryActionProcessor.test.ts +0 -616
- package/tests/services/actionProcessors/processorTestHelpers.ts +0 -147
- package/tests/services/actionProcessors/scheduledActionProcessor.test.ts +0 -153
- package/tests/services/jsonFileStorage.test.ts +0 -927
- package/tests/services/nodeTimeoutScheduler.test.ts +0 -421
- package/tests/services/responseProcessingQueue.test.ts +0 -388
- package/tsconfig.build.json +0 -8
- package/tsconfig.json +0 -118
|
@@ -93,7 +93,7 @@ export class JsonFileStorage {
|
|
|
93
93
|
async updateStateFor(action, chatId, update) {
|
|
94
94
|
await this.lock(action.key, async () => {
|
|
95
95
|
const data = this.data.load(action);
|
|
96
|
-
const state = data[chatId];
|
|
96
|
+
const state = data[chatId] ?? action.stateConstructor();
|
|
97
97
|
await update(state);
|
|
98
98
|
data[chatId] = state;
|
|
99
99
|
await this.data.save(data, action);
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "https://github.com/AlexSolari/botFramework.git"
|
|
16
16
|
},
|
|
17
|
-
"version": "0.7.
|
|
17
|
+
"version": "0.7.16",
|
|
18
18
|
"type": "module",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"async-sema": "^3.1.1",
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
},
|
|
24
24
|
"main": "dist/index.js",
|
|
25
25
|
"types": "dist/index.d.ts",
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
26
29
|
"devDependencies": {
|
|
27
30
|
"@eslint/js": "^9.39.4",
|
|
28
31
|
"@types/bun": "^1.3.11",
|
package/eslint.config.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import eslint from '@eslint/js';
|
|
3
|
-
import tseslint from 'typescript-eslint';
|
|
4
|
-
import parser from '@typescript-eslint/parser';
|
|
5
|
-
import { defineConfig } from 'eslint/config';
|
|
6
|
-
import { fileURLToPath } from 'node:url';
|
|
7
|
-
import { dirname } from 'node:path';
|
|
8
|
-
|
|
9
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
-
|
|
11
|
-
export default defineConfig(
|
|
12
|
-
{
|
|
13
|
-
ignores: ['dist/**', 'eslint.config.ts']
|
|
14
|
-
},
|
|
15
|
-
eslint.configs.recommended,
|
|
16
|
-
tseslint.configs.strictTypeChecked,
|
|
17
|
-
{
|
|
18
|
-
languageOptions: {
|
|
19
|
-
parser,
|
|
20
|
-
parserOptions: {
|
|
21
|
-
tsconfigRootDir: __dirname,
|
|
22
|
-
sourceType: 'module',
|
|
23
|
-
projectService: true
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
plugins: { '@typescript-eslint': tseslint.plugin },
|
|
27
|
-
rules: {
|
|
28
|
-
'@typescript-eslint/switch-exhaustiveness-check': 'error',
|
|
29
|
-
'@typescript-eslint/no-unused-vars': [
|
|
30
|
-
'error',
|
|
31
|
-
{
|
|
32
|
-
args: 'all',
|
|
33
|
-
argsIgnorePattern: '^_',
|
|
34
|
-
caughtErrors: 'all',
|
|
35
|
-
caughtErrorsIgnorePattern: '^_',
|
|
36
|
-
destructuredArrayIgnorePattern: '^_',
|
|
37
|
-
varsIgnorePattern: '^_',
|
|
38
|
-
ignoreRestSiblings: true
|
|
39
|
-
}
|
|
40
|
-
],
|
|
41
|
-
'@typescript-eslint/no-misused-promises': [
|
|
42
|
-
'error',
|
|
43
|
-
{
|
|
44
|
-
checksVoidReturn: true,
|
|
45
|
-
checksConditionals: true
|
|
46
|
-
}
|
|
47
|
-
],
|
|
48
|
-
'@typescript-eslint/restrict-template-expressions': [
|
|
49
|
-
'error',
|
|
50
|
-
{
|
|
51
|
-
allowNumber: true
|
|
52
|
-
}
|
|
53
|
-
],
|
|
54
|
-
'@typescript-eslint/unbound-method': [
|
|
55
|
-
'error',
|
|
56
|
-
{
|
|
57
|
-
ignoreStatic: true
|
|
58
|
-
}
|
|
59
|
-
]
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { CommandActionBuilder } from '../helpers/builders/commandActionBuilder';
|
|
2
|
-
import { Seconds } from '../types/timeValues';
|
|
3
|
-
|
|
4
|
-
export function buildHelpCommand(readmes: string[], botUsername: string) {
|
|
5
|
-
const helpCommandBuilder = new CommandActionBuilder('Reaction.Help')
|
|
6
|
-
.on(['/help', `/help@${botUsername}`])
|
|
7
|
-
.do((ctx) => {
|
|
8
|
-
ctx.reply.withText(readmes.join('\n\n'));
|
|
9
|
-
})
|
|
10
|
-
.withCooldown({
|
|
11
|
-
cooldown: 60 as Seconds
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
if (readmes.length == 0) helpCommandBuilder.disabled();
|
|
15
|
-
|
|
16
|
-
return helpCommandBuilder.build();
|
|
17
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { TelegramUser } from '../types/externalAliases';
|
|
2
|
-
import { MessageTypeValue } from '../types/messageTypes';
|
|
3
|
-
import { TraceId } from '../types/trace';
|
|
4
|
-
|
|
5
|
-
export class ChatHistoryMessage {
|
|
6
|
-
constructor(
|
|
7
|
-
/** The unique identifier for the message */
|
|
8
|
-
readonly id: number,
|
|
9
|
-
/** The user who sent the message */
|
|
10
|
-
readonly from: TelegramUser | undefined,
|
|
11
|
-
/** The content of the message */
|
|
12
|
-
readonly text: string,
|
|
13
|
-
/** The type of the message */
|
|
14
|
-
readonly type: MessageTypeValue,
|
|
15
|
-
/** The trace identifier for the message */
|
|
16
|
-
readonly traceId: TraceId,
|
|
17
|
-
/** The identifier for the message this message is replying to */
|
|
18
|
-
readonly replyToId: number | undefined,
|
|
19
|
-
/** The date the message was sent, represented as a Unix timestamp */
|
|
20
|
-
readonly date: number
|
|
21
|
-
) {}
|
|
22
|
-
}
|
package/src/dtos/chatInfo.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ChatHistoryMessage } from './chatHistoryMessage';
|
|
2
|
-
|
|
3
|
-
export class ChatInfo {
|
|
4
|
-
constructor(
|
|
5
|
-
/** Id of a chat that action is executed in. */
|
|
6
|
-
readonly id: number,
|
|
7
|
-
/** Name of a chat that action is executed in. */
|
|
8
|
-
readonly name: string,
|
|
9
|
-
/** Last 100 messages in chat where action is executed */
|
|
10
|
-
readonly messageHistory: ChatHistoryMessage[]
|
|
11
|
-
) {}
|
|
12
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
const _SkipTriggerReasonsObject = {
|
|
2
|
-
UserIdMissing: 'UserIdMissing',
|
|
3
|
-
UserForbidden: 'UserForbidden',
|
|
4
|
-
OnCooldown: 'OnCooldown',
|
|
5
|
-
CustomConditionNotMet: 'CustomConditionNotMet',
|
|
6
|
-
TriggerNotSatisfied: 'TriggerNotSatisfied',
|
|
7
|
-
Other: 'Other',
|
|
8
|
-
ActionDisabled: 'ActionDisabled',
|
|
9
|
-
ChatForbidden: 'ChatForbidden'
|
|
10
|
-
} as const;
|
|
11
|
-
|
|
12
|
-
export type SkipTriggerReasons = keyof typeof _SkipTriggerReasonsObject;
|
|
13
|
-
|
|
14
|
-
export class CommandTriggerCheckResult {
|
|
15
|
-
static DontTriggerAndSkipCooldown(reason: SkipTriggerReasons) {
|
|
16
|
-
return new CommandTriggerCheckResult(false, [], true, reason);
|
|
17
|
-
}
|
|
18
|
-
static DoNotTrigger(reason: SkipTriggerReasons) {
|
|
19
|
-
return new CommandTriggerCheckResult(false, [], false, reason);
|
|
20
|
-
}
|
|
21
|
-
static Trigger() {
|
|
22
|
-
return new CommandTriggerCheckResult(true, [], false);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
constructor(
|
|
26
|
-
readonly shouldExecute: boolean,
|
|
27
|
-
readonly matchResults: RegExpExecArray[],
|
|
28
|
-
readonly skipCooldown: boolean,
|
|
29
|
-
readonly reason?: SkipTriggerReasons
|
|
30
|
-
) {}
|
|
31
|
-
|
|
32
|
-
mergeWith(other: CommandTriggerCheckResult) {
|
|
33
|
-
return new CommandTriggerCheckResult(
|
|
34
|
-
this.shouldExecute || other.shouldExecute,
|
|
35
|
-
this.matchResults.concat(other.matchResults),
|
|
36
|
-
this.skipCooldown || other.skipCooldown,
|
|
37
|
-
other.reason
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
}
|
package/src/dtos/cooldownInfo.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { randomInt } from 'crypto';
|
|
2
|
-
import { MessageType, MessageTypeValue } from '../types/messageTypes';
|
|
3
|
-
import { ChatInfo } from './chatInfo';
|
|
4
|
-
import { createTrace } from '../helpers/traceFactory';
|
|
5
|
-
import { TraceId } from '../types/trace';
|
|
6
|
-
import { ChatHistoryMessage } from './chatHistoryMessage';
|
|
7
|
-
import { TelegramMessage, TelegramUser } from '../types/externalAliases';
|
|
8
|
-
|
|
9
|
-
export class IncomingMessage {
|
|
10
|
-
readonly messageId: number;
|
|
11
|
-
readonly chatInfo: ChatInfo;
|
|
12
|
-
readonly from: TelegramUser | undefined;
|
|
13
|
-
readonly text: string;
|
|
14
|
-
readonly type: MessageTypeValue;
|
|
15
|
-
readonly traceId: TraceId;
|
|
16
|
-
readonly replyToMessageId: number | undefined;
|
|
17
|
-
|
|
18
|
-
readonly updateObject: TelegramMessage;
|
|
19
|
-
|
|
20
|
-
private detectMessageType(message: TelegramMessage) {
|
|
21
|
-
if ('forward_origin' in message) return MessageType.Forward;
|
|
22
|
-
if ('text' in message) return MessageType.Text;
|
|
23
|
-
if ('video' in message) return MessageType.Video;
|
|
24
|
-
if ('photo' in message) return MessageType.Photo;
|
|
25
|
-
if ('sticker' in message) return MessageType.Sticker;
|
|
26
|
-
if ('animation' in message) return MessageType.Animation;
|
|
27
|
-
if ('voice' in message) return MessageType.Voice;
|
|
28
|
-
if ('audio' in message) return MessageType.Audio;
|
|
29
|
-
if ('document' in message) return MessageType.Document;
|
|
30
|
-
if ('left_chat_member' in message) return MessageType.LeftChatMember;
|
|
31
|
-
if ('new_chat_member' in message) return MessageType.NewChatMember;
|
|
32
|
-
if ('poll' in message) return MessageType.Poll;
|
|
33
|
-
if ('location' in message) return MessageType.Location;
|
|
34
|
-
|
|
35
|
-
return MessageType.Unknown;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
constructor(
|
|
39
|
-
ctxMessage: TelegramMessage,
|
|
40
|
-
botName: string,
|
|
41
|
-
history: ChatHistoryMessage[]
|
|
42
|
-
) {
|
|
43
|
-
this.traceId = createTrace(
|
|
44
|
-
this,
|
|
45
|
-
botName,
|
|
46
|
-
randomInt(10000, 99999).toString()
|
|
47
|
-
);
|
|
48
|
-
this.messageId = ctxMessage.message_id;
|
|
49
|
-
this.replyToMessageId =
|
|
50
|
-
'reply_to_message' in ctxMessage
|
|
51
|
-
? ctxMessage.reply_to_message?.message_id
|
|
52
|
-
: undefined;
|
|
53
|
-
this.from = ctxMessage.from;
|
|
54
|
-
this.text = this.getMessageText(ctxMessage);
|
|
55
|
-
this.chatInfo = new ChatInfo(
|
|
56
|
-
ctxMessage.chat.id,
|
|
57
|
-
'title' in ctxMessage.chat
|
|
58
|
-
? `${ctxMessage.chat.title} ${ctxMessage.chat.id}`
|
|
59
|
-
: 'DM',
|
|
60
|
-
history
|
|
61
|
-
);
|
|
62
|
-
this.type = this.detectMessageType(ctxMessage);
|
|
63
|
-
this.updateObject = ctxMessage;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private getMessageText(ctxMessage: TelegramMessage) {
|
|
67
|
-
if ('text' in ctxMessage) return ctxMessage.text;
|
|
68
|
-
|
|
69
|
-
return 'caption' in ctxMessage ? ctxMessage.caption ?? '' : '';
|
|
70
|
-
}
|
|
71
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { TraceId } from '../types/trace';
|
|
2
|
-
|
|
3
|
-
export class IncomingInlineQuery {
|
|
4
|
-
readonly abortController: AbortController;
|
|
5
|
-
|
|
6
|
-
constructor(
|
|
7
|
-
readonly queryId: string,
|
|
8
|
-
readonly query: string,
|
|
9
|
-
readonly userId: number,
|
|
10
|
-
readonly traceId: TraceId
|
|
11
|
-
) {
|
|
12
|
-
this.abortController = new AbortController();
|
|
13
|
-
}
|
|
14
|
-
}
|
package/src/dtos/messageInfo.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { TelegramMessage } from '../types/externalAliases';
|
|
2
|
-
import { MessageTypeValue } from '../types/messageTypes';
|
|
3
|
-
|
|
4
|
-
export class MessageInfo {
|
|
5
|
-
constructor(
|
|
6
|
-
/** Id of a message that triggered this action. */
|
|
7
|
-
readonly id: number,
|
|
8
|
-
/** Text of a message that triggered this action. */
|
|
9
|
-
readonly text: string,
|
|
10
|
-
/** Type of message being received */
|
|
11
|
-
readonly type: MessageTypeValue,
|
|
12
|
-
/** Message object recieved from Telegram */
|
|
13
|
-
readonly telegramUpdateObject: TelegramMessage
|
|
14
|
-
) {}
|
|
15
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { CooldownInfo } from './cooldownInfo';
|
|
2
|
-
import {
|
|
3
|
-
CommandActionPropertyProvider,
|
|
4
|
-
ScheduledActionPropertyProvider
|
|
5
|
-
} from '../types/propertyProvider';
|
|
6
|
-
import { HoursOfDay } from '../types/timeValues';
|
|
7
|
-
|
|
8
|
-
export type CommandActionProviders = {
|
|
9
|
-
cooldownProvider: CommandActionPropertyProvider<CooldownInfo>;
|
|
10
|
-
isActiveProvider: CommandActionPropertyProvider<boolean>;
|
|
11
|
-
chatsBlacklistProvider: CommandActionPropertyProvider<number[]>;
|
|
12
|
-
chatsWhitelistProvider: CommandActionPropertyProvider<number[]>;
|
|
13
|
-
usersWhitelistProvider: CommandActionPropertyProvider<number[]>;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export type ScheduledActionProviders = {
|
|
17
|
-
timeinHoursProvider: ScheduledActionPropertyProvider<HoursOfDay>;
|
|
18
|
-
isActiveProvider: ScheduledActionPropertyProvider<boolean>;
|
|
19
|
-
chatsWhitelistProvider: ScheduledActionPropertyProvider<number[]>;
|
|
20
|
-
};
|
package/src/dtos/replyInfo.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { IActionState } from '../../types/actionState';
|
|
2
|
-
import { IActionWithState } from '../../types/action';
|
|
3
|
-
import { BotResponseTypes, IChatResponse } from '../../types/response';
|
|
4
|
-
import { Milliseconds } from '../../types/timeValues';
|
|
5
|
-
import { TraceId } from '../../types/trace';
|
|
6
|
-
import { ChatInfo } from '../chatInfo';
|
|
7
|
-
|
|
8
|
-
export class DelayResponse implements IChatResponse {
|
|
9
|
-
readonly kind = BotResponseTypes.delay;
|
|
10
|
-
readonly createdAt = Date.now();
|
|
11
|
-
|
|
12
|
-
readonly chatInfo: ChatInfo;
|
|
13
|
-
readonly traceId: TraceId;
|
|
14
|
-
readonly delay: Milliseconds;
|
|
15
|
-
readonly action: IActionWithState<IActionState>;
|
|
16
|
-
|
|
17
|
-
constructor(
|
|
18
|
-
delay: Milliseconds,
|
|
19
|
-
chatInfo: ChatInfo,
|
|
20
|
-
traceId: TraceId,
|
|
21
|
-
action: IActionWithState<IActionState>
|
|
22
|
-
) {
|
|
23
|
-
this.chatInfo = chatInfo;
|
|
24
|
-
this.delay = delay;
|
|
25
|
-
this.traceId = traceId;
|
|
26
|
-
this.action = action;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BotResponseTypes,
|
|
3
|
-
IReplyResponseWithContent
|
|
4
|
-
} from '../../types/response';
|
|
5
|
-
import { MessageSendingOptions } from '../../types/messageSendingOptions';
|
|
6
|
-
import { IAction } from '../../types/action';
|
|
7
|
-
import { ChatInfo } from '../chatInfo';
|
|
8
|
-
import { TraceId } from '../../types/trace';
|
|
9
|
-
import { ReplyInfo } from '../replyInfo';
|
|
10
|
-
import { IReplyCapture } from '../../types/capture';
|
|
11
|
-
import { InputFile } from '../../types/inputFile';
|
|
12
|
-
|
|
13
|
-
export class ImageMessage implements IReplyResponseWithContent<InputFile> {
|
|
14
|
-
readonly kind = BotResponseTypes.image;
|
|
15
|
-
readonly createdAt = Date.now();
|
|
16
|
-
readonly captures: IReplyCapture[] = [];
|
|
17
|
-
|
|
18
|
-
readonly content: InputFile;
|
|
19
|
-
readonly chatInfo: ChatInfo;
|
|
20
|
-
readonly replyInfo: ReplyInfo | undefined;
|
|
21
|
-
readonly traceId: TraceId;
|
|
22
|
-
readonly disableWebPreview = false;
|
|
23
|
-
readonly shouldPin: boolean;
|
|
24
|
-
readonly action: IAction;
|
|
25
|
-
|
|
26
|
-
constructor(
|
|
27
|
-
image: InputFile,
|
|
28
|
-
chatInfo: ChatInfo,
|
|
29
|
-
traceId: TraceId,
|
|
30
|
-
action: IAction,
|
|
31
|
-
replyInfo: ReplyInfo | undefined,
|
|
32
|
-
options?: MessageSendingOptions
|
|
33
|
-
) {
|
|
34
|
-
this.content = image;
|
|
35
|
-
this.chatInfo = chatInfo;
|
|
36
|
-
this.replyInfo = replyInfo;
|
|
37
|
-
this.traceId = traceId;
|
|
38
|
-
this.shouldPin = options?.pin ?? false;
|
|
39
|
-
this.action = action;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { InlineQueryAction } from '../../entities/actions/inlineQueryAction';
|
|
2
|
-
import { TelegramInlineQueryResult } from '../../types/externalAliases';
|
|
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: TelegramInlineQueryResult[];
|
|
14
|
-
|
|
15
|
-
constructor(
|
|
16
|
-
queryResult: TelegramInlineQueryResult[],
|
|
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,30 +0,0 @@
|
|
|
1
|
-
import { BotResponseTypes, IChatResponse } from '../../types/response';
|
|
2
|
-
import { IAction } from '../../types/action';
|
|
3
|
-
import { ChatInfo } from '../chatInfo';
|
|
4
|
-
import { TraceId } from '../../types/trace';
|
|
5
|
-
import { TelegramEmoji } from '../../types/externalAliases';
|
|
6
|
-
|
|
7
|
-
export class Reaction implements IChatResponse {
|
|
8
|
-
readonly kind = BotResponseTypes.react;
|
|
9
|
-
readonly createdAt = Date.now();
|
|
10
|
-
|
|
11
|
-
readonly chatInfo: ChatInfo;
|
|
12
|
-
readonly messageId: number;
|
|
13
|
-
readonly traceId: TraceId;
|
|
14
|
-
readonly emoji: TelegramEmoji;
|
|
15
|
-
readonly action: IAction;
|
|
16
|
-
|
|
17
|
-
constructor(
|
|
18
|
-
traceId: TraceId,
|
|
19
|
-
chatInfo: ChatInfo,
|
|
20
|
-
messageId: number,
|
|
21
|
-
emoji: TelegramEmoji,
|
|
22
|
-
action: IAction
|
|
23
|
-
) {
|
|
24
|
-
this.chatInfo = chatInfo;
|
|
25
|
-
this.messageId = messageId;
|
|
26
|
-
this.emoji = emoji;
|
|
27
|
-
this.traceId = traceId;
|
|
28
|
-
this.action = action;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { TextMessageSendingOptions } from '../../types/messageSendingOptions';
|
|
2
|
-
import {
|
|
3
|
-
BotResponseTypes,
|
|
4
|
-
IReplyResponseWithContent
|
|
5
|
-
} from '../../types/response';
|
|
6
|
-
import { IAction } from '../../types/action';
|
|
7
|
-
import { ChatInfo } from '../chatInfo';
|
|
8
|
-
import { TraceId } from '../../types/trace';
|
|
9
|
-
import { ReplyInfo } from '../replyInfo';
|
|
10
|
-
import { IReplyCapture } from '../../types/capture';
|
|
11
|
-
import { TelegramInlineKeyboardButton } from '../../types/externalAliases';
|
|
12
|
-
|
|
13
|
-
export class TextMessage implements IReplyResponseWithContent<string> {
|
|
14
|
-
readonly kind = BotResponseTypes.text;
|
|
15
|
-
readonly createdAt = Date.now();
|
|
16
|
-
readonly captures: IReplyCapture[] = [];
|
|
17
|
-
|
|
18
|
-
readonly content: string;
|
|
19
|
-
readonly chatInfo: ChatInfo;
|
|
20
|
-
readonly replyInfo: ReplyInfo | undefined;
|
|
21
|
-
readonly traceId: TraceId;
|
|
22
|
-
readonly disableWebPreview: boolean;
|
|
23
|
-
readonly shouldPin: boolean;
|
|
24
|
-
readonly action: IAction;
|
|
25
|
-
readonly keyboard?: TelegramInlineKeyboardButton[][];
|
|
26
|
-
|
|
27
|
-
constructor(
|
|
28
|
-
text: string,
|
|
29
|
-
chatInfo: ChatInfo,
|
|
30
|
-
traceId: TraceId,
|
|
31
|
-
action: IAction,
|
|
32
|
-
replyInfo?: ReplyInfo,
|
|
33
|
-
options?: TextMessageSendingOptions
|
|
34
|
-
) {
|
|
35
|
-
this.content = text;
|
|
36
|
-
this.chatInfo = chatInfo;
|
|
37
|
-
this.replyInfo = replyInfo;
|
|
38
|
-
this.traceId = traceId;
|
|
39
|
-
this.disableWebPreview = options?.disableWebPreview ?? false;
|
|
40
|
-
this.shouldPin = options?.pin ?? false;
|
|
41
|
-
this.action = action;
|
|
42
|
-
this.keyboard = options?.keyboard;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { BotResponseTypes, IChatResponse } from '../../types/response';
|
|
2
|
-
import { IActionWithState } from '../../types/action';
|
|
3
|
-
import { IActionState } from '../../types/actionState';
|
|
4
|
-
import { ChatInfo } from '../chatInfo';
|
|
5
|
-
import { TraceId } from '../../types/trace';
|
|
6
|
-
|
|
7
|
-
export class UnpinResponse implements IChatResponse {
|
|
8
|
-
readonly kind = BotResponseTypes.unpin;
|
|
9
|
-
readonly createdAt = Date.now();
|
|
10
|
-
|
|
11
|
-
readonly messageId: number;
|
|
12
|
-
readonly chatInfo: ChatInfo;
|
|
13
|
-
readonly traceId: TraceId;
|
|
14
|
-
readonly action: IActionWithState<IActionState>;
|
|
15
|
-
|
|
16
|
-
constructor(
|
|
17
|
-
messageId: number,
|
|
18
|
-
chatInfo: ChatInfo,
|
|
19
|
-
traceId: TraceId,
|
|
20
|
-
action: IActionWithState<IActionState>
|
|
21
|
-
) {
|
|
22
|
-
this.messageId = messageId;
|
|
23
|
-
this.chatInfo = chatInfo;
|
|
24
|
-
this.traceId = traceId;
|
|
25
|
-
this.action = action;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BotResponseTypes,
|
|
3
|
-
IReplyResponseWithContent
|
|
4
|
-
} from '../../types/response';
|
|
5
|
-
import { MessageSendingOptions } from '../../types/messageSendingOptions';
|
|
6
|
-
import { IAction } from '../../types/action';
|
|
7
|
-
import { ChatInfo } from '../chatInfo';
|
|
8
|
-
import { TraceId } from '../../types/trace';
|
|
9
|
-
import { ReplyInfo } from '../replyInfo';
|
|
10
|
-
import { IReplyCapture } from '../../types/capture';
|
|
11
|
-
import { InputFile } from '../../types/inputFile';
|
|
12
|
-
|
|
13
|
-
export class VideoMessage implements IReplyResponseWithContent<InputFile> {
|
|
14
|
-
readonly kind = BotResponseTypes.video;
|
|
15
|
-
readonly createdAt = Date.now();
|
|
16
|
-
readonly captures: IReplyCapture[] = [];
|
|
17
|
-
|
|
18
|
-
readonly content: InputFile;
|
|
19
|
-
readonly chatInfo: ChatInfo;
|
|
20
|
-
readonly replyInfo: ReplyInfo | undefined;
|
|
21
|
-
readonly traceId: TraceId;
|
|
22
|
-
readonly disableWebPreview = false;
|
|
23
|
-
readonly shouldPin: boolean;
|
|
24
|
-
readonly action: IAction;
|
|
25
|
-
|
|
26
|
-
constructor(
|
|
27
|
-
video: InputFile,
|
|
28
|
-
chatInfo: ChatInfo,
|
|
29
|
-
traceId: TraceId,
|
|
30
|
-
action: IAction,
|
|
31
|
-
replyInfo: ReplyInfo | undefined,
|
|
32
|
-
options?: MessageSendingOptions
|
|
33
|
-
) {
|
|
34
|
-
this.content = video;
|
|
35
|
-
this.chatInfo = chatInfo;
|
|
36
|
-
this.replyInfo = replyInfo;
|
|
37
|
-
this.traceId = traceId;
|
|
38
|
-
this.shouldPin = options?.pin ?? false;
|
|
39
|
-
this.action = action;
|
|
40
|
-
}
|
|
41
|
-
}
|
package/src/dtos/userInfo.ts
DELETED