@codebam/cf-workers-telegram-bot 11.9.0 → 11.11.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.
@@ -203,6 +203,7 @@ export default class TelegramApi {
203
203
  parse_mode?: string;
204
204
  disable_web_page_preview?: boolean;
205
205
  reply_markup?: object;
206
+ business_connection_id?: string | number;
206
207
  }): Promise<Response>;
207
208
  sendMessageDraft(botApi: string, data: SendMessageDraftParams): Promise<Response>;
208
209
  /**
@@ -219,4 +220,10 @@ export default class TelegramApi {
219
220
  * @returns Promise with the API response
220
221
  */
221
222
  answerPreCheckoutQuery(botApi: string, data: AnswerPreCheckoutParams): Promise<Response>;
223
+ /**
224
+ * Get basic information about the bot
225
+ * @param botApi - full URL to the telegram API without slug
226
+ * @returns Promise with the API response
227
+ */
228
+ getMe(botApi: string): Promise<Response>;
222
229
  }
@@ -206,4 +206,13 @@ export default class TelegramApi {
206
206
  const url = this.getApiUrl(botApi, 'answerPreCheckoutQuery', data);
207
207
  return await this.fetchAndLog(url, 'answerPreCheckoutQuery', data);
208
208
  }
209
+ /**
210
+ * Get basic information about the bot
211
+ * @param botApi - full URL to the telegram API without slug
212
+ * @returns Promise with the API response
213
+ */
214
+ async getMe(botApi) {
215
+ const url = this.getApiUrl(botApi, 'getMe', {});
216
+ return await this.fetchAndLog(url, 'getMe', {});
217
+ }
209
218
  }
@@ -156,6 +156,14 @@ export default class TelegramExecutionContext {
156
156
  reply_to_message_id: this.getMessageId(),
157
157
  video,
158
158
  });
159
+ case 'business_message':
160
+ return await this.api.sendVideo(this.bot.api.toString(), {
161
+ ...options,
162
+ chat_id: this.getChatId(),
163
+ message_thread_id: this.getThreadId(),
164
+ business_connection_id: this.update.business_message?.business_connection_id.toString() ?? '',
165
+ video,
166
+ });
159
167
  case 'guest_message':
160
168
  return await this.answerGuestQueryVideo(video);
161
169
  case 'inline':
@@ -196,6 +204,15 @@ export default class TelegramExecutionContext {
196
204
  photo,
197
205
  caption,
198
206
  });
207
+ case 'business_message':
208
+ return await this.api.sendPhoto(this.bot.api.toString(), {
209
+ ...options,
210
+ chat_id: this.getChatId(),
211
+ message_thread_id: this.getThreadId(),
212
+ business_connection_id: this.update.business_message?.business_connection_id.toString() ?? '',
213
+ photo,
214
+ caption,
215
+ });
199
216
  case 'guest_message':
200
217
  return await this.answerGuestQueryPhoto(photo, caption);
201
218
  case 'inline':
@@ -226,6 +243,15 @@ export default class TelegramExecutionContext {
226
243
  voice,
227
244
  caption,
228
245
  });
246
+ case 'business_message':
247
+ return await this.api.sendVoice(this.bot.api.toString(), {
248
+ ...options,
249
+ chat_id: this.getChatId(),
250
+ message_thread_id: this.getThreadId(),
251
+ business_connection_id: this.update.business_message?.business_connection_id.toString() ?? '',
252
+ voice,
253
+ caption,
254
+ });
229
255
  case 'guest_message':
230
256
  return await this.answerGuestQueryVoice(voice, caption);
231
257
  default:
@@ -336,12 +362,14 @@ export default class TelegramExecutionContext {
336
362
  */
337
363
  async streamReply(message, draft_id, parse_mode = '', options = {}) {
338
364
  const message_id = this.drafts.get(draft_id);
365
+ const business_connection_id = this.update.business_message?.business_connection_id.toString();
339
366
  if (message_id) {
340
367
  return await this.api.editMessageText(this.bot.api.toString(), {
341
368
  chat_id: this.getChatId(),
342
369
  message_id,
343
370
  text: message,
344
371
  parse_mode,
372
+ business_connection_id,
345
373
  ...options,
346
374
  });
347
375
  }
@@ -358,6 +386,7 @@ export default class TelegramExecutionContext {
358
386
  message_thread_id: this.getThreadId(),
359
387
  text: message,
360
388
  parse_mode,
389
+ business_connection_id,
361
390
  });
362
391
  if (response.status === 200) {
363
392
  const cloned = response.clone();
@@ -442,6 +471,7 @@ export default class TelegramExecutionContext {
442
471
  return await this.api.sendInvoice(this.bot.api.toString(), {
443
472
  chat_id: this.getChatId(),
444
473
  message_thread_id: this.getThreadId(),
474
+ business_connection_id: this.update.business_message?.business_connection_id.toString(),
445
475
  title,
446
476
  description,
447
477
  payload,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebam/cf-workers-telegram-bot",
3
- "version": "11.9.0",
3
+ "version": "11.11.0",
4
4
  "description": "serverless telegram bot on cf workers",
5
5
  "main": "./dist/main.js",
6
6
  "module": "./dist/main.js",