@codebam/cf-workers-telegram-bot 9.4.1 → 9.4.3
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/telegram_api.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import TelegramInlineQueryResultVideo from './types/TelegramInlineQueryResultVid
|
|
|
4
4
|
/** Interface for common Telegram API parameters */
|
|
5
5
|
export interface TelegramApiBaseParams {
|
|
6
6
|
chat_id: number | string;
|
|
7
|
+
message_thread_id?: number;
|
|
7
8
|
business_connection_id?: string | number;
|
|
8
9
|
}
|
|
9
10
|
/** Interface for message parameters */
|
|
@@ -32,6 +32,11 @@ export default class TelegramExecutionContext {
|
|
|
32
32
|
* @returns The message ID as a string or empty string if not available
|
|
33
33
|
*/
|
|
34
34
|
private getMessageId;
|
|
35
|
+
/**
|
|
36
|
+
* Get the message thread ID from the current update
|
|
37
|
+
* @returns The message thread ID as a number or undefined
|
|
38
|
+
*/
|
|
39
|
+
private getThreadId;
|
|
35
40
|
/**
|
|
36
41
|
* Reply to the last message with a video
|
|
37
42
|
* @param video - string to a video on the internet or a file_id on telegram
|
|
@@ -85,6 +85,13 @@ export default class TelegramExecutionContext {
|
|
|
85
85
|
}
|
|
86
86
|
return '';
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Get the message thread ID from the current update
|
|
90
|
+
* @returns The message thread ID as a number or undefined
|
|
91
|
+
*/
|
|
92
|
+
getThreadId() {
|
|
93
|
+
return this.update.message?.message_thread_id;
|
|
94
|
+
}
|
|
88
95
|
/**
|
|
89
96
|
* Reply to the last message with a video
|
|
90
97
|
* @param video - string to a video on the internet or a file_id on telegram
|
|
@@ -98,6 +105,7 @@ export default class TelegramExecutionContext {
|
|
|
98
105
|
return await this.api.sendVideo(this.bot.api.toString(), {
|
|
99
106
|
...options,
|
|
100
107
|
chat_id: this.getChatId(),
|
|
108
|
+
message_thread_id: this.getThreadId(),
|
|
101
109
|
reply_to_message_id: this.getMessageId(),
|
|
102
110
|
video,
|
|
103
111
|
});
|
|
@@ -134,6 +142,7 @@ export default class TelegramExecutionContext {
|
|
|
134
142
|
return await this.api.sendPhoto(this.bot.api.toString(), {
|
|
135
143
|
...options,
|
|
136
144
|
chat_id: this.getChatId(),
|
|
145
|
+
message_thread_id: this.getThreadId(),
|
|
137
146
|
reply_to_message_id: this.getMessageId(),
|
|
138
147
|
photo,
|
|
139
148
|
caption,
|
|
@@ -156,15 +165,16 @@ export default class TelegramExecutionContext {
|
|
|
156
165
|
case 'message':
|
|
157
166
|
case 'photo':
|
|
158
167
|
case 'document':
|
|
159
|
-
case 'guest_message':
|
|
160
168
|
return await this.api.sendChatAction(this.bot.api.toString(), {
|
|
161
169
|
chat_id: this.getChatId(),
|
|
170
|
+
message_thread_id: this.getThreadId(),
|
|
162
171
|
action: 'typing',
|
|
163
172
|
});
|
|
164
173
|
case 'business_message':
|
|
165
174
|
return await this.api.sendChatAction(this.bot.api.toString(), {
|
|
166
175
|
business_connection_id: this.update.business_message?.business_connection_id.toString() ?? '',
|
|
167
176
|
chat_id: this.getChatId(),
|
|
177
|
+
message_thread_id: this.getThreadId(),
|
|
168
178
|
action: 'typing',
|
|
169
179
|
});
|
|
170
180
|
default:
|
|
@@ -210,6 +220,7 @@ export default class TelegramExecutionContext {
|
|
|
210
220
|
return await this.api.sendMessageDraft(this.bot.api.toString(), {
|
|
211
221
|
...options,
|
|
212
222
|
chat_id: this.getChatId(),
|
|
223
|
+
message_thread_id: this.getThreadId(),
|
|
213
224
|
text: message,
|
|
214
225
|
parse_mode,
|
|
215
226
|
draft_id,
|
|
@@ -235,6 +246,7 @@ export default class TelegramExecutionContext {
|
|
|
235
246
|
return await this.api.sendMessage(this.bot.api.toString(), {
|
|
236
247
|
...options,
|
|
237
248
|
chat_id: this.getChatId(),
|
|
249
|
+
message_thread_id: this.getThreadId(),
|
|
238
250
|
reply_to_message_id: this.getMessageId(),
|
|
239
251
|
text: message,
|
|
240
252
|
parse_mode,
|
|
@@ -243,12 +255,14 @@ export default class TelegramExecutionContext {
|
|
|
243
255
|
return await this.api.sendMessage(this.bot.api.toString(), {
|
|
244
256
|
...options,
|
|
245
257
|
chat_id: this.getChatId(),
|
|
258
|
+
message_thread_id: this.getThreadId(),
|
|
246
259
|
text: message,
|
|
247
260
|
parse_mode,
|
|
248
261
|
});
|
|
249
262
|
case 'business_message':
|
|
250
263
|
return await this.api.sendMessage(this.bot.api.toString(), {
|
|
251
264
|
chat_id: this.getChatId(),
|
|
265
|
+
message_thread_id: this.getThreadId(),
|
|
252
266
|
text: message,
|
|
253
267
|
business_connection_id: this.update.business_message?.business_connection_id.toString() ?? '',
|
|
254
268
|
parse_mode,
|
|
@@ -258,6 +272,7 @@ export default class TelegramExecutionContext {
|
|
|
258
272
|
return await this.api.sendMessage(this.bot.api.toString(), {
|
|
259
273
|
...options,
|
|
260
274
|
chat_id: this.update.callback_query.message.chat.id.toString(),
|
|
275
|
+
message_thread_id: this.getThreadId(),
|
|
261
276
|
text: message,
|
|
262
277
|
parse_mode,
|
|
263
278
|
});
|
|
@@ -280,6 +295,7 @@ export default class TelegramExecutionContext {
|
|
|
280
295
|
async sendStarsInvoice(title, description, payload, amount) {
|
|
281
296
|
return await this.api.sendInvoice(this.bot.api.toString(), {
|
|
282
297
|
chat_id: this.getChatId(),
|
|
298
|
+
message_thread_id: this.getThreadId(),
|
|
283
299
|
title,
|
|
284
300
|
description,
|
|
285
301
|
payload,
|
|
@@ -7,6 +7,7 @@ import TelegramUser from './TelegramUser.js';
|
|
|
7
7
|
import TelegramSuccessfulPayment from './TelegramSuccessfulPayment.js';
|
|
8
8
|
interface TelegramMessage {
|
|
9
9
|
message_id: number;
|
|
10
|
+
message_thread_id?: number;
|
|
10
11
|
from: TelegramFrom;
|
|
11
12
|
sender_chat?: TelegramChat;
|
|
12
13
|
date: number;
|