@mtkruto/node 0.1.190 → 0.1.200

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.
Files changed (205) hide show
  1. package/esm/0_errors.d.ts +12 -0
  2. package/esm/0_errors.js +19 -0
  3. package/esm/1_utilities.d.ts +1 -1
  4. package/esm/1_utilities.js +1 -1
  5. package/esm/2_tl.d.ts +6 -6
  6. package/esm/2_tl.js +6 -6
  7. package/esm/3_storage.d.ts +5 -5
  8. package/esm/3_storage.js +5 -5
  9. package/esm/3_types.d.ts +6 -5
  10. package/esm/3_types.js +6 -5
  11. package/esm/4_constants.d.ts +2 -2
  12. package/esm/4_constants.js +2 -2
  13. package/esm/5_client.d.ts +1 -1
  14. package/esm/5_client.js +1 -1
  15. package/esm/client/0_client_abstract.js +3 -2
  16. package/esm/client/0_html.js +4 -3
  17. package/esm/client/0_markdown.js +6 -5
  18. package/esm/client/0_params.d.ts +7 -1
  19. package/esm/client/0_types.d.ts +1 -2
  20. package/esm/client/0_types.js +1 -2
  21. package/esm/client/0_utilities.d.ts +0 -3
  22. package/esm/client/0_utilities.js +2 -21
  23. package/esm/client/1_business_connection_manager.d.ts +11 -0
  24. package/esm/client/1_business_connection_manager.js +47 -0
  25. package/esm/client/1_client_encrypted.js +1 -1
  26. package/esm/client/1_client_plain.js +3 -4
  27. package/esm/client/1_composer.js +3 -2
  28. package/esm/client/1_file_manager.js +4 -4
  29. package/esm/client/1_update_manager.d.ts +8 -1
  30. package/esm/client/1_update_manager.js +88 -8
  31. package/esm/client/2_message_manager.d.ts +7 -6
  32. package/esm/client/2_message_manager.js +89 -74
  33. package/esm/client/3_chat_list_manager.js +3 -2
  34. package/esm/client/3_story_manager.js +2 -1
  35. package/esm/client/4_client.d.ts +422 -421
  36. package/esm/client/4_client.js +578 -520
  37. package/esm/mod.d.ts +1 -0
  38. package/esm/mod.js +1 -0
  39. package/esm/storage/0_storage.d.ts +5 -0
  40. package/esm/storage/0_storage.js +20 -0
  41. package/esm/storage/{1_storage_indexed_db.js → 2_storage_indexed_db.js} +1 -1
  42. package/esm/storage/{1_storage_local_storage.js → 2_storage_local_storage.js} +1 -1
  43. package/{script/storage/1_storage_memory.d.ts → esm/storage/2_storage_memory.d.ts} +1 -4
  44. package/esm/storage/{1_storage_memory.js → 2_storage_memory.js} +8 -28
  45. package/esm/storage/{1_storage_session_storage.js → 2_storage_session_storage.js} +1 -1
  46. package/esm/tl/2_types.d.ts +1071 -183
  47. package/esm/tl/2_types.js +2916 -464
  48. package/esm/tl/3_functions.d.ts +381 -17
  49. package/esm/tl/3_functions.js +1002 -120
  50. package/{script/tl/4_tl_writer.d.ts → esm/tl/5_tl_writer.d.ts} +1 -1
  51. package/{script/tl/4_rpc_result.d.ts → esm/tl/6_rpc_result.d.ts} +1 -1
  52. package/esm/tl/{4_rpc_result.js → 6_rpc_result.js} +1 -1
  53. package/esm/tl/{6_message.d.ts → 7_message.d.ts} +2 -2
  54. package/esm/tl/{6_message.js → 7_message.js} +3 -3
  55. package/esm/tl/{7_message_container.d.ts → 8_message_container.d.ts} +1 -1
  56. package/esm/tl/{7_message_container.js → 8_message_container.js} +3 -3
  57. package/esm/types/0_chat_photo.d.ts +1 -0
  58. package/esm/types/0_chat_photo.js +8 -5
  59. package/esm/types/0_message_entity.d.ts +1 -1
  60. package/esm/types/0_thumbnail.js +1 -1
  61. package/esm/types/1_bot_command_scope.d.ts +1 -1
  62. package/esm/types/1_photo.js +2 -2
  63. package/esm/types/1_story_privacy.d.ts +1 -1
  64. package/esm/types/2_business_connection.d.ts +11 -0
  65. package/esm/types/2_business_connection.js +12 -0
  66. package/esm/types/2_chat_member.d.ts +1 -1
  67. package/esm/types/2_chosen_inline_result.d.ts +1 -1
  68. package/esm/types/2_game.js +1 -1
  69. package/esm/types/2_inline_keyboard_button.d.ts +1 -1
  70. package/esm/types/2_inline_query.d.ts +1 -1
  71. package/esm/types/2_invite_link.d.ts +1 -1
  72. package/esm/types/2_message_reaction_count.d.ts +1 -1
  73. package/esm/types/2_message_reactions.d.ts +1 -1
  74. package/esm/types/2_story_content.js +1 -1
  75. package/{script/types/1_story_interactive_area.d.ts → esm/types/2_story_interactive_area.d.ts} +2 -2
  76. package/esm/types/{1_story_interactive_area.js → 2_story_interactive_area.js} +1 -1
  77. package/esm/types/3_chat_member_updated.d.ts +1 -1
  78. package/esm/types/3_reply_markup.d.ts +1 -1
  79. package/esm/types/3_story.d.ts +2 -2
  80. package/esm/types/3_story.js +1 -1
  81. package/esm/types/4_inline_query_result.d.ts +1 -1
  82. package/esm/types/4_inline_query_result.js +1 -1
  83. package/esm/types/4_message.d.ts +9 -3
  84. package/esm/types/4_message.js +22 -5
  85. package/esm/types/5_callback_query.d.ts +1 -1
  86. package/esm/types/5_callback_query.js +2 -1
  87. package/esm/types/5_chat.d.ts +1 -1
  88. package/esm/types/6_update.d.ts +12 -2
  89. package/esm/types/{0__file_id.js → _file_id.js} +2 -1
  90. package/package.json +1 -1
  91. package/script/0_errors.d.ts +12 -0
  92. package/script/0_errors.js +27 -0
  93. package/script/1_utilities.d.ts +1 -1
  94. package/script/1_utilities.js +1 -1
  95. package/script/2_tl.d.ts +6 -6
  96. package/script/2_tl.js +6 -6
  97. package/script/3_storage.d.ts +5 -5
  98. package/script/3_storage.js +5 -5
  99. package/script/3_types.d.ts +6 -5
  100. package/script/3_types.js +6 -5
  101. package/script/4_constants.d.ts +2 -2
  102. package/script/4_constants.js +2 -2
  103. package/script/5_client.d.ts +1 -1
  104. package/script/5_client.js +1 -1
  105. package/script/client/0_client_abstract.js +3 -2
  106. package/script/client/0_html.js +4 -3
  107. package/script/client/0_markdown.js +6 -5
  108. package/script/client/0_params.d.ts +7 -1
  109. package/script/client/0_types.d.ts +1 -2
  110. package/script/client/0_types.js +0 -4
  111. package/script/client/0_utilities.d.ts +0 -3
  112. package/script/client/0_utilities.js +3 -24
  113. package/script/client/1_business_connection_manager.d.ts +11 -0
  114. package/script/client/1_business_connection_manager.js +51 -0
  115. package/script/client/1_client_encrypted.js +2 -2
  116. package/script/client/1_client_plain.js +3 -4
  117. package/script/client/1_composer.js +3 -2
  118. package/script/client/1_file_manager.js +5 -5
  119. package/script/client/1_update_manager.d.ts +8 -1
  120. package/script/client/1_update_manager.js +88 -8
  121. package/script/client/2_message_manager.d.ts +7 -6
  122. package/script/client/2_message_manager.js +88 -73
  123. package/script/client/3_chat_list_manager.js +3 -2
  124. package/script/client/3_story_manager.js +2 -1
  125. package/script/client/4_client.d.ts +422 -421
  126. package/script/client/4_client.js +578 -520
  127. package/script/mod.d.ts +1 -0
  128. package/script/mod.js +1 -0
  129. package/script/storage/0_storage.d.ts +5 -0
  130. package/script/storage/0_storage.js +20 -0
  131. package/script/storage/{1_storage_indexed_db.js → 2_storage_indexed_db.js} +7 -7
  132. package/script/storage/{1_storage_local_storage.js → 2_storage_local_storage.js} +10 -10
  133. package/{esm/storage/1_storage_memory.d.ts → script/storage/2_storage_memory.d.ts} +1 -4
  134. package/script/storage/{1_storage_memory.js → 2_storage_memory.js} +12 -32
  135. package/script/storage/{1_storage_session_storage.js → 2_storage_session_storage.js} +10 -10
  136. package/script/tl/2_types.d.ts +1071 -183
  137. package/script/tl/2_types.js +3028 -504
  138. package/script/tl/3_functions.d.ts +381 -17
  139. package/script/tl/3_functions.js +1047 -143
  140. package/{esm/tl/4_tl_writer.d.ts → script/tl/5_tl_writer.d.ts} +1 -1
  141. package/{esm/tl/4_rpc_result.d.ts → script/tl/6_rpc_result.d.ts} +1 -1
  142. package/script/tl/{4_rpc_result.js → 6_rpc_result.js} +2 -2
  143. package/script/tl/{6_message.d.ts → 7_message.d.ts} +2 -2
  144. package/script/tl/{6_message.js → 7_message.js} +8 -8
  145. package/script/tl/{7_message_container.d.ts → 8_message_container.d.ts} +1 -1
  146. package/script/tl/{7_message_container.js → 8_message_container.js} +7 -7
  147. package/script/types/0_chat_photo.d.ts +1 -0
  148. package/script/types/0_chat_photo.js +16 -13
  149. package/script/types/0_message_entity.d.ts +1 -1
  150. package/script/types/0_thumbnail.js +6 -6
  151. package/script/types/1_bot_command_scope.d.ts +1 -1
  152. package/script/types/1_photo.js +7 -7
  153. package/script/types/1_story_privacy.d.ts +1 -1
  154. package/script/types/2_business_connection.d.ts +11 -0
  155. package/script/types/2_business_connection.js +16 -0
  156. package/script/types/2_chat_member.d.ts +1 -1
  157. package/script/types/2_chosen_inline_result.d.ts +1 -1
  158. package/script/types/2_game.js +3 -3
  159. package/script/types/2_inline_keyboard_button.d.ts +1 -1
  160. package/script/types/2_inline_query.d.ts +1 -1
  161. package/script/types/2_invite_link.d.ts +1 -1
  162. package/script/types/2_message_reaction_count.d.ts +1 -1
  163. package/script/types/2_message_reactions.d.ts +1 -1
  164. package/script/types/2_story_content.js +4 -4
  165. package/{esm/types/1_story_interactive_area.d.ts → script/types/2_story_interactive_area.d.ts} +2 -2
  166. package/script/types/{1_story_interactive_area.js → 2_story_interactive_area.js} +2 -2
  167. package/script/types/3_chat_member_updated.d.ts +1 -1
  168. package/script/types/3_reply_markup.d.ts +1 -1
  169. package/script/types/3_story.d.ts +2 -2
  170. package/script/types/3_story.js +2 -2
  171. package/script/types/4_inline_query_result.d.ts +1 -1
  172. package/script/types/4_inline_query_result.js +2 -2
  173. package/script/types/4_message.d.ts +9 -3
  174. package/script/types/4_message.js +37 -20
  175. package/script/types/5_callback_query.d.ts +1 -1
  176. package/script/types/5_callback_query.js +2 -1
  177. package/script/types/5_chat.d.ts +1 -1
  178. package/script/types/6_update.d.ts +12 -2
  179. package/script/types/{0__file_id.js → _file_id.js} +2 -1
  180. /package/esm/storage/{0_utilities.d.ts → 1_utilities.d.ts} +0 -0
  181. /package/esm/storage/{0_utilities.js → 1_utilities.js} +0 -0
  182. /package/esm/storage/{1_storage_indexed_db.d.ts → 2_storage_indexed_db.d.ts} +0 -0
  183. /package/esm/storage/{1_storage_local_storage.d.ts → 2_storage_local_storage.d.ts} +0 -0
  184. /package/esm/storage/{1_storage_session_storage.d.ts → 2_storage_session_storage.d.ts} +0 -0
  185. /package/esm/tl/{3_tl_reader.d.ts → 4_tl_reader.d.ts} +0 -0
  186. /package/esm/tl/{3_tl_reader.js → 4_tl_reader.js} +0 -0
  187. /package/esm/tl/{4_tl_writer.js → 5_tl_writer.js} +0 -0
  188. /package/esm/types/{0_venue.d.ts → 1_venue.d.ts} +0 -0
  189. /package/esm/types/{0_venue.js → 1_venue.js} +0 -0
  190. /package/esm/types/{0__file_id.d.ts → _file_id.d.ts} +0 -0
  191. /package/esm/types/{1__getters.d.ts → _getters.d.ts} +0 -0
  192. /package/esm/types/{1__getters.js → _getters.js} +0 -0
  193. /package/script/storage/{0_utilities.d.ts → 1_utilities.d.ts} +0 -0
  194. /package/script/storage/{0_utilities.js → 1_utilities.js} +0 -0
  195. /package/script/storage/{1_storage_indexed_db.d.ts → 2_storage_indexed_db.d.ts} +0 -0
  196. /package/script/storage/{1_storage_local_storage.d.ts → 2_storage_local_storage.d.ts} +0 -0
  197. /package/script/storage/{1_storage_session_storage.d.ts → 2_storage_session_storage.d.ts} +0 -0
  198. /package/script/tl/{3_tl_reader.d.ts → 4_tl_reader.d.ts} +0 -0
  199. /package/script/tl/{3_tl_reader.js → 4_tl_reader.js} +0 -0
  200. /package/script/tl/{4_tl_writer.js → 5_tl_writer.js} +0 -0
  201. /package/script/types/{0_venue.d.ts → 1_venue.d.ts} +0 -0
  202. /package/script/types/{0_venue.js → 1_venue.js} +0 -0
  203. /package/script/types/{0__file_id.d.ts → _file_id.d.ts} +0 -0
  204. /package/script/types/{1__getters.d.ts → _getters.d.ts} +0 -0
  205. /package/script/types/{1__getters.js → _getters.js} +0 -0
@@ -9,7 +9,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _Client_instances, _Client_client, _Client_guaranteeUpdateDelivery, _Client_updateManager, _Client_networkStatisticsManager, _Client_botInfoManager, _Client_fileManager, _Client_reactionManager, _Client_messageManager, _Client_storyManager, _Client_callbackQueryManager, _Client_inlineQueryManager, _Client_chatListManager, _Client_accountManager, _Client_parseMode, _Client_publicKeys, _Client_ignoreOutgoing, _Client_storeMessages, _Client_Lauthorize, _Client_LpingLoop, _Client_LhandleMigrationError, _Client_L$initConncetion, _Client_namespaceProxies, _Client_getApiId, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_stateChangeHandler, _Client_storageInited, _Client_initStorage, _Client_connectionInited, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_getSelfId, _Client_pingLoopStarted, _Client_pingLoopAbortController, _Client_pingInterval, _Client_lastUpdates, _Client_startPingLoop, _Client_pingLoop, _Client_invoke, _Client_handleInvokeError, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe;
12
+ var _Client_instances, _Client_client, _Client_guaranteeUpdateDelivery, _Client_updateManager, _Client_networkStatisticsManager, _Client_botInfoManager, _Client_fileManager, _Client_reactionManager, _Client_businessConnectionManager, _Client_messageManager, _Client_storyManager, _Client_callbackQueryManager, _Client_inlineQueryManager, _Client_chatListManager, _Client_accountManager, _Client_parseMode, _Client_publicKeys, _Client_ignoreOutgoing, _Client_storeMessages, _Client_Lauthorize, _Client_LpingLoop, _Client_LhandleMigrationError, _Client_L$initConncetion, _Client_namespaceProxies, _Client_getApiId, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_stateChangeHandler, _Client_storageInited, _Client_initStorage, _Client_connectionInited, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_getSelfId, _Client_pingLoopStarted, _Client_pingLoopAbortController, _Client_pingInterval, _Client_lastUpdates, _Client_startPingLoop, _Client_pingLoop, _Client_invoke, _Client_handleInvokeError, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe;
13
+ import { AccessError, InputError } from "../0_errors.js";
13
14
  import { cleanObject, drop, getLogger, getRandomId, mustPrompt, mustPromptOneOf, UNREACHABLE, ZERO_CHANNEL_ID } from "../1_utilities.js";
14
15
  import { as, chatIdToPeerId, functions, getChatIdPeerType, name, peerToChatId, types } from "../2_tl.js";
15
16
  import { StorageMemory } from "../3_storage.js";
@@ -20,6 +21,7 @@ import { checkPassword } from "./0_password.js";
20
21
  import { getUsername, resolve } from "./0_utilities.js";
21
22
  import { AccountManager } from "./1_account_manager.js";
22
23
  import { BotInfoManager } from "./1_bot_info_manager.js";
24
+ import { BusinessConnectionManager } from "./1_business_connection_manager.js";
23
25
  import { ClientEncrypted } from "./1_client_encrypted.js";
24
26
  import { ClientPlain } from "./1_client_plain.js";
25
27
  import { Composer as Composer_ } from "./1_composer.js";
@@ -76,6 +78,7 @@ export class Client extends Composer {
76
78
  _Client_botInfoManager.set(this, void 0);
77
79
  _Client_fileManager.set(this, void 0);
78
80
  _Client_reactionManager.set(this, void 0);
81
+ _Client_businessConnectionManager.set(this, void 0);
79
82
  _Client_messageManager.set(this, void 0);
80
83
  _Client_storyManager.set(this, void 0);
81
84
  _Client_callbackQueryManager.set(this, void 0);
@@ -199,7 +202,7 @@ export class Client extends Composer {
199
202
  const reactions = "messageInteractions" in update ? update.messageInteractions : undefined;
200
203
  const mustGetMsg = () => {
201
204
  if (msg !== undefined) {
202
- return { chatId: msg.chat.id, messageId: msg.id, senderId: (msg.from ?? msg.senderChat)?.id };
205
+ return { chatId: msg.chat.id, messageId: msg.id, businessConnectionId: msg.businessConnectionId, senderId: (msg.from ?? msg.senderChat)?.id };
203
206
  }
204
207
  else if (reactions !== undefined) {
205
208
  return { chatId: reactions.chatId, messageId: reactions.messageId };
@@ -258,74 +261,74 @@ export class Client extends Composer {
258
261
  return () => update;
259
262
  },
260
263
  reply: (text, params) => {
261
- const { chatId, messageId } = mustGetMsg();
264
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
262
265
  const replyToMessageId = getReplyToMessageId(params?.quote, chatId, messageId);
263
- return this.sendMessage(chatId, text, { ...params, replyToMessageId });
266
+ return this.sendMessage(chatId, text, { ...params, replyToMessageId, businessConnectionId });
264
267
  },
265
268
  replyPoll: (question, options, params) => {
266
- const { chatId, messageId } = mustGetMsg();
269
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
267
270
  const replyToMessageId = getReplyToMessageId(params?.quote, chatId, messageId);
268
- return this.sendPoll(chatId, question, options, { ...params, replyToMessageId });
271
+ return this.sendPoll(chatId, question, options, { ...params, replyToMessageId, businessConnectionId });
269
272
  },
270
273
  replyPhoto: (photo, params) => {
271
- const { chatId, messageId } = mustGetMsg();
274
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
272
275
  const replyToMessageId = getReplyToMessageId(params?.quote, chatId, messageId);
273
- return this.sendPhoto(chatId, photo, { ...params, replyToMessageId });
276
+ return this.sendPhoto(chatId, photo, { ...params, replyToMessageId, businessConnectionId });
274
277
  },
275
278
  replyDocument: (document, params) => {
276
- const { chatId, messageId } = mustGetMsg();
279
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
277
280
  const replyToMessageId = getReplyToMessageId(params?.quote, chatId, messageId);
278
- return this.sendDocument(chatId, document, { ...params, replyToMessageId });
281
+ return this.sendDocument(chatId, document, { ...params, replyToMessageId, businessConnectionId });
279
282
  },
280
283
  replySticker: (sticker, params) => {
281
- const { chatId, messageId } = mustGetMsg();
284
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
282
285
  const replyToMessageId = getReplyToMessageId(params?.quote, chatId, messageId);
283
- return this.sendSticker(chatId, sticker, { ...params, replyToMessageId });
286
+ return this.sendSticker(chatId, sticker, { ...params, replyToMessageId, businessConnectionId });
284
287
  },
285
288
  replyContact: (firstName, number, params) => {
286
- const { chatId, messageId } = mustGetMsg();
289
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
287
290
  const replyToMessageId = getReplyToMessageId(params?.quote, chatId, messageId);
288
- return this.sendContact(chatId, firstName, number, { ...params, replyToMessageId });
291
+ return this.sendContact(chatId, firstName, number, { ...params, replyToMessageId, businessConnectionId });
289
292
  },
290
293
  replyLocation: (latitude, longitude, params) => {
291
- const { chatId, messageId } = mustGetMsg();
294
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
292
295
  const replyToMessageId = getReplyToMessageId(params?.quote, chatId, messageId);
293
- return this.sendLocation(chatId, latitude, longitude, { ...params, replyToMessageId });
296
+ return this.sendLocation(chatId, latitude, longitude, { ...params, replyToMessageId, businessConnectionId });
294
297
  },
295
298
  replyDice: (params) => {
296
- const { chatId, messageId } = mustGetMsg();
299
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
297
300
  const replyToMessageId = getReplyToMessageId(params?.quote, chatId, messageId);
298
- return this.sendDice(chatId, { ...params, replyToMessageId });
301
+ return this.sendDice(chatId, { ...params, replyToMessageId, businessConnectionId });
299
302
  },
300
303
  replyVenue: (latitude, longitude, title, address, params) => {
301
- const { chatId, messageId } = mustGetMsg();
304
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
302
305
  const replyToMessageId = getReplyToMessageId(params?.quote, chatId, messageId);
303
- return this.sendVenue(chatId, latitude, longitude, title, address, { ...params, replyToMessageId });
306
+ return this.sendVenue(chatId, latitude, longitude, title, address, { ...params, replyToMessageId, businessConnectionId });
304
307
  },
305
308
  replyVideo: (video, params) => {
306
- const { chatId, messageId } = mustGetMsg();
309
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
307
310
  const replyToMessageId = getReplyToMessageId(params?.quote, chatId, messageId);
308
- return this.sendVideo(chatId, video, { ...params, replyToMessageId });
311
+ return this.sendVideo(chatId, video, { ...params, replyToMessageId, businessConnectionId });
309
312
  },
310
313
  replyAnimation: (document, params) => {
311
- const { chatId, messageId } = mustGetMsg();
314
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
312
315
  const replyToMessageId = getReplyToMessageId(params?.quote, chatId, messageId);
313
- return this.sendAnimation(chatId, document, { ...params, replyToMessageId });
316
+ return this.sendAnimation(chatId, document, { ...params, replyToMessageId, businessConnectionId });
314
317
  },
315
318
  replyVoice: (document, params) => {
316
- const { chatId, messageId } = mustGetMsg();
319
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
317
320
  const replyToMessageId = getReplyToMessageId(params?.quote, chatId, messageId);
318
- return this.sendVoice(chatId, document, { ...params, replyToMessageId });
321
+ return this.sendVoice(chatId, document, { ...params, replyToMessageId, businessConnectionId });
319
322
  },
320
323
  replyAudio: (document, params) => {
321
- const { chatId, messageId } = mustGetMsg();
324
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
322
325
  const replyToMessageId = getReplyToMessageId(params?.quote, chatId, messageId);
323
- return this.sendAudio(chatId, document, { ...params, replyToMessageId });
326
+ return this.sendAudio(chatId, document, { ...params, replyToMessageId, businessConnectionId });
324
327
  },
325
328
  replyVideoNote: (videoNote, params) => {
326
- const { chatId, messageId } = mustGetMsg();
329
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
327
330
  const replyToMessageId = getReplyToMessageId(params?.quote, chatId, messageId);
328
- return this.sendVideoNote(chatId, videoNote, { ...params, replyToMessageId });
331
+ return this.sendVideoNote(chatId, videoNote, { ...params, replyToMessageId, businessConnectionId });
329
332
  },
330
333
  delete: () => {
331
334
  const { chatId, messageId } = mustGetMsg();
@@ -530,6 +533,13 @@ export class Client extends Composer {
530
533
  const { chatId } = mustGetMsg();
531
534
  return this.deleteChatStickerSet(chatId);
532
535
  },
536
+ getBusinessConnection: () => {
537
+ const { businessConnectionId } = mustGetMsg();
538
+ if (!businessConnectionId) {
539
+ UNREACHABLE();
540
+ }
541
+ return this.getBusinessConnection(businessConnectionId);
542
+ },
533
543
  };
534
544
  return cleanObject(context);
535
545
  });
@@ -635,6 +645,14 @@ export class Client extends Composer {
635
645
  const c = {
636
646
  id,
637
647
  api: this.api,
648
+ invoke: async (function_, businessConnectionId) => {
649
+ if (businessConnectionId) {
650
+ return await this.api.invokeWithBusinessConnection({ connection_id: businessConnectionId, query: function_ });
651
+ }
652
+ else {
653
+ return await this.invoke(function_);
654
+ }
655
+ },
638
656
  storage: this.storage,
639
657
  messageStorage: this.messageStorage,
640
658
  guaranteeUpdateDelivery: __classPrivateFieldGet(this, _Client_guaranteeUpdateDelivery, "f"),
@@ -664,6 +682,7 @@ export class Client extends Composer {
664
682
  try {
665
683
  const exportedAuth = await this.api.auth.exportAuthorization({ dc_id: dcId });
666
684
  await client.authorize(exportedAuth);
685
+ // throw 1;
667
686
  return true;
668
687
  }
669
688
  catch (err) {
@@ -698,6 +717,7 @@ export class Client extends Composer {
698
717
  __classPrivateFieldSet(this, _Client_botInfoManager, new BotInfoManager(c), "f");
699
718
  __classPrivateFieldSet(this, _Client_fileManager, new FileManager(c), "f");
700
719
  __classPrivateFieldSet(this, _Client_reactionManager, new ReactionManager(c), "f");
720
+ __classPrivateFieldSet(this, _Client_businessConnectionManager, new BusinessConnectionManager(c), "f");
701
721
  __classPrivateFieldSet(this, _Client_messageManager, new MessageManager({ ...c, fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f") }), "f");
702
722
  __classPrivateFieldSet(this, _Client_callbackQueryManager, new CallbackQueryManager({ ...c, messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
703
723
  __classPrivateFieldSet(this, _Client_storyManager, new StoryManager({ ...c, fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f"), messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
@@ -806,9 +826,13 @@ export class Client extends Composer {
806
826
  await Promise.all([this.storage.setAuthKey(__classPrivateFieldGet(this, _Client_client, "f").authKey), this.storage.setDc(__classPrivateFieldGet(this, _Client_client, "f").dc), this.storage.setServerSalt(__classPrivateFieldGet(this, _Client_client, "f").serverSalt)]);
807
827
  }
808
828
  async reconnect(dc) {
809
- await __classPrivateFieldGet(this, _Client_client, "f").reconnect(dc);
829
+ await this.disconnect();
830
+ if (dc) {
831
+ await this.setDc(dc);
832
+ }
833
+ await this.connect();
810
834
  }
811
- async [(_Client_client = new WeakMap(), _Client_guaranteeUpdateDelivery = new WeakMap(), _Client_updateManager = new WeakMap(), _Client_networkStatisticsManager = new WeakMap(), _Client_botInfoManager = new WeakMap(), _Client_fileManager = new WeakMap(), _Client_reactionManager = new WeakMap(), _Client_messageManager = new WeakMap(), _Client_storyManager = new WeakMap(), _Client_callbackQueryManager = new WeakMap(), _Client_inlineQueryManager = new WeakMap(), _Client_chatListManager = new WeakMap(), _Client_accountManager = new WeakMap(), _Client_parseMode = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_storeMessages = new WeakMap(), _Client_Lauthorize = new WeakMap(), _Client_LpingLoop = new WeakMap(), _Client_LhandleMigrationError = new WeakMap(), _Client_L$initConncetion = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_stateChangeHandler = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_pingLoopAbortController = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_instances = new WeakSet(), _Client_getApiId = async function _Client_getApiId() {
835
+ async [(_Client_client = new WeakMap(), _Client_guaranteeUpdateDelivery = new WeakMap(), _Client_updateManager = new WeakMap(), _Client_networkStatisticsManager = new WeakMap(), _Client_botInfoManager = new WeakMap(), _Client_fileManager = new WeakMap(), _Client_reactionManager = new WeakMap(), _Client_businessConnectionManager = new WeakMap(), _Client_messageManager = new WeakMap(), _Client_storyManager = new WeakMap(), _Client_callbackQueryManager = new WeakMap(), _Client_inlineQueryManager = new WeakMap(), _Client_chatListManager = new WeakMap(), _Client_accountManager = new WeakMap(), _Client_parseMode = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_storeMessages = new WeakMap(), _Client_Lauthorize = new WeakMap(), _Client_LpingLoop = new WeakMap(), _Client_LhandleMigrationError = new WeakMap(), _Client_L$initConncetion = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_stateChangeHandler = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_pingLoopAbortController = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_instances = new WeakSet(), _Client_getApiId = async function _Client_getApiId() {
812
836
  const apiId = this.apiId || await this.storage.getApiId();
813
837
  if (!apiId) {
814
838
  throw new Error("apiId not set");
@@ -1050,6 +1074,9 @@ export class Client extends Composer {
1050
1074
  inputPeer.access_hash = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getUserAccessHash).call(this, inputPeer.user_id);
1051
1075
  }
1052
1076
  }
1077
+ else {
1078
+ throw new AccessError(`Cannot access the chat ${id} because there is no access hash for it.`);
1079
+ }
1053
1080
  return inputPeer;
1054
1081
  }
1055
1082
  /**
@@ -1060,7 +1087,7 @@ export class Client extends Composer {
1060
1087
  async getInputChannel(id) {
1061
1088
  const inputPeer = await this.getInputPeer(id);
1062
1089
  if (!(inputPeer instanceof types.InputPeerChannel)) {
1063
- UNREACHABLE();
1090
+ throw new TypeError(`The chat ${id} is not a channel neither a supergroup.`);
1064
1091
  }
1065
1092
  return new types.InputChannel(inputPeer);
1066
1093
  }
@@ -1072,7 +1099,7 @@ export class Client extends Composer {
1072
1099
  async getInputUser(id) {
1073
1100
  const inputPeer = await this.getInputPeer(id);
1074
1101
  if (!(inputPeer instanceof types.InputPeerUser)) {
1075
- UNREACHABLE();
1102
+ throw new TypeError(`The chat ${id} is not a private chat.`);
1076
1103
  }
1077
1104
  return new types.InputUser(inputPeer);
1078
1105
  }
@@ -1227,7 +1254,7 @@ export class Client extends Composer {
1227
1254
  return new types.InputPeerChannel({ channel_id: chatIdToPeerId(id), access_hash: accessHash ?? 0n });
1228
1255
  }
1229
1256
  else {
1230
- throw new Error("ID format unknown or not implemented");
1257
+ throw new InputError("The ID is of an format unknown.");
1231
1258
  }
1232
1259
  }, getEntity)](peer) {
1233
1260
  const id = peerToChatId(peer);
@@ -1240,6 +1267,77 @@ export class Client extends Composer {
1240
1267
  }
1241
1268
  return await this.messageStorage.getEntity(id);
1242
1269
  }
1270
+ //
1271
+ // ========================= ACCOUNT ========================= //
1272
+ //
1273
+ /**
1274
+ * Get information on the currently authorized user.
1275
+ *
1276
+ * @method ac
1277
+ */
1278
+ async getMe() {
1279
+ let user_ = await this[getEntity](new types.PeerUser({ user_id: BigInt(await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).call(this)) }));
1280
+ if (user_ == null) {
1281
+ const users = await this.api.users.getUsers({ id: [new types.InputUserSelf()] });
1282
+ user_ = users[0][as](types.User);
1283
+ await this.messageStorage.setEntity(user_);
1284
+ }
1285
+ const user = constructUser(user_);
1286
+ __classPrivateFieldSet(this, _Client_lastGetMe, user, "f");
1287
+ return user;
1288
+ }
1289
+ /**
1290
+ * Show a username in the current account, a bot account, a supergroup, or a channel's profile. User-only.
1291
+ *
1292
+ * @method ac
1293
+ * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
1294
+ * @param username The username to show.
1295
+ */
1296
+ async showUsername(id, username) {
1297
+ await __classPrivateFieldGet(this, _Client_accountManager, "f").showUsername(id, username);
1298
+ }
1299
+ /**
1300
+ * Hide a username from the current account, a bot account, a supergroup, or a channel's profile. User-only.
1301
+ *
1302
+ * @method ac
1303
+ * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
1304
+ * @param username The username to hide.
1305
+ */
1306
+ async hideUsername(id, username) {
1307
+ await __classPrivateFieldGet(this, _Client_accountManager, "f").hideUsername(id, username);
1308
+ }
1309
+ /**
1310
+ * Reorder the usernames of the current account, a bot account, a supergroup, or a channel's profile. User-only.
1311
+ *
1312
+ * @method ac
1313
+ * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
1314
+ * @param order The new order to use.
1315
+ * @returns Whether the order was changed.
1316
+ */
1317
+ async reorderUsernames(id, order) {
1318
+ return await __classPrivateFieldGet(this, _Client_accountManager, "f").reorderUsernames(id, order);
1319
+ }
1320
+ /**
1321
+ * Hide all usernames from the a supergroup or a channel's profile. User-only.
1322
+ *
1323
+ * @method ac
1324
+ * @param id A supergroup ID or a channel ID.
1325
+ */
1326
+ async hideUsernames(id) {
1327
+ return await __classPrivateFieldGet(this, _Client_accountManager, "f").hideUsernames(id);
1328
+ }
1329
+ /**
1330
+ * Get a business connection. Bot-only.
1331
+ *
1332
+ * @method ac
1333
+ * @param id The identifier of the business connection.
1334
+ */
1335
+ async getBusinessConnection(id) {
1336
+ return await __classPrivateFieldGet(this, _Client_businessConnectionManager, "f").getBusinessConnection(id);
1337
+ }
1338
+ //
1339
+ // ========================= MESSAGES ========================= //
1340
+ //
1243
1341
  /**
1244
1342
  * Send a text message.
1245
1343
  *
@@ -1251,6 +1349,154 @@ export class Client extends Composer {
1251
1349
  async sendMessage(chatId, text, params) {
1252
1350
  return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendMessage(chatId, text, params);
1253
1351
  }
1352
+ /**
1353
+ * Send a photo.
1354
+ *
1355
+ * @method ms
1356
+ * @param chatId The chat to send the photo to.
1357
+ * @param photo The photo to send.
1358
+ * @returns The sent photo.
1359
+ */
1360
+ async sendPhoto(chatId, photo, params) {
1361
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendPhoto(chatId, photo, params);
1362
+ }
1363
+ /**
1364
+ * Send a document.
1365
+ *
1366
+ * @method ms
1367
+ * @param chatId The chat to send the document to.
1368
+ * @param document The document to send.
1369
+ * @returns The sent document.
1370
+ */
1371
+ async sendDocument(chatId, document, params) {
1372
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendDocument(chatId, document, params);
1373
+ }
1374
+ /**
1375
+ * Send a sticker.
1376
+ *
1377
+ * @method ms
1378
+ * @param chatId The chat to send the sticker to.
1379
+ * @param document The sticker to send.
1380
+ * @returns The sent sticker.
1381
+ */
1382
+ async sendSticker(chatId, sticker, params) {
1383
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendSticker(chatId, sticker, params);
1384
+ }
1385
+ /**
1386
+ * Send a video.
1387
+ *
1388
+ * @method ms
1389
+ * @param chatId The chat to send the video to.
1390
+ * @param video The video to send.
1391
+ * @returns The sent video.
1392
+ */
1393
+ async sendVideo(chatId, video, params) {
1394
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendVideo(chatId, video, params);
1395
+ }
1396
+ /**
1397
+ * Send an animation.
1398
+ *
1399
+ * @method ms
1400
+ * @param chatId The chat to send the animation to.
1401
+ * @param animation The animation to send.
1402
+ * @returns The sent animation.
1403
+ */
1404
+ async sendAnimation(chatId, animation, params) {
1405
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendAnimation(chatId, animation, params);
1406
+ }
1407
+ /**
1408
+ * Send a voice message.
1409
+ *
1410
+ * @method ms
1411
+ * @param chatId The chat to send the voice message to.
1412
+ * @param voice The voice to send.
1413
+ * @returns The sent voice message.
1414
+ */
1415
+ async sendVoice(chatId, voice, params) {
1416
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendVoice(chatId, voice, params);
1417
+ }
1418
+ /**
1419
+ * Send an audio file.
1420
+ *
1421
+ * @method ms
1422
+ * @param chatId The chat to send the audio file to.
1423
+ * @param audio The audio to send.
1424
+ * @returns The sent audio filr.
1425
+ */
1426
+ async sendAudio(chatId, audio, params) {
1427
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendAudio(chatId, audio, params);
1428
+ }
1429
+ /**
1430
+ * Send a video note.
1431
+ *
1432
+ * @method ms
1433
+ * @param chatId The chat to send the video note to.
1434
+ * @param videoNote The video note to send.
1435
+ * @returns The sent video note.
1436
+ */
1437
+ async sendVideoNote(chatId, videoNote, params) {
1438
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendVideoNote(chatId, videoNote, params);
1439
+ }
1440
+ /**
1441
+ * Send a location.
1442
+ *
1443
+ * @method ms
1444
+ * @param chatId The chat to send the location to.
1445
+ * @param latitude The location's latitude.
1446
+ * @param longitude The location's longitude.
1447
+ * @returns The sent location.
1448
+ */
1449
+ async sendLocation(chatId, latitude, longitude, params) {
1450
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendLocation(chatId, latitude, longitude, params);
1451
+ }
1452
+ /**
1453
+ * Send a contact.
1454
+ *
1455
+ * @method ms
1456
+ * @param chatId The chat to send the contact to.
1457
+ * @param firstName The contact's first name.
1458
+ * @param number The contact's phone number.
1459
+ * @returns The sent contact.
1460
+ */
1461
+ async sendContact(chatId, firstName, number, params) {
1462
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendContact(chatId, firstName, number, params);
1463
+ }
1464
+ /**
1465
+ * Send a dice.
1466
+ *
1467
+ * @method ms
1468
+ * @param chatId The chat to send the dice to.
1469
+ * @returns The sent dice.
1470
+ */
1471
+ async sendDice(chatId, params) {
1472
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendDice(chatId, params);
1473
+ }
1474
+ /**
1475
+ * Send a venue.
1476
+ *
1477
+ * @method ms
1478
+ * @param chatId The chat to send the venue to.
1479
+ * @param latitude The latitude of the venue.
1480
+ * @param longitude The longitude of the venue.
1481
+ * @param title The title of the venue.
1482
+ * @param address The written address of the venue.
1483
+ * @returns The sent venue.
1484
+ */
1485
+ async sendVenue(chatId, latitude, longitude, title, address, params) {
1486
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendVenue(chatId, latitude, longitude, title, address, params);
1487
+ }
1488
+ /**
1489
+ * Send a poll.
1490
+ *
1491
+ * @method ms
1492
+ * @param chatId The chat to send the poll to.
1493
+ * @param question The poll's question.
1494
+ * @param options The poll's options.
1495
+ * @returns The sent poll.
1496
+ */
1497
+ async sendPoll(chatId, question, options, params) {
1498
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendPoll(chatId, question, options, params);
1499
+ }
1254
1500
  /**
1255
1501
  * Edit a message's text.
1256
1502
  *
@@ -1347,82 +1593,87 @@ export class Client extends Composer {
1347
1593
  return await __classPrivateFieldGet(this, _Client_messageManager, "f").getMessage(chatId, messageId);
1348
1594
  }
1349
1595
  /**
1350
- * Download a file.
1596
+ * Delete multiple messages.
1351
1597
  *
1352
- * @method fs
1353
- * @param fileId The identifier of the file to download.
1354
- * @example ```ts
1355
- * for await (const chunk of client.download(fileId, { chunkSize: 256 * 1024 })) {
1356
- * await outFile.write(chunk);
1357
- * }
1358
- * ```
1359
- * @returns A generator yielding the contents of the file.
1598
+ * @method ms
1599
+ * @param chatId The identifier of the chat that contains the messages.
1600
+ * @param messageIds The identifiers of the messages to delete.
1360
1601
  */
1361
- async *download(fileId, params) {
1362
- for await (const chunk of __classPrivateFieldGet(this, _Client_fileManager, "f").download(fileId, params)) {
1363
- yield chunk;
1364
- }
1602
+ async deleteMessages(chatId, messageIds, params) {
1603
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteMessages(chatId, messageIds, params);
1365
1604
  }
1366
1605
  /**
1367
- * Forward multiple messages.
1606
+ * Delete a single message.
1368
1607
  *
1369
1608
  * @method ms
1370
- * @param from The identifier of the chat to forward the messages from.
1371
- * @param to The identifier of the chat to forward the messages to.
1372
- * @param messageIds The identifiers of the messages to forward.
1373
- * @returns The forwarded messages.
1609
+ * @param chatId The identifier of the chat that contains the message.
1610
+ * @param messageId The identifier of the message to delete.
1374
1611
  */
1375
- async forwardMessages(from, to, messageIds, params) {
1376
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").forwardMessages(from, to, messageIds, params);
1612
+ async deleteMessage(chatId, messageId, params) {
1613
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteMessages(chatId, [messageId], params);
1377
1614
  }
1378
1615
  /**
1379
- * Forward a single message.
1616
+ * Delete all messages sent by a specific member of a chat. User-only.
1380
1617
  *
1381
1618
  * @method ms
1382
- * @param from The identifier of the chat to forward the message from.
1383
- * @param to The identifier of the chat to forward the message to.
1384
- * @param messageId The identifier of the message to forward.
1385
- * @returns The forwarded message.
1619
+ * @param chatId The identifier of the chat. Must be a supergroup.
1620
+ * @param memberId The identifier of the member.
1386
1621
  */
1387
- async forwardMessage(from, to, messageId, params) {
1388
- return await this.forwardMessages(from, to, [messageId], params).then((v) => v[0]);
1622
+ async deleteChatMemberMessages(chatId, memberId) {
1623
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteChatMemberMessages(chatId, memberId);
1389
1624
  }
1390
1625
  /**
1391
- * Get information on the currently authorized user.
1626
+ * Pin a message in a chat.
1392
1627
  *
1393
- * @method ac
1628
+ * @method ms
1629
+ * @param chatId The identifier of the chat that contains the message.
1630
+ * @param messageId The message's identifier.
1394
1631
  */
1395
- async getMe() {
1396
- let user_ = await this[getEntity](new types.PeerUser({ user_id: BigInt(await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).call(this)) }));
1397
- if (user_ == null) {
1398
- const users = await this.api.users.getUsers({ id: [new types.InputUserSelf()] });
1399
- user_ = users[0][as](types.User);
1400
- await this.messageStorage.setEntity(user_);
1401
- }
1402
- const user = constructUser(user_);
1403
- __classPrivateFieldSet(this, _Client_lastGetMe, user, "f");
1404
- return user;
1632
+ async pinMessage(chatId, messageId, params) {
1633
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").pinMessage(chatId, messageId, params);
1405
1634
  }
1406
1635
  /**
1407
- * Answer a callback query. Bot-only.
1636
+ * Unpin a pinned message.
1408
1637
  *
1409
- * @method cq
1410
- * @param id ID of the callback query to answer.
1638
+ * @method ms
1639
+ * @param chatId The identifier of the chat that contains the message.
1640
+ * @param messageId The message's identifier.
1411
1641
  */
1412
- async answerCallbackQuery(id, params) {
1413
- await __classPrivateFieldGet(this, _Client_callbackQueryManager, "f").answerCallbackQuery(id, params);
1642
+ async unpinMessage(chatId, messageId) {
1643
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").unpinMessage(chatId, messageId);
1414
1644
  }
1415
1645
  /**
1416
- * Send a poll.
1646
+ * Unpin all pinned messages.
1417
1647
  *
1418
1648
  * @method ms
1419
- * @param chatId The chat to send the poll to.
1420
- * @param question The poll's question.
1421
- * @param options The poll's options.
1422
- * @returns The sent poll.
1649
+ * @param chatId The identifier of the chat.
1423
1650
  */
1424
- async sendPoll(chatId, question, options, params) {
1425
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendPoll(chatId, question, options, params);
1651
+ async unpinMessages(chatId) {
1652
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").unpinMessages(chatId);
1653
+ }
1654
+ /**
1655
+ * Forward multiple messages.
1656
+ *
1657
+ * @method ms
1658
+ * @param from The identifier of the chat to forward the messages from.
1659
+ * @param to The identifier of the chat to forward the messages to.
1660
+ * @param messageIds The identifiers of the messages to forward.
1661
+ * @returns The forwarded messages.
1662
+ */
1663
+ async forwardMessages(from, to, messageIds, params) {
1664
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").forwardMessages(from, to, messageIds, params);
1665
+ }
1666
+ /**
1667
+ * Forward a single message.
1668
+ *
1669
+ * @method ms
1670
+ * @param from The identifier of the chat to forward the message from.
1671
+ * @param to The identifier of the chat to forward the message to.
1672
+ * @param messageId The identifier of the message to forward.
1673
+ * @returns The forwarded message.
1674
+ */
1675
+ async forwardMessage(from, to, messageId, params) {
1676
+ return await this.forwardMessages(from, to, [messageId], params).then((v) => v[0]);
1426
1677
  }
1427
1678
  /**
1428
1679
  * Stop a poll.
@@ -1447,446 +1698,393 @@ export class Client extends Composer {
1447
1698
  await __classPrivateFieldGet(this, _Client_messageManager, "f").sendChatAction(chatId, action, params);
1448
1699
  }
1449
1700
  /**
1450
- * Upload a file.
1451
- *
1452
- * @method fs
1453
- * @param contents The contents of the file.
1454
- * @returns The uploaded file.
1455
- */
1456
- // deno-lint-ignore no-explicit-any
1457
- async upload(contents, params) {
1458
- return await __classPrivateFieldGet(this, _Client_fileManager, "f").upload(contents, params);
1459
- }
1460
- /**
1461
- * Set the bot's commands in the given scope and/or language. Bot-only.
1462
- *
1463
- * @method bs
1464
- * @param commands The commands to set.
1465
- */
1466
- async setMyCommands(commands, params) {
1467
- await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyCommands(commands, params);
1468
- }
1469
- /**
1470
- * Get the bot's commands in the given scope and/or language. Bot-only.
1471
- *
1472
- * @method bs
1473
- * @returns The current bot's commands in the specified language.
1474
- */
1475
- async getMyCommands(params) {
1476
- return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyCommands(params);
1477
- }
1478
- /**
1479
- * Answer an inline query. Bot-only.
1480
- *
1481
- * @method iq
1482
- * @param id The ID of the inline query to answer.
1483
- * @param results The results to answer with.
1484
- */
1485
- async answerInlineQuery(id, results, params) {
1486
- await __classPrivateFieldGet(this, _Client_inlineQueryManager, "f").answerInlineQuery(id, results, params);
1487
- }
1488
- /**
1489
- * Set the bot's description in the given language. Bot-only.
1490
- *
1491
- * @method bs
1492
- */
1493
- async setMyDescription(params) {
1494
- await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyDescription(params);
1495
- }
1496
- /**
1497
- * Set the bot's name in the given language. Bot-only.
1498
- *
1499
- * @method bs
1500
- */
1501
- async setMyName(params) {
1502
- await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyName(params);
1503
- }
1504
- /**
1505
- * Set the bot's short description in the given language. Bot-only.
1701
+ * Search the messages of a chat. User-only.
1506
1702
  *
1507
- * @method bs
1703
+ * @method ms
1704
+ * @param chatId The identifier of the chat to search the messages in.
1705
+ * @param query The message search query.
1508
1706
  */
1509
- async setMyShortDescription(params) {
1510
- await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyShortDescription(params);
1707
+ async searchMessages(chatId, query, params) {
1708
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").searchMessages(chatId, query, params);
1511
1709
  }
1710
+ //
1711
+ // ========================= FILES ========================= //
1712
+ //
1512
1713
  /**
1513
- * Get the bot's description in the given language. Bot-only.
1714
+ * Download a file.
1514
1715
  *
1515
- * @method bs
1516
- * @returns The current bot's description in the specified language.
1716
+ * @method fs
1717
+ * @param fileId The identifier of the file to download.
1718
+ * @example ```ts
1719
+ * for await (const chunk of client.download(fileId, { chunkSize: 256 * 1024 })) {
1720
+ * await outFile.write(chunk);
1721
+ * }
1722
+ * ```
1723
+ * @returns A generator yielding the contents of the file.
1517
1724
  */
1518
- async getMyDescription(params) {
1519
- return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyDescription(params);
1725
+ async *download(fileId, params) {
1726
+ for await (const chunk of __classPrivateFieldGet(this, _Client_fileManager, "f").download(fileId, params)) {
1727
+ yield chunk;
1728
+ }
1520
1729
  }
1521
1730
  /**
1522
- * Get the bot's name in the given language. Bot-only.
1731
+ * Get custom emoji documents for download.
1523
1732
  *
1524
- * @method bs
1525
- * @returns The current bot's name in the specified language.
1733
+ * @method fs
1734
+ * @param id Identifier of one or more of custom emojis.
1735
+ * @returns The custom emoji documents.
1526
1736
  */
1527
- async getMyName(params) {
1528
- return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyName(params);
1737
+ async getCustomEmojiStickers(id) {
1738
+ return await __classPrivateFieldGet(this, _Client_fileManager, "f").getCustomEmojiStickers(id);
1529
1739
  }
1740
+ //
1741
+ // ========================= CHATS ========================= //
1742
+ //
1530
1743
  /**
1531
- * Get the bot's short description in the given language. Bot-only.
1744
+ * Get chats from a chat list. User-only.
1532
1745
  *
1533
- * @method bs
1534
- * @returns The current bot's short description in the specified language.
1746
+ * @method ch
1535
1747
  */
1536
- async getMyShortDescription(params) {
1537
- return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyShortDescription(params);
1748
+ async getChats(params) {
1749
+ return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getChats(params?.from, params?.after, params?.limit);
1538
1750
  }
1539
1751
  /**
1540
- * Delete multiple messages.
1752
+ * Get a chat.
1541
1753
  *
1542
- * @method ms
1543
- * @param chatId The identifier of the chat that contains the messages.
1544
- * @param messageIds The identifiers of the messages to delete.
1754
+ * @method ch
1545
1755
  */
1546
- async deleteMessages(chatId, messageIds, params) {
1547
- await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteMessages(chatId, messageIds, params);
1756
+ async getChat(chatId) {
1757
+ return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getChat(chatId);
1548
1758
  }
1549
1759
  /**
1550
- * Delete a single message.
1760
+ * Get chat history. User-only.
1551
1761
  *
1552
- * @method ms
1553
- * @param chatId The identifier of the chat that contains the message.
1554
- * @param messageId The identifier of the message to delete.
1762
+ * @method ch
1763
+ * @param chatId The identifier of the chat to get its history.
1555
1764
  */
1556
- async deleteMessage(chatId, messageId, params) {
1557
- await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteMessages(chatId, [messageId], params);
1765
+ async getHistory(chatId, params) {
1766
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").getHistory(chatId, params);
1558
1767
  }
1559
1768
  /**
1560
- * Send a photo.
1769
+ * Set a chat's available reactions. User-only.
1561
1770
  *
1562
- * @method ms
1563
- * @param chatId The chat to send the photo to.
1564
- * @param photo The photo to send.
1565
- * @returns The sent photo.
1771
+ * @method ch
1772
+ * @param chatId The identifier of the chat.
1773
+ * @param availableReactions The new available reactions.
1566
1774
  */
1567
- async sendPhoto(chatId, photo, params) {
1568
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendPhoto(chatId, photo, params);
1775
+ async setAvailableReactions(chatId, availableReactions) {
1776
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").setAvailableReactions(chatId, availableReactions);
1569
1777
  }
1570
1778
  /**
1571
- * Send a document.
1779
+ * Set a chat's photo.
1572
1780
  *
1573
- * @method ms
1574
- * @param chatId The chat to send the document to.
1575
- * @param document The document to send.
1576
- * @returns The sent document.
1781
+ * @method ch
1782
+ * @param chatId The identifier of the chat.
1783
+ * @param photo A photo to set as the chat's photo.
1577
1784
  */
1578
- async sendDocument(chatId, document, params) {
1579
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendDocument(chatId, document, params);
1785
+ async setChatPhoto(chatId, photo, params) {
1786
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").setChatPhoto(chatId, photo, params);
1580
1787
  }
1581
1788
  /**
1582
- * Send a sticker.
1789
+ * Delete a chat's photo.
1583
1790
  *
1584
- * @method ms
1585
- * @param chatId The chat to send the sticker to.
1586
- * @param document The sticker to send.
1587
- * @returns The sent sticker.
1791
+ * @method ch
1792
+ * @param chatId The identifier of the chat.
1588
1793
  */
1589
- async sendSticker(chatId, sticker, params) {
1590
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendSticker(chatId, sticker, params);
1794
+ async deleteChatPhoto(chatId) {
1795
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteChatPhoto(chatId);
1591
1796
  }
1592
1797
  /**
1593
- * Send a video.
1798
+ * Ban a member from a chat.
1594
1799
  *
1595
- * @method ms
1596
- * @param chatId The chat to send the video to.
1597
- * @param video The video to send.
1598
- * @returns The sent video.
1800
+ * @method ch
1801
+ * @param chatId The identifier of the chat.
1802
+ * @param memberId The identifier of the member.
1599
1803
  */
1600
- async sendVideo(chatId, video, params) {
1601
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendVideo(chatId, video, params);
1804
+ async banChatMember(chatId, memberId, params) {
1805
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").banChatMember(chatId, memberId, params);
1602
1806
  }
1603
1807
  /**
1604
- * Send an animation.
1808
+ * Unban a member from a chat.
1605
1809
  *
1606
- * @method ms
1607
- * @param chatId The chat to send the animation to.
1608
- * @param animation The animation to send.
1609
- * @returns The sent animation.
1810
+ * @method ch
1811
+ * @param chatId The identifier of the chat. Must be a supergroup.
1812
+ * @param memberId The identifier of the member.
1610
1813
  */
1611
- async sendAnimation(chatId, animation, params) {
1612
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendAnimation(chatId, animation, params);
1814
+ async unbanChatMember(chatId, memberId) {
1815
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").unbanChatMember(chatId, memberId);
1613
1816
  }
1614
1817
  /**
1615
- * Send a voice message.
1818
+ * Kick a member from a chat. Same as a banChatMember call followed by unbanChatMember.
1616
1819
  *
1617
- * @method ms
1618
- * @param chatId The chat to send the voice message to.
1619
- * @param voice The voice to send.
1620
- * @returns The sent voice message.
1820
+ * @method ch
1821
+ * @param chatId The identifier of the chat. Must be a supergroup.
1822
+ * @param memberId The identifier of the member.
1621
1823
  */
1622
- async sendVoice(chatId, voice, params) {
1623
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendVoice(chatId, voice, params);
1824
+ async kickChatMember(chatId, memberId) {
1825
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").banChatMember(chatId, memberId);
1826
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").unbanChatMember(chatId, memberId);
1624
1827
  }
1625
1828
  /**
1626
- * Send an audio file.
1829
+ * Set the rights of a chat member.
1627
1830
  *
1628
- * @method ms
1629
- * @param chatId The chat to send the audio file to.
1630
- * @param audio The audio to send.
1631
- * @returns The sent audio filr.
1831
+ * @method ch
1832
+ * @param chatId The identifier of the chat. Must be a supergroup.
1833
+ * @param memberId The identifier of a member.
1632
1834
  */
1633
- async sendAudio(chatId, audio, params) {
1634
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendAudio(chatId, audio, params);
1835
+ async setChatMemberRights(chatId, memberId, params) {
1836
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").setChatMemberRights(chatId, memberId, params);
1635
1837
  }
1636
1838
  /**
1637
- * Send a video note.
1839
+ * Get the administrators of a chat.
1638
1840
  *
1639
- * @method ms
1640
- * @param chatId The chat to send the video note to.
1641
- * @param videoNote The video note to send.
1642
- * @returns The sent video note.
1841
+ * @method ch
1842
+ * @param chatId The identifier of the chat.
1843
+ * @returns The chat's administrators.
1643
1844
  */
1644
- async sendVideoNote(chatId, videoNote, params) {
1645
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendVideoNote(chatId, videoNote, params);
1845
+ async getChatAdministrators(chatId) {
1846
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").getChatAdministrators(chatId);
1646
1847
  }
1647
1848
  /**
1648
- * Send a location.
1849
+ * Enable join requests in a chat. User-only.
1649
1850
  *
1650
- * @method ms
1651
- * @param chatId The chat to send the location to.
1652
- * @param latitude The location's latitude.
1653
- * @param longitude The location's longitude.
1654
- * @returns The sent location.
1851
+ * @method ch
1852
+ * @param chatId The identifier of the chat. Must be a channel or a supergroup.
1655
1853
  */
1656
- async sendLocation(chatId, latitude, longitude, params) {
1657
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendLocation(chatId, latitude, longitude, params);
1854
+ async enableJoinRequests(chatId) {
1855
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").enableJoinRequests(chatId);
1658
1856
  }
1659
1857
  /**
1660
- * Send a contact.
1858
+ * Disable join requests in a chat. User-only.
1661
1859
  *
1662
- * @method ms
1663
- * @param chatId The chat to send the contact to.
1664
- * @param firstName The contact's first name.
1665
- * @param number The contact's phone number.
1666
- * @returns The sent contact.
1860
+ * @method ch
1861
+ * @param chatId The identifier of the chat. Must be a channel or a supergroup.
1667
1862
  */
1668
- async sendContact(chatId, firstName, number, params) {
1669
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendContact(chatId, firstName, number, params);
1863
+ async disableJoinRequests(chatId) {
1864
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").disableJoinRequests(chatId);
1670
1865
  }
1671
1866
  /**
1672
- * Send a dice.
1867
+ * Get inactive chats. User-only.
1673
1868
  *
1674
- * @method ms
1675
- * @param chatId The chat to send the dice to.
1676
- * @returns The sent dice.
1869
+ * @method ch
1870
+ * @retuns A list of inactive chats the current user is member of.
1677
1871
  */
1678
- async sendDice(chatId, params) {
1679
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendDice(chatId, params);
1872
+ async getInactiveChats() {
1873
+ return await __classPrivateFieldGet(this, _Client_accountManager, "f").getInactiveChats();
1680
1874
  }
1681
1875
  /**
1682
- * Send a venue.
1876
+ * Get the invite links created for a chat. User-only.
1683
1877
  *
1684
- * @method ms
1685
- * @param chatId The chat to send the venue to.
1686
- * @param latitude The latitude of the venue.
1687
- * @param longitude The longitude of the venue.
1688
- * @param title The title of the venue.
1689
- * @param address The written address of the venue.
1690
- * @returns The sent venue.
1878
+ * @method ch
1879
+ * @param chatId The identifier of the chat.
1880
+ * @returns The invite links created for the chat. This might be a subset of the results if they were less than `limit`. The parameters `afterDate` and `afterInviteLink` can be used for pagination.
1691
1881
  */
1692
- async sendVenue(chatId, latitude, longitude, title, address, params) {
1693
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendVenue(chatId, latitude, longitude, title, address, params);
1882
+ async getCreatedInviteLinks(chatId, params) {
1883
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").getCreatedInviteLinks(chatId, params);
1694
1884
  }
1695
1885
  /**
1696
- * Get network statistics. This might not always be available.
1886
+ * Join a chat. User-only.
1697
1887
  *
1698
- * @method mc
1888
+ * @method ch
1889
+ * @param chatId The identifier of the chat to join.
1699
1890
  */
1700
- async getNetworkStatistics() {
1701
- return await __classPrivateFieldGet(this, _Client_networkStatisticsManager, "f").getNetworkStatistics();
1891
+ async joinChat(chatId) {
1892
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").joinChat(chatId);
1702
1893
  }
1703
1894
  /**
1704
- * Get chats from a chat list. User-only.
1895
+ * Leave a chat.
1705
1896
  *
1706
1897
  * @method ch
1898
+ * @param chatId The identifier of the chat to leave.
1707
1899
  */
1708
- async getChats(params) {
1709
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getChats(params?.from, params?.after, params?.limit);
1900
+ async leaveChat(chatId) {
1901
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").leaveChat(chatId);
1710
1902
  }
1711
1903
  /**
1712
- * Get a chat.
1904
+ * Get information on a user's chat membership.
1713
1905
  *
1714
1906
  * @method ch
1907
+ * @param chatId The identifier of a chat that includes the user.
1908
+ * @param userId The identifier of the user.
1715
1909
  */
1716
- async getChat(chatId) {
1717
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getChat(chatId);
1910
+ async getChatMember(chatId, userId) {
1911
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").getChatMember(chatId, userId);
1718
1912
  }
1719
1913
  /**
1720
- * Get chat history. User-only.
1914
+ * Set a chat's sticker set.
1721
1915
  *
1722
1916
  * @method ch
1723
- * @param chatId The identifier of the chat to get its history.
1917
+ * @param chatId The identifier of the chat. Must be a supergroup.
1918
+ * @param setName The name of the set.
1724
1919
  */
1725
- async getHistory(chatId, params) {
1726
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").getHistory(chatId, params);
1920
+ async setChatStickerSet(chatId, setName) {
1921
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").setChatStickerSet(chatId, setName);
1727
1922
  }
1728
1923
  /**
1729
- * Get custom emoji documents for download.
1924
+ * Delete a chat's sticker set.
1730
1925
  *
1731
- * @method fs
1732
- * @param id Identifier of one or more of custom emojis.
1733
- * @returns The custom emoji documents.
1926
+ * @method ch
1927
+ * @param chatId The identifier of the chat. Must be a supergroup.
1734
1928
  */
1735
- async getCustomEmojiStickers(id) {
1736
- return await __classPrivateFieldGet(this, _Client_fileManager, "f").getCustomEmojiStickers(id);
1929
+ async deleteChatStickerSet(chatId) {
1930
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteChatStickerSet(chatId);
1737
1931
  }
1738
1932
  /**
1739
- * Set a chat's available reactions. User-only.
1933
+ * Set the number of boosts required to circument a chat's default restrictions. User-only.
1740
1934
  *
1741
1935
  * @method ch
1742
1936
  * @param chatId The identifier of the chat.
1743
- * @param availableReactions The new available reactions.
1937
+ * @param boosts The number of boosts required to circumvent its restrictions.
1744
1938
  */
1745
- async setAvailableReactions(chatId, availableReactions) {
1746
- await __classPrivateFieldGet(this, _Client_messageManager, "f").setAvailableReactions(chatId, availableReactions);
1939
+ async setBoostsRequiredToCircumventRestrictions(chatId, boosts) {
1940
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").setBoostsRequiredToCircumventRestrictions(chatId, boosts);
1747
1941
  }
1748
1942
  /**
1749
- * Change reactions made to a message.
1943
+ * Create an invite link.
1750
1944
  *
1751
- * @method re
1752
- * @param chatId The identifier of the chat which the message belongs to.
1753
- * @param messageId The identifier of the message to add the reaction to.
1754
- * @param reactions The new reactions.
1945
+ * @method ch
1946
+ * @param chatId The identifier of the chat to create the invite link for.
1947
+ * @returns The newly created invite link.
1755
1948
  */
1756
- async setReactions(chatId, messageId, reactions, params) {
1757
- await __classPrivateFieldGet(this, _Client_messageManager, "f").setReactions(chatId, messageId, reactions, params);
1949
+ async createInviteLink(chatId, params) {
1950
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").createInviteLink(chatId, params);
1758
1951
  }
1952
+ //
1953
+ // ========================= CALLBACK QUERIES ========================= //
1954
+ //
1759
1955
  /**
1760
- * Make a reaction to a message.
1956
+ * Answer a callback query. Bot-only.
1761
1957
  *
1762
- * @method re
1763
- * @param chatId The identifier of the chat which the message belongs to.
1764
- * @param messageId The identifier of the message to add the reaction to.
1765
- * @param reaction The reaction to add.
1958
+ * @method cq
1959
+ * @param id ID of the callback query to answer.
1766
1960
  */
1767
- async addReaction(chatId, messageId, reaction, params) {
1768
- await __classPrivateFieldGet(this, _Client_messageManager, "f").addReaction(chatId, messageId, reaction, params);
1961
+ async answerCallbackQuery(id, params) {
1962
+ await __classPrivateFieldGet(this, _Client_callbackQueryManager, "f").answerCallbackQuery(id, params);
1769
1963
  }
1964
+ //
1965
+ // ========================= INLINE QUERIES ========================= //
1966
+ //
1770
1967
  /**
1771
- * Undo a reaction made to a message.
1968
+ * Answer an inline query. Bot-only.
1772
1969
  *
1773
- * @method re
1774
- * @param chatId The identifier of the chat which the message belongs to.
1775
- * @param messageId The identifier of the message which the reaction was made to.
1776
- * @param reaction The reaction to remove.
1970
+ * @method iq
1971
+ * @param id The ID of the inline query to answer.
1972
+ * @param results The results to answer with.
1777
1973
  */
1778
- async removeReaction(chatId, messageId, reaction) {
1779
- await __classPrivateFieldGet(this, _Client_messageManager, "f").removeReaction(chatId, messageId, reaction);
1974
+ async answerInlineQuery(id, results, params) {
1975
+ await __classPrivateFieldGet(this, _Client_inlineQueryManager, "f").answerInlineQuery(id, results, params);
1780
1976
  }
1977
+ //
1978
+ // ========================= BOTS ========================= //
1979
+ //
1781
1980
  /**
1782
- * Set a chat's photo.
1981
+ * Set the bot's description in the given language. Bot-only.
1783
1982
  *
1784
- * @method ch
1785
- * @param chatId The identifier of the chat.
1786
- * @param photo A photo to set as the chat's photo.
1983
+ * @method bs
1787
1984
  */
1788
- async setChatPhoto(chatId, photo, params) {
1789
- await __classPrivateFieldGet(this, _Client_messageManager, "f").setChatPhoto(chatId, photo, params);
1985
+ async setMyDescription(params) {
1986
+ await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyDescription(params);
1790
1987
  }
1791
1988
  /**
1792
- * Delete a chat's photo.
1989
+ * Set the bot's name in the given language. Bot-only.
1793
1990
  *
1794
- * @method ch
1795
- * @param chatId The identifier of the chat.
1991
+ * @method bs
1796
1992
  */
1797
- async deleteChatPhoto(chatId) {
1798
- await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteChatPhoto(chatId);
1993
+ async setMyName(params) {
1994
+ await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyName(params);
1799
1995
  }
1800
1996
  /**
1801
- * Delete all messages sent by a specific member of a chat. User-only.
1997
+ * Set the bot's short description in the given language. Bot-only.
1802
1998
  *
1803
- * @method ms
1804
- * @param chatId The identifier of the chat. Must be a supergroup.
1805
- * @param memberId The identifier of the member.
1999
+ * @method bs
1806
2000
  */
1807
- async deleteChatMemberMessages(chatId, memberId) {
1808
- await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteChatMemberMessages(chatId, memberId);
2001
+ async setMyShortDescription(params) {
2002
+ await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyShortDescription(params);
1809
2003
  }
1810
2004
  /**
1811
- * Pin a message in a chat.
2005
+ * Get the bot's description in the given language. Bot-only.
1812
2006
  *
1813
- * @method ms
1814
- * @param chatId The identifier of the chat that contains the message.
1815
- * @param messageId The message's identifier.
2007
+ * @method bs
2008
+ * @returns The current bot's description in the specified language.
1816
2009
  */
1817
- async pinMessage(chatId, messageId, params) {
1818
- await __classPrivateFieldGet(this, _Client_messageManager, "f").pinMessage(chatId, messageId, params);
2010
+ async getMyDescription(params) {
2011
+ return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyDescription(params);
1819
2012
  }
1820
2013
  /**
1821
- * Unpin a pinned message.
2014
+ * Get the bot's name in the given language. Bot-only.
1822
2015
  *
1823
- * @method ms
1824
- * @param chatId The identifier of the chat that contains the message.
1825
- * @param messageId The message's identifier.
2016
+ * @method bs
2017
+ * @returns The current bot's name in the specified language.
1826
2018
  */
1827
- async unpinMessage(chatId, messageId) {
1828
- await __classPrivateFieldGet(this, _Client_messageManager, "f").unpinMessage(chatId, messageId);
2019
+ async getMyName(params) {
2020
+ return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyName(params);
1829
2021
  }
1830
2022
  /**
1831
- * Unpin all pinned messages.
2023
+ * Get the bot's short description in the given language. Bot-only.
1832
2024
  *
1833
- * @method ms
1834
- * @param chatId The identifier of the chat.
2025
+ * @method bs
2026
+ * @returns The current bot's short description in the specified language.
1835
2027
  */
1836
- async unpinMessages(chatId) {
1837
- await __classPrivateFieldGet(this, _Client_messageManager, "f").unpinMessages(chatId);
2028
+ async getMyShortDescription(params) {
2029
+ return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyShortDescription(params);
1838
2030
  }
1839
2031
  /**
1840
- * Ban a member from a chat.
2032
+ * Set the bot's commands in the given scope and/or language. Bot-only.
1841
2033
  *
1842
- * @method ch
1843
- * @param chatId The identifier of the chat.
1844
- * @param memberId The identifier of the member.
2034
+ * @method bs
2035
+ * @param commands The commands to set.
1845
2036
  */
1846
- async banChatMember(chatId, memberId, params) {
1847
- await __classPrivateFieldGet(this, _Client_messageManager, "f").banChatMember(chatId, memberId, params);
2037
+ async setMyCommands(commands, params) {
2038
+ await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyCommands(commands, params);
1848
2039
  }
1849
2040
  /**
1850
- * Unban a member from a chat.
2041
+ * Get the bot's commands in the given scope and/or language. Bot-only.
1851
2042
  *
1852
- * @method ch
1853
- * @param chatId The identifier of the chat. Must be a supergroup.
1854
- * @param memberId The identifier of the member.
2043
+ * @method bs
2044
+ * @returns The current bot's commands in the specified language.
1855
2045
  */
1856
- async unbanChatMember(chatId, memberId) {
1857
- await __classPrivateFieldGet(this, _Client_messageManager, "f").unbanChatMember(chatId, memberId);
2046
+ async getMyCommands(params) {
2047
+ return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyCommands(params);
1858
2048
  }
2049
+ //
2050
+ // ========================= REACTIONS ========================= //
2051
+ //
1859
2052
  /**
1860
- * Kick a member from a chat. Same as a banChatMember call followed by unbanChatMember.
2053
+ * Change reactions made to a message.
1861
2054
  *
1862
- * @method ch
1863
- * @param chatId The identifier of the chat. Must be a supergroup.
1864
- * @param memberId The identifier of the member.
2055
+ * @method re
2056
+ * @param chatId The identifier of the chat which the message belongs to.
2057
+ * @param messageId The identifier of the message to add the reaction to.
2058
+ * @param reactions The new reactions.
1865
2059
  */
1866
- async kickChatMember(chatId, memberId) {
1867
- await __classPrivateFieldGet(this, _Client_messageManager, "f").banChatMember(chatId, memberId);
1868
- await __classPrivateFieldGet(this, _Client_messageManager, "f").unbanChatMember(chatId, memberId);
2060
+ async setReactions(chatId, messageId, reactions, params) {
2061
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").setReactions(chatId, messageId, reactions, params);
1869
2062
  }
1870
2063
  /**
1871
- * Set the rights of a chat member.
2064
+ * Make a reaction to a message.
1872
2065
  *
1873
- * @method ch
1874
- * @param chatId The identifier of the chat. Must be a supergroup.
1875
- * @param memberId The identifier of a member.
2066
+ * @method re
2067
+ * @param chatId The identifier of the chat which the message belongs to.
2068
+ * @param messageId The identifier of the message to add the reaction to.
2069
+ * @param reaction The reaction to add.
1876
2070
  */
1877
- async setChatMemberRights(chatId, memberId, params) {
1878
- await __classPrivateFieldGet(this, _Client_messageManager, "f").setChatMemberRights(chatId, memberId, params);
2071
+ async addReaction(chatId, messageId, reaction, params) {
2072
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").addReaction(chatId, messageId, reaction, params);
1879
2073
  }
1880
2074
  /**
1881
- * Get the administrators of a chat.
2075
+ * Undo a reaction made to a message.
1882
2076
  *
1883
- * @method ch
1884
- * @param chatId The identifier of the chat.
1885
- * @returns The chat's administrators.
2077
+ * @method re
2078
+ * @param chatId The identifier of the chat which the message belongs to.
2079
+ * @param messageId The identifier of the message which the reaction was made to.
2080
+ * @param reaction The reaction to remove.
1886
2081
  */
1887
- async getChatAdministrators(chatId) {
1888
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").getChatAdministrators(chatId);
2082
+ async removeReaction(chatId, messageId, reaction) {
2083
+ await __classPrivateFieldGet(this, _Client_messageManager, "f").removeReaction(chatId, messageId, reaction);
1889
2084
  }
2085
+ //
2086
+ // ========================= STORIES ========================= //
2087
+ //
1890
2088
  /**
1891
2089
  * Create a story. User-only.
1892
2090
  *
@@ -1981,130 +2179,16 @@ export class Client extends Composer {
1981
2179
  async removeStoryFromHighlights(chatId, storyId) {
1982
2180
  await __classPrivateFieldGet(this, _Client_storyManager, "f").removeStoryFromHighlights(chatId, storyId);
1983
2181
  }
2182
+ //
2183
+ // ========================= MISC ========================= //
2184
+ //
1984
2185
  /**
1985
- * Enable join requests in a chat. User-only.
1986
- *
1987
- * @method ch
1988
- * @param chatId The identifier of the chat. Must be a channel or a supergroup.
1989
- */
1990
- async enableJoinRequests(chatId) {
1991
- await __classPrivateFieldGet(this, _Client_messageManager, "f").enableJoinRequests(chatId);
1992
- }
1993
- /**
1994
- * Disable join requests in a chat. User-only.
1995
- *
1996
- * @method ch
1997
- * @param chatId The identifier of the chat. Must be a channel or a supergroup.
1998
- */
1999
- async disableJoinRequests(chatId) {
2000
- await __classPrivateFieldGet(this, _Client_messageManager, "f").disableJoinRequests(chatId);
2001
- }
2002
- /**
2003
- * Show a username in the current account, a bot account, sa upergroup, or a channel's profile. User-only.
2004
- *
2005
- * @method ac
2006
- * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
2007
- * @param username The username to show.
2008
- */
2009
- async showUsername(id, username) {
2010
- await __classPrivateFieldGet(this, _Client_accountManager, "f").showUsername(id, username);
2011
- }
2012
- /**
2013
- * Hide a username from the current account, a bot account, a supergroup, or a channel's profile. User-only.
2014
- *
2015
- * @method ac
2016
- * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
2017
- * @param username The username to hide.
2018
- */
2019
- async hideUsername(id, username) {
2020
- await __classPrivateFieldGet(this, _Client_accountManager, "f").hideUsername(id, username);
2021
- }
2022
- /**
2023
- * Reorder the usernames of the current account, a bot account, a supergroup, or a channel's profile. User-only.
2024
- *
2025
- * @method ac
2026
- * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
2027
- * @param order The new order to use.
2028
- * @returns Whether the order was changed.
2029
- */
2030
- async reorderUsernames(id, order) {
2031
- return await __classPrivateFieldGet(this, _Client_accountManager, "f").reorderUsernames(id, order);
2032
- }
2033
- /**
2034
- * Hide all usernames from the a supergroup or a channel's profile. User-only.
2035
- *
2036
- * @method ac
2037
- * @param id A supergroup ID or a channel ID.
2038
- */
2039
- async hideUsernames(id) {
2040
- return await __classPrivateFieldGet(this, _Client_accountManager, "f").hideUsernames(id);
2041
- }
2042
- /**
2043
- * Get inactive chats. User-only.
2044
- *
2045
- * @method ch
2046
- * @retuns A list of inactive chats the current user is member of.
2047
- */
2048
- async getInactiveChats() {
2049
- return await __classPrivateFieldGet(this, _Client_accountManager, "f").getInactiveChats();
2050
- }
2051
- /**
2052
- * Search the messages of a chat. User-only.
2053
- *
2054
- * @method ms
2055
- * @param chatId The identifier of the chat to search the messages in.
2056
- * @param query The message search query.
2057
- */
2058
- async searchMessages(chatId, query, params) {
2059
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").searchMessages(chatId, query, params);
2060
- }
2061
- /**
2062
- * Set the number of boosts required to circument a chat's default restrictions. User-only.
2063
- *
2064
- * @method ch
2065
- * @param chatId The identifier of the chat.
2066
- * @param boosts The number of boosts required to circumvent its restrictions.
2067
- */
2068
- async setBoostsRequiredToCircumventRestrictions(chatId, boosts) {
2069
- await __classPrivateFieldGet(this, _Client_messageManager, "f").setBoostsRequiredToCircumventRestrictions(chatId, boosts);
2070
- }
2071
- /**
2072
- * Create an invite link.
2073
- *
2074
- * @method ch
2075
- * @param chatId The identifier of the chat to create the invite link for.
2076
- * @returns The newly created invite link.
2077
- */
2078
- async createInviteLink(chatId, params) {
2079
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").createInviteLink(chatId, params);
2080
- }
2081
- /**
2082
- * Get the invite links created for a chat. User-only.
2083
- *
2084
- * @method ch
2085
- * @param chatId The identifier of the chat.
2086
- * @returns The invite links created for the chat. This might be a subset of the results if they were less than `limit`. The parameters `afterDate` and `afterInviteLink` can be used for pagination.
2087
- */
2088
- async getCreatedInviteLinks(chatId, params) {
2089
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").getCreatedInviteLinks(chatId, params);
2090
- }
2091
- /**
2092
- * Join a chat. User-only.
2093
- *
2094
- * @method ch
2095
- * @param chatId The identifier of the chat to join.
2096
- */
2097
- async joinChat(chatId) {
2098
- await __classPrivateFieldGet(this, _Client_messageManager, "f").joinChat(chatId);
2099
- }
2100
- /**
2101
- * Leave a chat.
2186
+ * Get network statistics. This might not always be available.
2102
2187
  *
2103
- * @method ch
2104
- * @param chatId The identifier of the chat to leave.
2188
+ * @method mc
2105
2189
  */
2106
- async leaveChat(chatId) {
2107
- await __classPrivateFieldGet(this, _Client_messageManager, "f").leaveChat(chatId);
2190
+ async getNetworkStatistics() {
2191
+ return await __classPrivateFieldGet(this, _Client_networkStatisticsManager, "f").getNetworkStatistics();
2108
2192
  }
2109
2193
  /**
2110
2194
  * Block a user. User-only.
@@ -2124,35 +2208,6 @@ export class Client extends Composer {
2124
2208
  async unblockUser(userId) {
2125
2209
  await __classPrivateFieldGet(this, _Client_messageManager, "f").unblockUser(userId);
2126
2210
  }
2127
- /**
2128
- * Get information on a user's chat membership.
2129
- *
2130
- * @method ch
2131
- * @param chatId The identifier of a chat that includes the user.
2132
- * @param userId The identifier of the user.
2133
- */
2134
- async getChatMember(chatId, userId) {
2135
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").getChatMember(chatId, userId);
2136
- }
2137
- /**
2138
- * Set a chat's sticker set.
2139
- *
2140
- * @method ch
2141
- * @param chatId The identifier of the chat. Must be a supergroup.
2142
- * @param setName The name of the set.
2143
- */
2144
- async setChatStickerSet(chatId, setName) {
2145
- await __classPrivateFieldGet(this, _Client_messageManager, "f").setChatStickerSet(chatId, setName);
2146
- }
2147
- /**
2148
- * Delete a chat's sticker set.
2149
- *
2150
- * @method ch
2151
- * @param chatId The identifier of the chat. Must be a supergroup.
2152
- */
2153
- async deleteChatStickerSet(chatId) {
2154
- await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteChatStickerSet(chatId);
2155
- }
2156
2211
  }
2157
2212
  _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
2158
2213
  await this.middleware()(await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, update), resolve);
@@ -2212,6 +2267,9 @@ _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
2212
2267
  promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, upd));
2213
2268
  }
2214
2269
  }
2270
+ if (BusinessConnectionManager.canHandleUpdate(update)) {
2271
+ promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, await __classPrivateFieldGet(this, _Client_businessConnectionManager, "f").handleUpdate(update)));
2272
+ }
2215
2273
  return () => Promise.all(promises);
2216
2274
  }, _Client_getMe = async function _Client_getMe() {
2217
2275
  if (__classPrivateFieldGet(this, _Client_lastGetMe, "f") != null) {