@mtkruto/node 0.0.991 → 0.0.992

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 (254) hide show
  1. package/esm/1_utilities.d.ts +12 -0
  2. package/esm/1_utilities.js +12 -0
  3. package/esm/2_connection.d.ts +2 -0
  4. package/esm/2_connection.js +2 -0
  5. package/esm/2_tl.d.ts +10 -0
  6. package/esm/2_tl.js +10 -0
  7. package/esm/3_storage.d.ts +6 -0
  8. package/esm/3_storage.js +6 -0
  9. package/esm/3_transport.d.ts +4 -0
  10. package/esm/3_transport.js +4 -0
  11. package/esm/3_types.d.ts +35 -0
  12. package/esm/3_types.js +35 -0
  13. package/esm/{constants.d.ts → 4_constants.d.ts} +2 -2
  14. package/esm/{constants.js → 4_constants.js} +1 -1
  15. package/esm/5_client.d.ts +2 -0
  16. package/esm/5_client.js +2 -0
  17. package/esm/client/0_html.d.ts +1 -1
  18. package/esm/client/0_html.js +1 -1
  19. package/esm/client/0_message.d.ts +1 -2
  20. package/esm/client/0_message.js +7 -14
  21. package/esm/client/0_password.d.ts +2 -2
  22. package/esm/client/0_password.js +2 -4
  23. package/esm/client/0_utilities.d.ts +3 -5
  24. package/esm/client/0_utilities.js +3 -22
  25. package/esm/client/1_client_abstract.d.ts +2 -2
  26. package/esm/client/1_client_abstract.js +3 -3
  27. package/esm/client/2_client_plain.d.ts +3 -3
  28. package/esm/client/2_client_plain.js +13 -20
  29. package/esm/client/3_client.d.ts +33 -18
  30. package/esm/client/3_client.js +47 -35
  31. package/esm/connection/0_connection.d.ts +1 -1
  32. package/esm/connection/1_connection_web_socket.js +1 -1
  33. package/esm/mod.d.ts +7 -21
  34. package/esm/mod.js +7 -21
  35. package/esm/storage/0_storage.d.ts +4 -5
  36. package/esm/storage/0_storage.js +3 -8
  37. package/esm/storage/0_utilities.js +2 -2
  38. package/esm/storage/1_storage_local_storage.d.ts +1 -1
  39. package/esm/storage/1_storage_memory.d.ts +1 -1
  40. package/esm/storage/1_storage_session_storage.d.ts +1 -1
  41. package/esm/tl/0_tl_raw_reader.js +1 -1
  42. package/esm/tl/0_tl_raw_writer.js +1 -1
  43. package/esm/tl/1_tl_object.js +1 -1
  44. package/esm/tl/3_deserialize.js +1 -1
  45. package/esm/tl/3_utilities.d.ts +3 -0
  46. package/esm/tl/3_utilities.js +20 -0
  47. package/esm/tl/4_tl_writer.js +1 -1
  48. package/esm/transport/0_obfuscation.d.ts +2 -2
  49. package/esm/transport/0_obfuscation.js +1 -2
  50. package/esm/transport/0_transport.d.ts +1 -2
  51. package/esm/transport/1_transport_abridged.d.ts +1 -1
  52. package/esm/transport/1_transport_abridged.js +1 -1
  53. package/esm/transport/1_transport_intermediate.d.ts +1 -1
  54. package/esm/transport/1_transport_intermediate.js +1 -1
  55. package/esm/transport/2_transport_provider.d.ts +1 -1
  56. package/esm/transport/2_transport_provider.js +1 -1
  57. package/esm/types/!0_file_id.js +6 -9
  58. package/esm/types/!0_misc.d.ts +7 -0
  59. package/esm/types/!0_misc.js +1 -0
  60. package/esm/types/0_audio.d.ts +3 -3
  61. package/esm/types/0_audio.js +1 -1
  62. package/esm/types/0_chat_administrator_rights.d.ts +1 -1
  63. package/esm/types/0_chat_administrator_rights.js +1 -1
  64. package/esm/types/0_chat_photo.d.ts +3 -3
  65. package/esm/types/0_chat_photo.js +1 -1
  66. package/esm/types/0_color.d.ts +2 -0
  67. package/esm/types/0_color.js +16 -0
  68. package/esm/types/0_contact.d.ts +2 -2
  69. package/esm/types/0_dice.d.ts +1 -1
  70. package/esm/types/0_force_reply.d.ts +1 -1
  71. package/esm/types/0_force_reply.js +1 -1
  72. package/esm/types/0_location.d.ts +1 -1
  73. package/esm/types/0_location.js +1 -2
  74. package/esm/types/0_mask_position.d.ts +1 -1
  75. package/esm/types/0_message_entity.d.ts +5 -5
  76. package/esm/types/0_message_entity.js +1 -1
  77. package/esm/types/0_poll_option.d.ts +1 -1
  78. package/esm/types/0_reply_keyboard_remove.d.ts +1 -1
  79. package/esm/types/0_reply_keyboard_remove.js +2 -2
  80. package/esm/types/0_thumbnail.d.ts +2 -2
  81. package/esm/types/0_thumbnail.js +1 -1
  82. package/esm/types/0_venue.d.ts +1 -1
  83. package/esm/types/0_venue.js +1 -2
  84. package/esm/types/0_voice.d.ts +3 -3
  85. package/esm/types/0_web_app_info.d.ts +2 -2
  86. package/esm/types/1_animation.d.ts +3 -3
  87. package/esm/types/1_animation.js +1 -1
  88. package/esm/types/1_chat.d.ts +5 -4
  89. package/esm/types/1_chat.js +8 -9
  90. package/esm/types/1_document.d.ts +4 -4
  91. package/esm/types/1_document.js +1 -1
  92. package/esm/types/1_inline_keyboard_button.d.ts +4 -4
  93. package/esm/types/1_inline_keyboard_button.js +2 -2
  94. package/esm/types/1_keyboard_button.d.ts +8 -8
  95. package/esm/types/1_keyboard_button.js +2 -2
  96. package/esm/types/1_photo.d.ts +2 -2
  97. package/esm/types/1_photo.js +1 -1
  98. package/esm/types/1_poll.d.ts +8 -8
  99. package/esm/types/1_poll.js +1 -1
  100. package/esm/types/1_sticker.d.ts +3 -3
  101. package/esm/types/1_sticker.js +1 -2
  102. package/esm/types/1_user.d.ts +4 -3
  103. package/esm/types/1_user.js +4 -4
  104. package/esm/types/1_video.d.ts +3 -3
  105. package/esm/types/1_video.js +1 -1
  106. package/esm/types/1_video_note.d.ts +2 -2
  107. package/esm/types/1_video_note.js +1 -1
  108. package/esm/types/2_game.d.ts +3 -3
  109. package/esm/types/2_game.js +2 -3
  110. package/esm/types/2_inline_keyboard_markup.d.ts +2 -2
  111. package/esm/types/2_inline_keyboard_markup.js +1 -1
  112. package/esm/types/2_inline_query.d.ts +19 -0
  113. package/esm/types/2_inline_query.js +41 -0
  114. package/esm/types/2_reply_keyboard_markup.d.ts +2 -2
  115. package/esm/types/2_reply_keyboard_markup.js +1 -1
  116. package/esm/types/3_message.d.ts +21 -23
  117. package/esm/types/3_message.js +16 -18
  118. package/esm/types/4_callback_query.d.ts +14 -0
  119. package/esm/types/4_callback_query.js +24 -0
  120. package/esm/utilities/0_base64.js +1 -1
  121. package/esm/utilities/0_crypto.js +1 -1
  122. package/esm/utilities/0_queue.js +1 -1
  123. package/esm/utilities/1_auth.js +1 -1
  124. package/package.json +1 -1
  125. package/script/1_utilities.d.ts +12 -0
  126. package/script/1_utilities.js +28 -0
  127. package/script/2_connection.d.ts +2 -0
  128. package/script/2_connection.js +18 -0
  129. package/script/2_tl.d.ts +10 -0
  130. package/script/2_tl.js +40 -0
  131. package/script/3_storage.d.ts +6 -0
  132. package/script/3_storage.js +22 -0
  133. package/script/3_transport.d.ts +4 -0
  134. package/script/3_transport.js +20 -0
  135. package/script/3_types.d.ts +35 -0
  136. package/script/3_types.js +51 -0
  137. package/script/{constants.d.ts → 4_constants.d.ts} +2 -2
  138. package/script/{constants.js → 4_constants.js} +1 -1
  139. package/script/5_client.d.ts +2 -0
  140. package/script/5_client.js +18 -0
  141. package/script/client/0_html.d.ts +1 -1
  142. package/script/client/0_html.js +2 -2
  143. package/script/client/0_message.d.ts +1 -2
  144. package/script/client/0_message.js +32 -39
  145. package/script/client/0_password.d.ts +2 -2
  146. package/script/client/0_password.js +20 -22
  147. package/script/client/0_utilities.d.ts +3 -5
  148. package/script/client/0_utilities.js +24 -68
  149. package/script/client/1_client_abstract.d.ts +2 -2
  150. package/script/client/1_client_abstract.js +6 -6
  151. package/script/client/2_client_plain.d.ts +3 -3
  152. package/script/client/2_client_plain.js +45 -52
  153. package/script/client/3_client.d.ts +33 -18
  154. package/script/client/3_client.js +291 -303
  155. package/script/connection/0_connection.d.ts +1 -1
  156. package/script/connection/1_connection_web_socket.js +5 -5
  157. package/script/mod.d.ts +7 -21
  158. package/script/mod.js +17 -45
  159. package/script/storage/0_storage.d.ts +4 -5
  160. package/script/storage/0_storage.js +11 -39
  161. package/script/storage/0_utilities.js +6 -6
  162. package/script/storage/1_storage_local_storage.d.ts +1 -1
  163. package/script/storage/1_storage_memory.d.ts +1 -1
  164. package/script/storage/1_storage_session_storage.d.ts +1 -1
  165. package/script/tl/0_tl_raw_reader.js +6 -6
  166. package/script/tl/0_tl_raw_writer.js +7 -7
  167. package/script/tl/1_tl_object.js +3 -3
  168. package/script/tl/3_deserialize.js +2 -2
  169. package/script/tl/3_utilities.d.ts +3 -0
  170. package/script/tl/3_utilities.js +48 -0
  171. package/script/tl/4_tl_writer.js +2 -2
  172. package/script/transport/0_obfuscation.d.ts +2 -2
  173. package/script/transport/0_obfuscation.js +5 -6
  174. package/script/transport/0_transport.d.ts +1 -2
  175. package/script/transport/1_transport_abridged.d.ts +1 -1
  176. package/script/transport/1_transport_abridged.js +3 -3
  177. package/script/transport/1_transport_intermediate.d.ts +1 -1
  178. package/script/transport/1_transport_intermediate.js +3 -3
  179. package/script/transport/2_transport_provider.d.ts +1 -1
  180. package/script/transport/2_transport_provider.js +2 -2
  181. package/script/types/!0_file_id.js +24 -27
  182. package/script/types/!0_misc.d.ts +7 -0
  183. package/script/types/!0_misc.js +2 -0
  184. package/script/types/0_audio.d.ts +3 -3
  185. package/script/types/0_audio.js +2 -25
  186. package/script/types/0_chat_administrator_rights.d.ts +1 -1
  187. package/script/types/0_chat_administrator_rights.js +2 -25
  188. package/script/types/0_chat_photo.d.ts +3 -3
  189. package/script/types/0_chat_photo.js +2 -25
  190. package/script/types/0_color.d.ts +2 -0
  191. package/script/types/{!0_id_color.js → 0_color.js} +10 -10
  192. package/script/types/0_contact.d.ts +2 -2
  193. package/script/types/0_dice.d.ts +1 -1
  194. package/script/types/0_force_reply.d.ts +1 -1
  195. package/script/types/0_force_reply.js +2 -25
  196. package/script/types/0_location.d.ts +1 -1
  197. package/script/types/0_location.js +5 -29
  198. package/script/types/0_mask_position.d.ts +1 -1
  199. package/script/types/0_message_entity.d.ts +5 -5
  200. package/script/types/0_message_entity.js +39 -62
  201. package/script/types/0_poll_option.d.ts +1 -1
  202. package/script/types/0_reply_keyboard_remove.d.ts +1 -1
  203. package/script/types/0_reply_keyboard_remove.js +4 -27
  204. package/script/types/0_thumbnail.d.ts +2 -2
  205. package/script/types/0_thumbnail.js +2 -25
  206. package/script/types/0_venue.d.ts +1 -1
  207. package/script/types/0_venue.js +2 -26
  208. package/script/types/0_voice.d.ts +3 -3
  209. package/script/types/0_web_app_info.d.ts +2 -2
  210. package/script/types/1_animation.d.ts +3 -3
  211. package/script/types/1_animation.js +2 -25
  212. package/script/types/1_chat.d.ts +5 -4
  213. package/script/types/1_chat.js +20 -44
  214. package/script/types/1_document.d.ts +4 -4
  215. package/script/types/1_document.js +2 -25
  216. package/script/types/1_inline_keyboard_button.d.ts +4 -4
  217. package/script/types/1_inline_keyboard_button.js +19 -42
  218. package/script/types/1_keyboard_button.d.ts +8 -8
  219. package/script/types/1_keyboard_button.js +24 -47
  220. package/script/types/1_photo.d.ts +2 -2
  221. package/script/types/1_photo.js +4 -27
  222. package/script/types/1_poll.d.ts +8 -8
  223. package/script/types/1_poll.js +2 -2
  224. package/script/types/1_sticker.d.ts +3 -3
  225. package/script/types/1_sticker.js +6 -30
  226. package/script/types/1_user.d.ts +4 -3
  227. package/script/types/1_user.js +6 -29
  228. package/script/types/1_video.d.ts +3 -3
  229. package/script/types/1_video.js +2 -25
  230. package/script/types/1_video_note.d.ts +2 -2
  231. package/script/types/1_video_note.js +2 -25
  232. package/script/types/2_game.d.ts +3 -3
  233. package/script/types/2_game.js +6 -30
  234. package/script/types/2_inline_keyboard_markup.d.ts +2 -2
  235. package/script/types/2_inline_keyboard_markup.js +3 -26
  236. package/script/types/2_inline_query.d.ts +19 -0
  237. package/script/types/2_inline_query.js +45 -0
  238. package/script/types/2_reply_keyboard_markup.d.ts +2 -2
  239. package/script/types/2_reply_keyboard_markup.js +3 -26
  240. package/script/types/3_message.d.ts +21 -23
  241. package/script/types/3_message.js +94 -119
  242. package/script/types/4_callback_query.d.ts +14 -0
  243. package/script/types/4_callback_query.js +28 -0
  244. package/script/utilities/0_base64.js +3 -3
  245. package/script/utilities/0_crypto.js +3 -3
  246. package/script/utilities/0_queue.js +2 -2
  247. package/script/utilities/1_auth.js +5 -5
  248. package/esm/types/!0_id_color.d.ts +0 -1
  249. package/esm/types/!0_id_color.js +0 -16
  250. package/script/types/!0_id_color.d.ts +0 -1
  251. /package/esm/{deps.d.ts → 0_deps.d.ts} +0 -0
  252. /package/esm/{deps.js → 0_deps.js} +0 -0
  253. /package/script/{deps.d.ts → 0_deps.d.ts} +0 -0
  254. /package/script/{deps.js → 0_deps.js} +0 -0
@@ -1,67 +1,27 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Client = exports.ParseMode = exports.restartAuth = exports.handleMigrationError = exports.getStickerSetName = exports.getEntity = void 0;
27
- const deps_js_1 = require("../deps.js");
28
- const constants_js_1 = require("../constants.js");
29
- const _1_misc_js_1 = require("../utilities/1_misc.js");
30
- const _0_bigint_js_1 = require("../utilities/0_bigint.js");
3
+ exports.Client = exports.ParseMode = exports.restartAuth = exports.getMessageWithReply = exports.handleMigrationError = exports.getStickerSetName = exports.getEntity = void 0;
4
+ const _0_deps_js_1 = require("../0_deps.js");
5
+ const _1_utilities_js_1 = require("../1_utilities.js");
6
+ const _2_tl_js_1 = require("../2_tl.js");
7
+ const _3_storage_js_1 = require("../3_storage.js");
8
+ const _3_types_js_1 = require("../3_types.js");
9
+ const _4_constants_js_1 = require("../4_constants.js");
31
10
  const _0_utilities_js_1 = require("./0_utilities.js");
32
- const _0_control_js_1 = require("../utilities/0_control.js");
33
- const _0_queue_js_1 = require("../utilities/0_queue.js");
34
- const _0_hash_js_1 = require("../utilities/0_hash.js");
35
- const _0_tl_raw_reader_js_1 = require("../tl/0_tl_raw_reader.js");
36
- const _1_tl_object_js_1 = require("../tl/1_tl_object.js");
37
- const types = __importStar(require("../tl/2_types.js"));
38
- const _3_tl_reader_js_1 = require("../tl/3_tl_reader.js");
39
- const functions = __importStar(require("../tl/3_functions.js"));
40
- const _5_rpc_result_js_1 = require("../tl/5_rpc_result.js");
41
- const _6_message_js_1 = require("../tl/6_message.js"); // MTProto API message
42
- const _7_message_container_js_1 = require("../tl/7_message_container.js");
43
- const _0_file_id_js_1 = require("../types/!0_file_id.js");
44
- const _0_reply_keyboard_remove_js_1 = require("../types/0_reply_keyboard_remove.js");
45
- const _0_message_entity_js_1 = require("../types/0_message_entity.js");
46
- const _0_force_reply_js_1 = require("../types/0_force_reply.js");
47
- const _1_user_js_1 = require("../types/1_user.js");
48
- const _2_inline_keyboard_markup_js_1 = require("../types/2_inline_keyboard_markup.js");
49
- const _2_reply_keyboard_markup_js_1 = require("../types/2_reply_keyboard_markup.js");
50
- const _3_message_js_1 = require("../types/3_message.js"); // high-level wrapper for Telegram API's message
51
- const _1_storage_memory_js_1 = require("../storage/1_storage_memory.js");
52
11
  const _0_message_js_1 = require("./0_message.js");
53
12
  const _0_password_js_1 = require("./0_password.js");
54
13
  const _0_html_js_1 = require("./0_html.js");
55
14
  const _2_client_plain_js_1 = require("./2_client_plain.js");
56
15
  const _1_client_abstract_js_1 = require("./1_client_abstract.js");
57
- const d = (0, deps_js_1.debug)("Client");
58
- const dGap = (0, deps_js_1.debug)("Client/recoverUpdateGap");
59
- const dGapC = (0, deps_js_1.debug)("Client/recoverChannelUpdateGap");
60
- const dAuth = (0, deps_js_1.debug)("Client/authorize");
61
- const dRecv = (0, deps_js_1.debug)("Client/receiveLoop");
16
+ const d = (0, _0_deps_js_1.debug)("Client");
17
+ const dGap = (0, _0_deps_js_1.debug)("Client/recoverUpdateGap");
18
+ const dGapC = (0, _0_deps_js_1.debug)("Client/recoverChannelUpdateGap");
19
+ const dAuth = (0, _0_deps_js_1.debug)("Client/authorize");
20
+ const dRecv = (0, _0_deps_js_1.debug)("Client/receiveLoop");
62
21
  exports.getEntity = Symbol();
63
22
  exports.getStickerSetName = Symbol();
64
23
  exports.handleMigrationError = Symbol();
24
+ exports.getMessageWithReply = Symbol();
65
25
  exports.restartAuth = Symbol();
66
26
  var ParseMode;
67
27
  (function (ParseMode) {
@@ -77,7 +37,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
77
37
  * @param apiHash App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Defaults to empty string (unset).
78
38
  * @param params Other parameters.
79
39
  */
80
- constructor(storage = new _1_storage_memory_js_1.StorageMemory(), apiId = 0, apiHash = "", params) {
40
+ constructor(storage = new _3_storage_js_1.StorageMemory(), apiId = 0, apiHash = "", params) {
81
41
  super(params);
82
42
  Object.defineProperty(this, "storage", {
83
43
  enumerable: true,
@@ -107,7 +67,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
107
67
  enumerable: true,
108
68
  configurable: true,
109
69
  writable: true,
110
- value: (0, _0_bigint_js_1.getRandomBigInt)(8, true, false)
70
+ value: (0, _1_utilities_js_1.getRandomBigInt)(8, true, false)
111
71
  });
112
72
  Object.defineProperty(this, "state", {
113
73
  enumerable: true,
@@ -222,7 +182,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
222
182
  enumerable: true,
223
183
  configurable: true,
224
184
  writable: true,
225
- value: new deps_js_1.Mutex()
185
+ value: new _0_deps_js_1.Mutex()
226
186
  });
227
187
  Object.defineProperty(this, "connectionInited", {
228
188
  enumerable: true,
@@ -252,13 +212,13 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
252
212
  enumerable: true,
253
213
  configurable: true,
254
214
  writable: true,
255
- value: new _0_queue_js_1.Queue("handleUpdate")
215
+ value: new _1_utilities_js_1.Queue("handleUpdate")
256
216
  });
257
217
  Object.defineProperty(this, "processUpdatesQueue", {
258
218
  enumerable: true,
259
219
  configurable: true,
260
220
  writable: true,
261
- value: new _0_queue_js_1.Queue("processUpdates")
221
+ value: new _1_utilities_js_1.Queue("processUpdates")
262
222
  });
263
223
  Object.defineProperty(this, "handler", {
264
224
  enumerable: true,
@@ -269,12 +229,12 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
269
229
  }
270
230
  });
271
231
  this.parseMode = params?.parseMode ?? ParseMode.None;
272
- this.appVersion = params?.appVersion ?? constants_js_1.APP_VERSION;
273
- this.deviceModel = params?.deviceModel ?? constants_js_1.DEVICE_MODEL;
274
- this.langCode = params?.langCode ?? constants_js_1.LANG_CODE;
275
- this.langPack = params?.langPack ?? constants_js_1.LANG_PACK;
276
- this.systemLangCode = params?.systemLangCode ?? constants_js_1.SYSTEM_LANG_CODE;
277
- this.systemVersion = params?.systemVersion ?? constants_js_1.SYSTEM_VERSION;
232
+ this.appVersion = params?.appVersion ?? _4_constants_js_1.APP_VERSION;
233
+ this.deviceModel = params?.deviceModel ?? _4_constants_js_1.DEVICE_MODEL;
234
+ this.langCode = params?.langCode ?? _4_constants_js_1.LANG_CODE;
235
+ this.langPack = params?.langPack ?? _4_constants_js_1.LANG_PACK;
236
+ this.systemLangCode = params?.systemLangCode ?? _4_constants_js_1.SYSTEM_LANG_CODE;
237
+ this.systemVersion = params?.systemVersion ?? _4_constants_js_1.SYSTEM_VERSION;
278
238
  this.publicKeys = params?.publicKeys;
279
239
  this.autoStart = params?.autoStart ?? true;
280
240
  }
@@ -300,8 +260,8 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
300
260
  super.setDc(dc);
301
261
  }
302
262
  async setAuth(key) {
303
- const hash = await (0, _0_hash_js_1.sha1)(key);
304
- const id = (0, _0_bigint_js_1.bigIntFromBuffer)(hash.slice(-8), true, false);
263
+ const hash = await (0, _1_utilities_js_1.sha1)(key);
264
+ const id = (0, _1_utilities_js_1.bigIntFromBuffer)(hash.slice(-8), true, false);
305
265
  this.auth = { key, id };
306
266
  }
307
267
  /**
@@ -345,15 +305,15 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
345
305
  await this.storage.setDc(this.initialDc);
346
306
  }
347
307
  d("encrypted client connected");
348
- (0, _1_misc_js_1.drop)(this.receiveLoop());
349
- (0, _1_misc_js_1.drop)(this.pingLoop());
308
+ (0, _1_utilities_js_1.drop)(this.receiveLoop());
309
+ (0, _1_utilities_js_1.drop)(this.pingLoop());
350
310
  }
351
311
  finally {
352
312
  release();
353
313
  }
354
314
  }
355
315
  async fetchState(source) {
356
- const state = await this.invoke(new functions.UpdatesGetState());
316
+ const state = await this.invoke(new _2_tl_js_1.functions.UpdatesGetState());
357
317
  this.updateState = state;
358
318
  d("state fetched [%s]", source);
359
319
  }
@@ -368,7 +328,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
368
328
  d("migrated to DC%s", newDc);
369
329
  }
370
330
  else {
371
- (0, _0_control_js_1.UNREACHABLE)();
331
+ (0, _1_utilities_js_1.UNREACHABLE)();
372
332
  }
373
333
  }
374
334
  disconnect() {
@@ -377,15 +337,15 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
377
337
  }
378
338
  async initConnection() {
379
339
  if (!this.connectionInited) {
380
- await this.invoke(new functions.InitConnection({
340
+ await this.invoke(new _2_tl_js_1.functions.InitConnection({
381
341
  apiId: this.apiId,
382
342
  appVersion: this.appVersion,
383
343
  deviceModel: this.deviceModel,
384
344
  langCode: this.langCode,
385
345
  langPack: this.langPack,
386
- query: new functions.InvokeWithLayer({
387
- layer: constants_js_1.LAYER,
388
- query: new functions.HelpGetConfig(),
346
+ query: new _2_tl_js_1.functions.InvokeWithLayer({
347
+ layer: _4_constants_js_1.LAYER,
348
+ query: new _2_tl_js_1.functions.HelpGetConfig(),
389
349
  }),
390
350
  systemLangCode: this.systemLangCode,
391
351
  systemVersion: this.systemVersion,
@@ -425,15 +385,15 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
425
385
  throw new Error("apiHash not set");
426
386
  }
427
387
  if (typeof params === "undefined") {
428
- const loginType = (0, _1_misc_js_1.mustPromptOneOf)("Do you want to login as bot [b] or user [u]?", ["b", "u"]);
388
+ const loginType = (0, _1_utilities_js_1.mustPromptOneOf)("Do you want to login as bot [b] or user [u]?", ["b", "u"]);
429
389
  if (loginType == "b") {
430
- params = (0, _1_misc_js_1.mustPrompt)("Bot token:");
390
+ params = (0, _1_utilities_js_1.mustPrompt)("Bot token:");
431
391
  }
432
392
  else {
433
- params = { phone: () => (0, _1_misc_js_1.mustPrompt)("Phone number:"), code: () => (0, _1_misc_js_1.mustPrompt)("Verification code:"), password: () => (0, _1_misc_js_1.mustPrompt)("Password:") };
393
+ params = { phone: () => (0, _1_utilities_js_1.mustPrompt)("Phone number:"), code: () => (0, _1_utilities_js_1.mustPrompt)("Verification code:"), password: () => (0, _1_utilities_js_1.mustPrompt)("Password:") };
434
394
  }
435
395
  }
436
- dAuth("authorizing with %s", typeof params === "string" ? "bot token" : params instanceof types.AuthExportedAuthorization ? "exported authorization" : "AuthorizeUserParams");
396
+ dAuth("authorizing with %s", typeof params === "string" ? "bot token" : params instanceof _2_tl_js_1.types.AuthExportedAuthorization ? "exported authorization" : "AuthorizeUserParams");
437
397
  await this.initConnection();
438
398
  try {
439
399
  await this.fetchState("authorize");
@@ -442,19 +402,19 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
442
402
  return;
443
403
  }
444
404
  catch (err) {
445
- if (!(err instanceof types.RPCError) || err.errorMessage != "AUTH_KEY_UNREGISTERED") {
405
+ if (!(err instanceof _2_tl_js_1.types.RPCError) || err.errorMessage != "AUTH_KEY_UNREGISTERED") {
446
406
  throw err;
447
407
  }
448
408
  }
449
409
  if (typeof params === "string") {
450
410
  while (true) {
451
411
  try {
452
- await this.invoke(new functions.AuthImportBotAuthorization({ apiId: this.apiId, apiHash: this.apiHash, botAuthToken: params, flags: 0 }));
412
+ await this.invoke(new _2_tl_js_1.functions.AuthImportBotAuthorization({ apiId: this.apiId, apiHash: this.apiHash, botAuthToken: params, flags: 0 }));
453
413
  await this.storage.setAccountType("bot");
454
414
  break;
455
415
  }
456
416
  catch (err) {
457
- if (err instanceof types.RPCError) {
417
+ if (err instanceof _2_tl_js_1.types.RPCError) {
458
418
  const match = err.errorMessage.match(/MIGRATE_(\d)$/);
459
419
  if (match) {
460
420
  await this[exports.handleMigrationError](err);
@@ -475,8 +435,8 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
475
435
  await this.fetchState("authorize");
476
436
  return;
477
437
  }
478
- if (params instanceof types.AuthExportedAuthorization) {
479
- await this.invoke(new functions.AuthImportAuthorization({ id: params.id, bytes: params.bytes }));
438
+ if (params instanceof _2_tl_js_1.types.AuthExportedAuthorization) {
439
+ await this.invoke(new _2_tl_js_1.functions.AuthImportAuthorization({ id: params.id, bytes: params.bytes }));
480
440
  dAuth("authorization imported");
481
441
  return;
482
442
  }
@@ -485,17 +445,17 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
485
445
  while (true) {
486
446
  try {
487
447
  phone = typeof params.phone === "string" ? params.phone : await params.phone();
488
- const sendCode = () => this.invoke(new functions.AuthSendCode({
448
+ const sendCode = () => this.invoke(new _2_tl_js_1.functions.AuthSendCode({
489
449
  phoneNumber: phone,
490
450
  apiId: this.apiId,
491
451
  apiHash: this.apiHash,
492
- settings: new types.CodeSettings(),
493
- })).then((v) => v[_1_tl_object_js_1.as](types.AuthSentCode));
452
+ settings: new _2_tl_js_1.types.CodeSettings(),
453
+ })).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.AuthSentCode));
494
454
  try {
495
455
  sentCode = await sendCode();
496
456
  }
497
457
  catch (err) {
498
- if (err instanceof types.RPCError) {
458
+ if (err instanceof _2_tl_js_1.types.RPCError) {
499
459
  const match = err.errorMessage.match(/MIGRATE_(\d)$/);
500
460
  if (match) {
501
461
  await this[exports.handleMigrationError](err);
@@ -513,7 +473,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
513
473
  break;
514
474
  }
515
475
  catch (err) {
516
- if (err instanceof types.RPCError && err.errorMessage == "PHONE_NUMBER_INVALID") {
476
+ if (err instanceof _2_tl_js_1.types.RPCError && err.errorMessage == "PHONE_NUMBER_INVALID") {
517
477
  continue;
518
478
  }
519
479
  else {
@@ -526,7 +486,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
526
486
  while (true) {
527
487
  const code = typeof params.code === "string" ? params.code : await params.code();
528
488
  try {
529
- await this.invoke(new functions.AuthSignIn({
489
+ await this.invoke(new _2_tl_js_1.functions.AuthSignIn({
530
490
  phoneNumber: phone,
531
491
  phoneCode: code,
532
492
  phoneCodeHash: sentCode.phoneCodeHash,
@@ -538,7 +498,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
538
498
  return;
539
499
  }
540
500
  catch (err_) {
541
- if (err_ instanceof types.RPCError && err_.errorMessage == "PHONE_CODE_INVALID") {
501
+ if (err_ instanceof _2_tl_js_1.types.RPCError && err_.errorMessage == "PHONE_CODE_INVALID") {
542
502
  continue;
543
503
  }
544
504
  else {
@@ -547,18 +507,18 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
547
507
  }
548
508
  }
549
509
  }
550
- if (!(err instanceof types.RPCError && err.errorMessage == "SESSION_PASSWORD_NEEDED")) {
510
+ if (!(err instanceof _2_tl_js_1.types.RPCError && err.errorMessage == "SESSION_PASSWORD_NEEDED")) {
551
511
  throw err;
552
512
  }
553
513
  while (true) {
554
- const ap = await this.invoke(new functions.AccountGetPassword());
555
- if (!(ap.currentAlgo instanceof types.PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow)) {
514
+ const ap = await this.invoke(new _2_tl_js_1.functions.AccountGetPassword());
515
+ if (!(ap.currentAlgo instanceof _2_tl_js_1.types.PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow)) {
556
516
  throw new Error(`Handling ${ap.currentAlgo?.constructor.name} not implemented`);
557
517
  }
558
518
  try {
559
519
  const password = typeof params.password === "string" ? params.password : await params.password(ap.hint ?? null);
560
520
  const input = await (0, _0_password_js_1.checkPassword)(password, ap);
561
- await this.invoke(new functions.AuthCheckPassword({ password: input }));
521
+ await this.invoke(new _2_tl_js_1.functions.AuthCheckPassword({ password: input }));
562
522
  await this.storage.setAccountType("user");
563
523
  dAuth("authorized as user");
564
524
  await this.propagateAuthorizationState(true);
@@ -566,7 +526,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
566
526
  break;
567
527
  }
568
528
  catch (err) {
569
- if (err instanceof types.RPCError && err.errorMessage == "PASSWORD_HASH_INVALID") {
529
+ if (err instanceof _2_tl_js_1.types.RPCError && err.errorMessage == "PASSWORD_HASH_INVALID") {
570
530
  continue;
571
531
  }
572
532
  else {
@@ -588,7 +548,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
588
548
  return;
589
549
  }
590
550
  catch (err) {
591
- if (!(err instanceof types.RPCError) || err.errorMessage != "AUTH_KEY_UNREGISTERED") {
551
+ if (!(err instanceof _2_tl_js_1.types.RPCError) || err.errorMessage != "AUTH_KEY_UNREGISTERED") {
592
552
  throw err;
593
553
  }
594
554
  }
@@ -600,8 +560,8 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
600
560
  }
601
561
  while (this.connected) {
602
562
  try {
603
- if (this.toAcknowledge.size >= constants_js_1.ACK_THRESHOLD) {
604
- await this.send(new types.MsgsAck({ msgIds: [...this.toAcknowledge] }));
563
+ if (this.toAcknowledge.size >= _4_constants_js_1.ACK_THRESHOLD) {
564
+ await this.send(new _2_tl_js_1.types.MsgsAck({ msgIds: [...this.toAcknowledge] }));
605
565
  this.toAcknowledge.clear();
606
566
  }
607
567
  const buffer = await this.transport.transport.receive();
@@ -611,25 +571,25 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
611
571
  }
612
572
  catch (err) {
613
573
  dRecv("failed to decrypt message: %o", err);
614
- (0, _1_misc_js_1.drop)(this.recoverUpdateGap("decryption"));
574
+ (0, _1_utilities_js_1.drop)(this.recoverUpdateGap("decryption"));
615
575
  continue;
616
576
  }
617
- const messages = decrypted instanceof _7_message_container_js_1.MessageContainer ? decrypted.messages : [decrypted];
577
+ const messages = decrypted instanceof _2_tl_js_1.MessageContainer ? decrypted.messages : [decrypted];
618
578
  for (const message of messages) {
619
579
  let body = message.body;
620
- if (body instanceof types.GZIPPacked) {
621
- body = new _3_tl_reader_js_1.TLReader((0, deps_js_1.gunzip)(body.packedData)).readObject();
580
+ if (body instanceof _2_tl_js_1.types.GZIPPacked) {
581
+ body = new _2_tl_js_1.TLReader((0, _0_deps_js_1.gunzip)(body.packedData)).readObject();
622
582
  }
623
583
  dRecv("received %s", body.constructor.name);
624
- if (body instanceof types._TypeUpdates || body instanceof types._TypeUpdate) {
584
+ if (body instanceof _2_tl_js_1.types._TypeUpdates || body instanceof _2_tl_js_1.types._TypeUpdate) {
625
585
  this.processUpdatesQueue.add(() => this.processUpdates(body));
626
586
  }
627
- else if (message.body instanceof _5_rpc_result_js_1.RPCResult) {
587
+ else if (message.body instanceof _2_tl_js_1.RPCResult) {
628
588
  let result = message.body.result;
629
- if (result instanceof types.GZIPPacked) {
630
- result = new _3_tl_reader_js_1.TLReader((0, deps_js_1.gunzip)(result.packedData)).readObject();
589
+ if (result instanceof _2_tl_js_1.types.GZIPPacked) {
590
+ result = new _2_tl_js_1.TLReader((0, _0_deps_js_1.gunzip)(result.packedData)).readObject();
631
591
  }
632
- if (result instanceof types.RPCError) {
592
+ if (result instanceof _2_tl_js_1.types.RPCError) {
633
593
  dRecv("RPCResult: %d %s", result.errorCode, result.errorMessage);
634
594
  }
635
595
  else {
@@ -639,7 +599,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
639
599
  const resolvePromise = () => {
640
600
  const promise = this.promises.get(messageId);
641
601
  if (promise) {
642
- if (result instanceof types.RPCError) {
602
+ if (result instanceof _2_tl_js_1.types.RPCError) {
643
603
  promise.reject(result);
644
604
  }
645
605
  else {
@@ -648,7 +608,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
648
608
  this.promises.delete(messageId);
649
609
  }
650
610
  };
651
- if (result instanceof types._TypeUpdates || result instanceof types._TypeUpdate) {
611
+ if (result instanceof _2_tl_js_1.types._TypeUpdates || result instanceof _2_tl_js_1.types._TypeUpdate) {
652
612
  this.processUpdatesQueue.add(async () => {
653
613
  await this.processUpdates(result);
654
614
  resolvePromise();
@@ -659,14 +619,14 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
659
619
  resolvePromise();
660
620
  }
661
621
  }
662
- else if (message.body instanceof types.Pong) {
622
+ else if (message.body instanceof _2_tl_js_1.types.Pong) {
663
623
  const promise = this.promises.get(message.body.msgId);
664
624
  if (promise) {
665
625
  promise.resolve(message.body);
666
626
  this.promises.delete(message.body.msgId);
667
627
  }
668
628
  }
669
- else if (message.body instanceof types.BadServerSalt) {
629
+ else if (message.body instanceof _2_tl_js_1.types.BadServerSalt) {
670
630
  d("server salt reassigned");
671
631
  this.state.salt = message.body.newServerSalt;
672
632
  const promise = this.promises.get(message.body.badMsgId);
@@ -682,9 +642,9 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
682
642
  if (!this.connected) {
683
643
  break;
684
644
  }
685
- else if (err instanceof _0_tl_raw_reader_js_1.TLError) {
645
+ else if (err instanceof _2_tl_js_1.TLError) {
686
646
  dRecv("failed to deserialize: %o", err);
687
- (0, _1_misc_js_1.drop)(this.recoverUpdateGap("deserialize"));
647
+ (0, _1_utilities_js_1.drop)(this.recoverUpdateGap("deserialize"));
688
648
  }
689
649
  else {
690
650
  throw err;
@@ -695,7 +655,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
695
655
  async pingLoop() {
696
656
  while (this.connected) {
697
657
  try {
698
- await this.invoke(new functions.Ping({ pingId: (0, _0_bigint_js_1.getRandomBigInt)(8, true, false) }));
658
+ await this.invoke(new _2_tl_js_1.functions.Ping({ pingId: (0, _1_utilities_js_1.getRandomBigInt)(8, true, false) }));
699
659
  }
700
660
  catch (err) {
701
661
  d("ping loop error: %o", err);
@@ -713,15 +673,15 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
713
673
  }
714
674
  }
715
675
  if (!this.auth || !this.transport) {
716
- (0, _0_control_js_1.UNREACHABLE)();
676
+ (0, _1_utilities_js_1.UNREACHABLE)();
717
677
  }
718
678
  let seqNo = this.state.seqNo * 2;
719
- if (!(function_ instanceof functions.Ping) && !(function_ instanceof types.MsgsAck)) {
679
+ if (!(function_ instanceof _2_tl_js_1.functions.Ping) && !(function_ instanceof _2_tl_js_1.types.MsgsAck)) {
720
680
  seqNo++;
721
681
  this.state.seqNo++;
722
682
  }
723
683
  const messageId = this.lastMsgId = (0, _0_message_js_1.getMessageId)(this.lastMsgId);
724
- const message = new _6_message_js_1.Message(messageId, seqNo, function_);
684
+ const message = new _2_tl_js_1.Message(messageId, seqNo, function_);
725
685
  await this.transport.transport.send(await (0, _0_message_js_1.encryptMessage)(message, this.auth.key, this.auth.id, this.state.salt, this.sessionId));
726
686
  d("invoked %s", function_.constructor.name);
727
687
  if (noWait) {
@@ -734,12 +694,12 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
734
694
  });
735
695
  }
736
696
  catch (err) {
737
- if (err instanceof types.RPCError && err.errorMessage == "AUTH_KEY_UNREGISTERED") {
697
+ if (err instanceof _2_tl_js_1.types.RPCError && err.errorMessage == "AUTH_KEY_UNREGISTERED") {
738
698
  await this.propagateAuthorizationState(false);
739
699
  }
740
700
  throw err;
741
701
  }
742
- if (result instanceof types.BadServerSalt) {
702
+ if (result instanceof _2_tl_js_1.types.BadServerSalt) {
743
703
  return await this.invoke(function_);
744
704
  }
745
705
  else {
@@ -754,7 +714,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
754
714
  }
755
715
  async processChats(chats) {
756
716
  for (const chat of chats) {
757
- if (chat instanceof types.Channel && chat.accessHash) {
717
+ if (chat instanceof _2_tl_js_1.types.Channel && chat.accessHash) {
758
718
  await this.storage.setEntity(chat);
759
719
  await this.storage.setChannelAccessHash(chat.id, chat.accessHash);
760
720
  if (chat.username) {
@@ -764,14 +724,14 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
764
724
  await this.storage.updateUsernames("channel", chat.id, chat.usernames.map((v) => v.username));
765
725
  }
766
726
  }
767
- else if (chat instanceof types.Chat) {
727
+ else if (chat instanceof _2_tl_js_1.types.Chat) {
768
728
  await this.storage.setEntity(chat);
769
729
  }
770
730
  }
771
731
  }
772
732
  async processUsers(users) {
773
733
  for (const user of users) {
774
- if (user instanceof types.User && user.accessHash) {
734
+ if (user instanceof _2_tl_js_1.types.User && user.accessHash) {
775
735
  await this.storage.setEntity(user);
776
736
  await this.storage.setUserAccessHash(user.id, user.accessHash);
777
737
  if (user.username) {
@@ -787,7 +747,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
787
747
  const localState = await this.getLocalState();
788
748
  if (localState.pts + ptsCount < pts) {
789
749
  if (assertNoGap) {
790
- (0, _0_control_js_1.UNREACHABLE)();
750
+ (0, _1_utilities_js_1.UNREACHABLE)();
791
751
  }
792
752
  else {
793
753
  await this.recoverUpdateGap("processUpdates");
@@ -801,7 +761,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
801
761
  }
802
762
  if (localPts + ptsCount < pts) {
803
763
  if (assertNoGap) {
804
- (0, _0_control_js_1.UNREACHABLE)();
764
+ (0, _1_utilities_js_1.UNREACHABLE)();
805
765
  }
806
766
  else {
807
767
  await this.recoverChannelUpdateGap(channelId, "processUpdates");
@@ -817,26 +777,26 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
817
777
  /// [2]: https://core.telegram.org/type/Updates
818
778
  /// [3]: https://core.telegram.org/constructor/updatesTooLong
819
779
  let updates;
820
- if (updates_ instanceof types.UpdatesCombined || updates_ instanceof types.Updates) {
780
+ if (updates_ instanceof _2_tl_js_1.types.UpdatesCombined || updates_ instanceof _2_tl_js_1.types.Updates) {
821
781
  updates = updates_.updates;
822
782
  }
823
- else if (updates_ instanceof types.UpdateShort) {
783
+ else if (updates_ instanceof _2_tl_js_1.types.UpdateShort) {
824
784
  updates = [updates_.update];
825
785
  }
826
- else if (updates_ instanceof types.UpdateShortMessage ||
827
- updates_ instanceof types.UpdateShortChatMessage ||
828
- updates_ instanceof types.UpdateShortSentMessage) {
786
+ else if (updates_ instanceof _2_tl_js_1.types.UpdateShortMessage ||
787
+ updates_ instanceof _2_tl_js_1.types.UpdateShortChatMessage ||
788
+ updates_ instanceof _2_tl_js_1.types.UpdateShortSentMessage) {
829
789
  updates = [updates_];
830
790
  }
831
- else if (updates_ instanceof types.UpdatesTooLong) {
791
+ else if (updates_ instanceof _2_tl_js_1.types.UpdatesTooLong) {
832
792
  await this.recoverUpdateGap("updatesTooLong");
833
793
  return;
834
794
  }
835
- else if (updates_ instanceof types._TypeUpdate) {
795
+ else if (updates_ instanceof _2_tl_js_1.types._TypeUpdate) {
836
796
  updates = [updates_];
837
797
  }
838
798
  else {
839
- (0, _0_control_js_1.UNREACHABLE)();
799
+ (0, _1_utilities_js_1.UNREACHABLE)();
840
800
  }
841
801
  /// Then, we go through each Update and updateShort*, and see if they are order-sensitive.
842
802
  /// If they were, we check the local state to see if it is OK to process them right away.
@@ -846,7 +806,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
846
806
  let originalPts = null;
847
807
  const channelPtsMap = new Map();
848
808
  for (const update of updates) {
849
- if ((0, _0_utilities_js_1.hasPts)(update)) {
809
+ if ((0, _0_utilities_js_1.isPtsUpdate)(update)) {
850
810
  if (update.pts == 0) {
851
811
  continue;
852
812
  }
@@ -860,12 +820,12 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
860
820
  localState.pts = update.pts;
861
821
  }
862
822
  }
863
- else if ((0, _0_utilities_js_1.hasChannelPts)(update)) {
823
+ else if ((0, _0_utilities_js_1.isChannelPtsUpdate)(update)) {
864
824
  if (update.pts == 0) {
865
825
  continue;
866
826
  }
867
827
  const ptsCount = "ptsCount" in update ? update.ptsCount : 1;
868
- const channelId = update instanceof types.UpdateNewChannelMessage || update instanceof types.UpdateEditChannelMessage ? update.message.peerId[_1_tl_object_js_1.as](types.PeerChannel).channelId : update.channelId;
828
+ const channelId = update instanceof _2_tl_js_1.types.UpdateNewChannelMessage || update instanceof _2_tl_js_1.types.UpdateEditChannelMessage ? update.message.peerId[_2_tl_js_1.as](_2_tl_js_1.types.PeerChannel).channelId : update.channelId;
869
829
  await this.checkChannelGap(channelId, update.pts, ptsCount, assertNoGap);
870
830
  let currentPts = channelPtsMap.get(channelId);
871
831
  if (currentPts === undefined) {
@@ -889,41 +849,41 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
889
849
  }
890
850
  }
891
851
  /// We process the updates when we are sure there is no gap.
892
- if (updates_ instanceof types.Updates || updates_ instanceof types.UpdatesCombined) {
852
+ if (updates_ instanceof _2_tl_js_1.types.Updates || updates_ instanceof _2_tl_js_1.types.UpdatesCombined) {
893
853
  await this.processChats(updates_.chats);
894
854
  await this.processUsers(updates_.users);
895
855
  await this.setUpdateStateDate(updates_.date);
896
856
  }
897
- else if (updates_ instanceof types.UpdateShort) {
857
+ else if (updates_ instanceof _2_tl_js_1.types.UpdateShort) {
898
858
  await this.setUpdateStateDate(updates_.date);
899
859
  }
900
860
  const updatesToHandle = new Array();
901
861
  for (const update of updates) {
902
- if (update instanceof types.UpdateShortMessage ||
903
- update instanceof types.UpdateShortChatMessage ||
904
- update instanceof types.UpdateShortSentMessage) {
862
+ if (update instanceof _2_tl_js_1.types.UpdateShortMessage ||
863
+ update instanceof _2_tl_js_1.types.UpdateShortChatMessage ||
864
+ update instanceof _2_tl_js_1.types.UpdateShortSentMessage) {
905
865
  await this.setUpdateStateDate(update.date);
906
866
  }
907
- else if (update instanceof types.UpdateChannelTooLong) {
867
+ else if (update instanceof _2_tl_js_1.types.UpdateChannelTooLong) {
908
868
  if (update.pts != undefined) {
909
869
  await this.storage.setChannelPts(update.channelId, update.pts);
910
870
  }
911
871
  await this.recoverChannelUpdateGap(update.channelId, "updateChannelTooLong");
912
872
  }
913
- else if (update instanceof types.UpdateUserName) {
873
+ else if (update instanceof _2_tl_js_1.types.UpdateUserName) {
914
874
  await this.storage.updateUsernames("user", update.userId, update.usernames.map((v) => v.username));
915
875
  }
916
- else if (update instanceof types.UpdatePtsChanged) {
876
+ else if (update instanceof _2_tl_js_1.types.UpdatePtsChanged) {
917
877
  await this.fetchState("updatePtsChanged");
918
878
  if (this.updateState) {
919
879
  await this.storage.setState(this.updateState);
920
880
  }
921
881
  else {
922
- (0, _0_control_js_1.UNREACHABLE)();
882
+ (0, _1_utilities_js_1.UNREACHABLE)();
923
883
  }
924
884
  }
925
885
  /// If there were any Update, they will be passed to the update handling queue.
926
- if (update instanceof types._TypeUpdate) {
886
+ if (update instanceof _2_tl_js_1.types._TypeUpdate) {
927
887
  updatesToHandle.push(update);
928
888
  }
929
889
  }
@@ -952,7 +912,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
952
912
  await this.storage.setState(localState);
953
913
  }
954
914
  else {
955
- (0, _0_control_js_1.UNREACHABLE)();
915
+ (0, _1_utilities_js_1.UNREACHABLE)();
956
916
  }
957
917
  }
958
918
  }
@@ -964,41 +924,41 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
964
924
  try {
965
925
  let state = await this.getLocalState();
966
926
  while (true) {
967
- const difference = await this.invoke(new functions.UpdatesGetDifference({ pts: state.pts, date: state.date, qts: state.qts ?? 0 }));
968
- if (difference instanceof types.UpdatesDifference || difference instanceof types.UpdatesDifferenceSlice) {
927
+ const difference = await this.invoke(new _2_tl_js_1.functions.UpdatesGetDifference({ pts: state.pts, date: state.date, qts: state.qts ?? 0 }));
928
+ if (difference instanceof _2_tl_js_1.types.UpdatesDifference || difference instanceof _2_tl_js_1.types.UpdatesDifferenceSlice) {
969
929
  await this.processChats(difference.chats);
970
930
  await this.processUsers(difference.users);
971
931
  for (const message of difference.newMessages) {
972
- await this.processUpdates(new types.UpdateNewMessage({ message, pts: 0, ptsCount: 0 }), true);
932
+ await this.processUpdates(new _2_tl_js_1.types.UpdateNewMessage({ message, pts: 0, ptsCount: 0 }), true);
973
933
  }
974
934
  for (const update of difference.otherUpdates) {
975
935
  await this.processUpdates(update, true);
976
936
  }
977
- if (difference instanceof types.UpdatesDifference) {
937
+ if (difference instanceof _2_tl_js_1.types.UpdatesDifference) {
978
938
  await this.storage.setState(difference.state);
979
939
  dGap("recovered from update gap");
980
940
  break;
981
941
  }
982
- else if (difference instanceof types.UpdatesDifferenceSlice) {
942
+ else if (difference instanceof _2_tl_js_1.types.UpdatesDifferenceSlice) {
983
943
  state = difference.intermediateState;
984
944
  }
985
945
  else {
986
- (0, _0_control_js_1.UNREACHABLE)();
946
+ (0, _1_utilities_js_1.UNREACHABLE)();
987
947
  }
988
948
  }
989
- else if (difference instanceof types.UpdatesDifferenceTooLong) {
949
+ else if (difference instanceof _2_tl_js_1.types.UpdatesDifferenceTooLong) {
990
950
  // TODO: we actually do now
991
951
  // stored messages should be invalidated in case we store messages in the future
992
952
  state.pts = difference.pts;
993
953
  dGap("received differenceTooLong");
994
954
  }
995
- else if (difference instanceof types.UpdatesDifferenceEmpty) {
955
+ else if (difference instanceof _2_tl_js_1.types.UpdatesDifferenceEmpty) {
996
956
  await this.setUpdateStateDate(difference.date);
997
957
  dGap("there was no update gap");
998
958
  break;
999
959
  }
1000
960
  else {
1001
- (0, _0_control_js_1.UNREACHABLE)();
961
+ (0, _1_utilities_js_1.UNREACHABLE)();
1002
962
  }
1003
963
  }
1004
964
  }
@@ -1011,18 +971,18 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1011
971
  const pts_ = await this.storage.getChannelPts(channelId);
1012
972
  let pts = pts_ == null ? 1 : pts_;
1013
973
  while (true) {
1014
- const { accessHash } = await this.getInputPeer(constants_js_1.ZERO_CHANNEL_ID + -Number(channelId)).then((v) => v[_1_tl_object_js_1.as](types.InputPeerChannel));
1015
- const difference = await this.invoke(new functions.UpdatesGetChannelDifference({
974
+ const { accessHash } = await this.getInputPeer(_4_constants_js_1.ZERO_CHANNEL_ID + -Number(channelId)).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.InputPeerChannel));
975
+ const difference = await this.invoke(new _2_tl_js_1.functions.UpdatesGetChannelDifference({
1016
976
  pts,
1017
- channel: new types.InputChannel({ channelId, accessHash: accessHash }),
1018
- filter: new types.ChannelMessagesFilterEmpty(),
1019
- limit: await this.storage.getAccountType() == "user" ? constants_js_1.CHANNEL_DIFFERENCE_LIMIT_USER : constants_js_1.CHANNEL_DIFFERENCE_LIMIT_BOT,
977
+ channel: new _2_tl_js_1.types.InputChannel({ channelId, accessHash: accessHash }),
978
+ filter: new _2_tl_js_1.types.ChannelMessagesFilterEmpty(),
979
+ limit: await this.storage.getAccountType() == "user" ? _4_constants_js_1.CHANNEL_DIFFERENCE_LIMIT_USER : _4_constants_js_1.CHANNEL_DIFFERENCE_LIMIT_BOT,
1020
980
  }));
1021
- if (difference instanceof types.UpdatesChannelDifference) {
981
+ if (difference instanceof _2_tl_js_1.types.UpdatesChannelDifference) {
1022
982
  await this.processChats(difference.chats);
1023
983
  await this.processUsers(difference.users);
1024
984
  for (const message of difference.newMessages) {
1025
- await this.processUpdates(new types.UpdateNewChannelMessage({ message, pts: 0, ptsCount: 0 }), true);
985
+ await this.processUpdates(new _2_tl_js_1.types.UpdateNewChannelMessage({ message, pts: 0, ptsCount: 0 }), true);
1026
986
  }
1027
987
  for (const update of difference.otherUpdates) {
1028
988
  await this.processUpdates(update, true);
@@ -1031,40 +991,40 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1031
991
  dGapC("recovered from update gap [%o, %s]", channelId, source);
1032
992
  break;
1033
993
  }
1034
- else if (difference instanceof types.UpdatesChannelDifferenceTooLong) {
994
+ else if (difference instanceof _2_tl_js_1.types.UpdatesChannelDifferenceTooLong) {
1035
995
  // invalidate messages
1036
996
  dGapC("received channelDifferenceTooLong");
1037
997
  await this.processChats(difference.chats);
1038
998
  await this.processUsers(difference.users);
1039
999
  for (const message of difference.messages) {
1040
- await this.processUpdates(new types.UpdateNewChannelMessage({ message, pts: 0, ptsCount: 0 }), true);
1000
+ await this.processUpdates(new _2_tl_js_1.types.UpdateNewChannelMessage({ message, pts: 0, ptsCount: 0 }), true);
1041
1001
  }
1042
- const pts_ = difference.dialog[_1_tl_object_js_1.as](types.Dialog).pts;
1002
+ const pts_ = difference.dialog[_2_tl_js_1.as](_2_tl_js_1.types.Dialog).pts;
1043
1003
  if (pts_ != undefined) {
1044
1004
  pts = pts_;
1045
1005
  }
1046
1006
  else {
1047
- (0, _0_control_js_1.UNREACHABLE)();
1007
+ (0, _1_utilities_js_1.UNREACHABLE)();
1048
1008
  }
1049
1009
  dGapC("processed channelDifferenceTooLong");
1050
1010
  }
1051
- else if (difference instanceof types.UpdatesChannelDifferenceEmpty) {
1011
+ else if (difference instanceof _2_tl_js_1.types.UpdatesChannelDifferenceEmpty) {
1052
1012
  dGapC("there was no update gap");
1053
1013
  break;
1054
1014
  }
1055
1015
  }
1056
1016
  }
1057
1017
  async getUserAccessHash(userId) {
1058
- const users = await this.invoke(new functions.UsersGetUsers({ id: [new types.InputUser({ userId, accessHash: 0n })] }));
1059
- return users[0][_1_tl_object_js_1.as](types.User).accessHash ?? 0n;
1018
+ const users = await this.invoke(new _2_tl_js_1.functions.UsersGetUsers({ id: [new _2_tl_js_1.types.InputUser({ userId, accessHash: 0n })] }));
1019
+ return users[0][_2_tl_js_1.as](_2_tl_js_1.types.User).accessHash ?? 0n;
1060
1020
  }
1061
1021
  async getChannelAccessHash(channelId) {
1062
- const channels = await this.invoke(new functions.ChannelsGetChannels({ id: [new types.InputChannel({ channelId, accessHash: 0n })] }));
1063
- return channels.chats[0][_1_tl_object_js_1.as](types.Channel).accessHash ?? 0n;
1022
+ const channels = await this.invoke(new _2_tl_js_1.functions.ChannelsGetChannels({ id: [new _2_tl_js_1.types.InputChannel({ channelId, accessHash: 0n })] }));
1023
+ return channels.chats[0][_2_tl_js_1.as](_2_tl_js_1.types.Channel).accessHash ?? 0n;
1064
1024
  }
1065
1025
  async getInputPeer(id) {
1066
1026
  const inputPeer = await this.getInputPeerInner(id);
1067
- if (inputPeer instanceof types.InputPeerUser || inputPeer instanceof types.InputPeerChannel && inputPeer.accessHash == 0n && await this.storage.getAccountType() == "bot") {
1027
+ if (inputPeer instanceof _2_tl_js_1.types.InputPeerUser || inputPeer instanceof _2_tl_js_1.types.InputPeerChannel && inputPeer.accessHash == 0n && await this.storage.getAccountType() == "bot") {
1068
1028
  if ("channelId" in inputPeer) {
1069
1029
  inputPeer.accessHash = await this.getChannelAccessHash(inputPeer.channelId);
1070
1030
  }
@@ -1088,7 +1048,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1088
1048
  let userId = 0n;
1089
1049
  let channelId = 0n;
1090
1050
  const maybeUsername = await this.storage.getUsername(id);
1091
- if (maybeUsername != null && Date.now() - maybeUsername[2].getTime() < constants_js_1.USERNAME_TTL) {
1051
+ if (maybeUsername != null && Date.now() - maybeUsername[2].getTime() < _4_constants_js_1.USERNAME_TTL) {
1092
1052
  const [type, id] = maybeUsername;
1093
1053
  if (type == "user") {
1094
1054
  userId = id;
@@ -1098,117 +1058,117 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1098
1058
  }
1099
1059
  }
1100
1060
  else {
1101
- const resolved = await this.invoke(new functions.ContactsResolveUsername({ username: id }));
1061
+ const resolved = await this.invoke(new _2_tl_js_1.functions.ContactsResolveUsername({ username: id }));
1102
1062
  await this.processChats(resolved.chats);
1103
1063
  await this.processUsers(resolved.users);
1104
- if (resolved.peer instanceof types.PeerUser) {
1064
+ if (resolved.peer instanceof _2_tl_js_1.types.PeerUser) {
1105
1065
  userId = resolved.peer.userId;
1106
1066
  }
1107
- else if (resolved.peer instanceof types.PeerChannel) {
1067
+ else if (resolved.peer instanceof _2_tl_js_1.types.PeerChannel) {
1108
1068
  channelId = resolved.peer.channelId;
1109
1069
  }
1110
1070
  else {
1111
- (0, _0_control_js_1.UNREACHABLE)();
1071
+ (0, _1_utilities_js_1.UNREACHABLE)();
1112
1072
  }
1113
1073
  }
1114
1074
  if (userId) {
1115
1075
  const accessHash = await this.storage.getUserAccessHash(userId);
1116
- return new types.InputPeerUser({ userId, accessHash: accessHash ?? 0n });
1076
+ return new _2_tl_js_1.types.InputPeerUser({ userId, accessHash: accessHash ?? 0n });
1117
1077
  }
1118
1078
  else if (channelId) {
1119
1079
  const accessHash = await this.storage.getChannelAccessHash(channelId);
1120
- return new types.InputPeerChannel({ channelId, accessHash: accessHash ?? 0n });
1080
+ return new _2_tl_js_1.types.InputPeerChannel({ channelId, accessHash: accessHash ?? 0n });
1121
1081
  }
1122
1082
  else {
1123
- (0, _0_control_js_1.UNREACHABLE)();
1083
+ (0, _1_utilities_js_1.UNREACHABLE)();
1124
1084
  }
1125
1085
  }
1126
1086
  }
1127
1087
  else if (id > 0) {
1128
1088
  const id_ = BigInt(id);
1129
1089
  const accessHash = await this.storage.getUserAccessHash(id_);
1130
- return new types.InputPeerUser({ userId: id_, accessHash: accessHash ?? 0n });
1090
+ return new _2_tl_js_1.types.InputPeerUser({ userId: id_, accessHash: accessHash ?? 0n });
1131
1091
  }
1132
- else if (-constants_js_1.MAX_CHAT_ID <= id) {
1133
- return new types.InputPeerChat({ chatId: BigInt(Math.abs(id)) });
1092
+ else if (-_4_constants_js_1.MAX_CHAT_ID <= id) {
1093
+ return new _2_tl_js_1.types.InputPeerChat({ chatId: BigInt(Math.abs(id)) });
1134
1094
  }
1135
- else if (constants_js_1.ZERO_CHANNEL_ID - constants_js_1.MAX_CHANNEL_ID <= id && id != constants_js_1.ZERO_CHANNEL_ID) {
1136
- const id_ = BigInt(Math.abs(id - constants_js_1.ZERO_CHANNEL_ID));
1095
+ else if (_4_constants_js_1.ZERO_CHANNEL_ID - _4_constants_js_1.MAX_CHANNEL_ID <= id && id != _4_constants_js_1.ZERO_CHANNEL_ID) {
1096
+ const id_ = BigInt(Math.abs(id - _4_constants_js_1.ZERO_CHANNEL_ID));
1137
1097
  const accessHash = await this.storage.getChannelAccessHash(id_);
1138
- return new types.InputPeerChannel({ channelId: id_, accessHash: accessHash ?? 0n });
1098
+ return new _2_tl_js_1.types.InputPeerChannel({ channelId: id_, accessHash: accessHash ?? 0n });
1139
1099
  }
1140
1100
  else {
1141
1101
  throw new Error("ID format unknown or not implemented");
1142
1102
  }
1143
1103
  }
1144
1104
  [exports.getEntity](peer) {
1145
- const type = peer instanceof types.PeerUser ? "user" : peer instanceof types.PeerChat ? "chat" : peer instanceof types.PeerChannel ? "channel" : (0, _0_control_js_1.UNREACHABLE)();
1146
- const id = peer instanceof types.PeerUser ? peer.userId : peer instanceof types.PeerChat ? peer.chatId : peer instanceof types.PeerChannel ? peer.channelId : (0, _0_control_js_1.UNREACHABLE)();
1105
+ const type = peer instanceof _2_tl_js_1.types.PeerUser ? "user" : peer instanceof _2_tl_js_1.types.PeerChat ? "chat" : peer instanceof _2_tl_js_1.types.PeerChannel ? "channel" : (0, _1_utilities_js_1.UNREACHABLE)();
1106
+ const id = peer instanceof _2_tl_js_1.types.PeerUser ? peer.userId : peer instanceof _2_tl_js_1.types.PeerChat ? peer.chatId : peer instanceof _2_tl_js_1.types.PeerChannel ? peer.channelId : (0, _1_utilities_js_1.UNREACHABLE)();
1147
1107
  return this.storage.getEntity(type, id);
1148
1108
  }
1149
1109
  async processResult(result) {
1150
- if (result instanceof types.MessagesDialogs ||
1151
- result instanceof types.MessagesDialogsSlice ||
1152
- result instanceof types.MessagesMessages ||
1153
- result instanceof types.MessagesMessagesSlice ||
1154
- result instanceof types.MessagesChannelMessages ||
1155
- result instanceof types.MessagesChatFull ||
1156
- result instanceof types.ContactsFound ||
1157
- result instanceof types.AccountPrivacyRules ||
1158
- result instanceof types.ContactsResolvedPeer ||
1159
- result instanceof types.ChannelsChannelParticipants ||
1160
- result instanceof types.ChannelsChannelParticipant ||
1161
- result instanceof types.MessagesPeerDialogs ||
1162
- result instanceof types.ContactsTopPeers ||
1163
- result instanceof types.ChannelsAdminLogResults ||
1164
- result instanceof types.HelpRecentMeURLs ||
1165
- result instanceof types.MessagesInactiveChats ||
1166
- result instanceof types.HelpPromoData ||
1167
- result instanceof types.MessagesMessageViews ||
1168
- result instanceof types.MessagesDiscussionMessage ||
1169
- result instanceof types.PhoneGroupCall ||
1170
- result instanceof types.PhoneGroupParticipants ||
1171
- result instanceof types.PhoneJoinAsPeers ||
1172
- result instanceof types.MessagesSponsoredMessages ||
1173
- result instanceof types.MessagesSearchResultsCalendar ||
1174
- result instanceof types.ChannelsSendAsPeers ||
1175
- result instanceof types.UsersUserFull ||
1176
- result instanceof types.MessagesPeerSettings ||
1177
- result instanceof types.MessagesMessageReactionsList ||
1178
- result instanceof types.MessagesForumTopics ||
1179
- result instanceof types.AccountAutoSaveSettings ||
1180
- result instanceof types.ChatlistsExportedInvites ||
1181
- result instanceof types.ChatlistsChatlistInviteAlready ||
1182
- result instanceof types.ChatlistsChatlistInvite ||
1183
- result instanceof types.ChatlistsChatlistUpdates ||
1184
- result instanceof types.MessagesChats ||
1185
- result instanceof types.MessagesChatsSlice) {
1110
+ if (result instanceof _2_tl_js_1.types.MessagesDialogs ||
1111
+ result instanceof _2_tl_js_1.types.MessagesDialogsSlice ||
1112
+ result instanceof _2_tl_js_1.types.MessagesMessages ||
1113
+ result instanceof _2_tl_js_1.types.MessagesMessagesSlice ||
1114
+ result instanceof _2_tl_js_1.types.MessagesChannelMessages ||
1115
+ result instanceof _2_tl_js_1.types.MessagesChatFull ||
1116
+ result instanceof _2_tl_js_1.types.ContactsFound ||
1117
+ result instanceof _2_tl_js_1.types.AccountPrivacyRules ||
1118
+ result instanceof _2_tl_js_1.types.ContactsResolvedPeer ||
1119
+ result instanceof _2_tl_js_1.types.ChannelsChannelParticipants ||
1120
+ result instanceof _2_tl_js_1.types.ChannelsChannelParticipant ||
1121
+ result instanceof _2_tl_js_1.types.MessagesPeerDialogs ||
1122
+ result instanceof _2_tl_js_1.types.ContactsTopPeers ||
1123
+ result instanceof _2_tl_js_1.types.ChannelsAdminLogResults ||
1124
+ result instanceof _2_tl_js_1.types.HelpRecentMeURLs ||
1125
+ result instanceof _2_tl_js_1.types.MessagesInactiveChats ||
1126
+ result instanceof _2_tl_js_1.types.HelpPromoData ||
1127
+ result instanceof _2_tl_js_1.types.MessagesMessageViews ||
1128
+ result instanceof _2_tl_js_1.types.MessagesDiscussionMessage ||
1129
+ result instanceof _2_tl_js_1.types.PhoneGroupCall ||
1130
+ result instanceof _2_tl_js_1.types.PhoneGroupParticipants ||
1131
+ result instanceof _2_tl_js_1.types.PhoneJoinAsPeers ||
1132
+ result instanceof _2_tl_js_1.types.MessagesSponsoredMessages ||
1133
+ result instanceof _2_tl_js_1.types.MessagesSearchResultsCalendar ||
1134
+ result instanceof _2_tl_js_1.types.ChannelsSendAsPeers ||
1135
+ result instanceof _2_tl_js_1.types.UsersUserFull ||
1136
+ result instanceof _2_tl_js_1.types.MessagesPeerSettings ||
1137
+ result instanceof _2_tl_js_1.types.MessagesMessageReactionsList ||
1138
+ result instanceof _2_tl_js_1.types.MessagesForumTopics ||
1139
+ result instanceof _2_tl_js_1.types.AccountAutoSaveSettings ||
1140
+ result instanceof _2_tl_js_1.types.ChatlistsExportedInvites ||
1141
+ result instanceof _2_tl_js_1.types.ChatlistsChatlistInviteAlready ||
1142
+ result instanceof _2_tl_js_1.types.ChatlistsChatlistInvite ||
1143
+ result instanceof _2_tl_js_1.types.ChatlistsChatlistUpdates ||
1144
+ result instanceof _2_tl_js_1.types.MessagesChats ||
1145
+ result instanceof _2_tl_js_1.types.MessagesChatsSlice) {
1186
1146
  await this.processChats(result.chats);
1187
1147
  if ("users" in result) {
1188
1148
  await this.processUsers(result.users);
1189
1149
  }
1190
1150
  }
1191
- if (result instanceof types.MessagesMessages) {
1151
+ if (result instanceof _2_tl_js_1.types.MessagesMessages) {
1192
1152
  for (const message of result.messages) {
1193
- if (message instanceof types.Message || message instanceof types.MessageService) {
1194
- await this.storage.setMessage((0, _0_utilities_js_1.peerToChatId)(message.peerId), message.id, message);
1153
+ if (message instanceof _2_tl_js_1.types.Message || message instanceof _2_tl_js_1.types.MessageService) {
1154
+ await this.storage.setMessage((0, _2_tl_js_1.peerToChatId)(message.peerId), message.id, message);
1195
1155
  }
1196
1156
  }
1197
1157
  }
1198
1158
  }
1199
1159
  async updatesToMessages(chatId, updates) {
1200
1160
  const messages = new Array();
1201
- if (updates instanceof types.Updates) {
1161
+ if (updates instanceof _2_tl_js_1.types.Updates) {
1202
1162
  for (const update of updates.updates) {
1203
- if (update instanceof types.UpdateNewMessage) {
1204
- messages.push(await (0, _3_message_js_1.constructMessage)(update.message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this)));
1163
+ if (update instanceof _2_tl_js_1.types.UpdateNewMessage) {
1164
+ messages.push(await (0, _3_types_js_1.constructMessage)(update.message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this)));
1205
1165
  }
1206
- else if (update instanceof types.UpdateNewChannelMessage) {
1207
- messages.push(await (0, _3_message_js_1.constructMessage)(update.message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this)));
1166
+ else if (update instanceof _2_tl_js_1.types.UpdateNewChannelMessage) {
1167
+ messages.push(await (0, _3_types_js_1.constructMessage)(update.message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this)));
1208
1168
  }
1209
1169
  }
1210
1170
  }
1211
- else if (updates instanceof types.UpdateShortSentMessage || updates instanceof types.UpdateShortSentMessage) {
1171
+ else if (updates instanceof _2_tl_js_1.types.UpdateShortSentMessage || updates instanceof _2_tl_js_1.types.UpdateShortSentMessage) {
1212
1172
  const message = await this.getMessage(chatId, updates.id);
1213
1173
  if (message != null) {
1214
1174
  messages.push(message);
@@ -1239,26 +1199,26 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1239
1199
  let replyMarkup = undefined;
1240
1200
  if (params?.replyMarkup) {
1241
1201
  if ("inlineKeyboard" in params.replyMarkup) {
1242
- replyMarkup = await (0, _2_inline_keyboard_markup_js_1.inlineKeyboardMarkupToTlObject)(params.replyMarkup, async (v) => {
1243
- const inputPeer = await this.getInputPeer(v).then((v) => v[_1_tl_object_js_1.as](types.InputPeerUser));
1244
- return new types.InputUser({ userId: inputPeer.userId, accessHash: inputPeer.accessHash });
1202
+ replyMarkup = await (0, _3_types_js_1.inlineKeyboardMarkupToTlObject)(params.replyMarkup, async (v) => {
1203
+ const inputPeer = await this.getInputPeer(v).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.InputPeerUser));
1204
+ return new _2_tl_js_1.types.InputUser({ userId: inputPeer.userId, accessHash: inputPeer.accessHash });
1245
1205
  });
1246
1206
  }
1247
1207
  else if ("keyboard" in params.replyMarkup) {
1248
- replyMarkup = (0, _2_reply_keyboard_markup_js_1.replyKeyboardMarkupToTlObject)(params.replyMarkup);
1208
+ replyMarkup = (0, _3_types_js_1.replyKeyboardMarkupToTlObject)(params.replyMarkup);
1249
1209
  }
1250
1210
  else if ("removeKeyboard" in params.replyMarkup) {
1251
- replyMarkup = (0, _0_reply_keyboard_remove_js_1.replyKeyboardRemoveToTlObject)(params.replyMarkup);
1211
+ replyMarkup = (0, _3_types_js_1.replyKeyboardRemoveToTlObject)(params.replyMarkup);
1252
1212
  }
1253
1213
  else if ("forceReply" in params.replyMarkup) {
1254
- replyMarkup = (0, _0_force_reply_js_1.forceReplyToTlObject)(params.replyMarkup);
1214
+ replyMarkup = (0, _3_types_js_1.forceReplyToTlObject)(params.replyMarkup);
1255
1215
  }
1256
1216
  else {
1257
1217
  throw new Error("The replyMarkup parameter has an unexpected type");
1258
1218
  }
1259
1219
  }
1260
1220
  const peer = await this.getInputPeer(chatId);
1261
- const randomId = (0, _0_bigint_js_1.getRandomId)();
1221
+ const randomId = (0, _1_utilities_js_1.getRandomId)();
1262
1222
  const message = text;
1263
1223
  const noWebpage = params?.disableWebPagePreview ? true : undefined;
1264
1224
  const silent = params?.disableNotification ? true : undefined;
@@ -1266,15 +1226,15 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1266
1226
  const replyToMsgId = params?.replyToMessageId;
1267
1227
  const topMsgId = params?.messageThreadId;
1268
1228
  const sendAs = params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined;
1269
- const entities = entities_?.length > 0 ? entities_.map((v) => (0, _0_message_entity_js_1.messageEntityToTlObject)(v)) : undefined;
1270
- const result = await this.invoke(new functions.MessagesSendMessage({
1229
+ const entities = entities_?.length > 0 ? entities_.map((v) => (0, _3_types_js_1.messageEntityToTlObject)(v)) : undefined;
1230
+ const result = await this.invoke(new _2_tl_js_1.functions.MessagesSendMessage({
1271
1231
  peer,
1272
1232
  randomId,
1273
1233
  message,
1274
1234
  noWebpage,
1275
1235
  silent,
1276
1236
  noforwards,
1277
- replyTo: replyToMsgId !== undefined ? new types.InputReplyToMessage({ replyToMsgId, topMsgId }) : undefined,
1237
+ replyTo: replyToMsgId !== undefined ? new _2_tl_js_1.types.InputReplyToMessage({ replyToMsgId, topMsgId }) : undefined,
1278
1238
  sendAs,
1279
1239
  entities,
1280
1240
  replyMarkup,
@@ -1305,19 +1265,19 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1305
1265
  let replyMarkup = undefined;
1306
1266
  if (params?.replyMarkup) {
1307
1267
  if ("inlineKeyboard" in params.replyMarkup) {
1308
- replyMarkup = await (0, _2_inline_keyboard_markup_js_1.inlineKeyboardMarkupToTlObject)(params.replyMarkup, async (v) => {
1309
- const inputPeer = await this.getInputPeer(v).then((v) => v[_1_tl_object_js_1.as](types.InputPeerUser));
1310
- return new types.InputUser({ userId: inputPeer.userId, accessHash: inputPeer.accessHash });
1268
+ replyMarkup = await (0, _3_types_js_1.inlineKeyboardMarkupToTlObject)(params.replyMarkup, async (v) => {
1269
+ const inputPeer = await this.getInputPeer(v).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.InputPeerUser));
1270
+ return new _2_tl_js_1.types.InputUser({ userId: inputPeer.userId, accessHash: inputPeer.accessHash });
1311
1271
  });
1312
1272
  }
1313
1273
  else if ("keyboard" in params.replyMarkup) {
1314
- replyMarkup = (0, _2_reply_keyboard_markup_js_1.replyKeyboardMarkupToTlObject)(params.replyMarkup);
1274
+ replyMarkup = (0, _3_types_js_1.replyKeyboardMarkupToTlObject)(params.replyMarkup);
1315
1275
  }
1316
1276
  else if ("removeKeyboard" in params.replyMarkup) {
1317
- replyMarkup = (0, _0_reply_keyboard_remove_js_1.replyKeyboardRemoveToTlObject)(params.replyMarkup);
1277
+ replyMarkup = (0, _3_types_js_1.replyKeyboardRemoveToTlObject)(params.replyMarkup);
1318
1278
  }
1319
1279
  else if ("forceReply" in params.replyMarkup) {
1320
- replyMarkup = (0, _0_force_reply_js_1.forceReplyToTlObject)(params.replyMarkup);
1280
+ replyMarkup = (0, _3_types_js_1.forceReplyToTlObject)(params.replyMarkup);
1321
1281
  }
1322
1282
  else {
1323
1283
  throw new Error("The replyMarkup parameter has an unexpected type");
@@ -1325,21 +1285,15 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1325
1285
  }
1326
1286
  const id = messageId;
1327
1287
  const peer = await this.getInputPeer(chatId);
1328
- const entities = entities_?.length > 0 ? entities_.map((v) => (0, _0_message_entity_js_1.messageEntityToTlObject)(v)) : undefined;
1288
+ const entities = entities_?.length > 0 ? entities_.map((v) => (0, _3_types_js_1.messageEntityToTlObject)(v)) : undefined;
1329
1289
  const message = text;
1330
1290
  const noWebpage = params?.disableWebPagePreview ? true : undefined;
1331
- await this.invoke(new functions.MessagesEditMessage({ id, peer, entities, message, noWebpage, replyMarkup }));
1291
+ await this.invoke(new _2_tl_js_1.functions.MessagesEditMessage({ id, peer, entities, message, noWebpage, replyMarkup }));
1332
1292
  }
1333
- /**
1334
- * Retrieve multiple messages.
1335
- *
1336
- * @param chatId The identifier of the chat to retrieve the messages from.
1337
- * @param messageIds The identifiers of the messages to retrieve.
1338
- */
1339
- async getMessages(chatId_, messageIds) {
1293
+ async getMessagesInner(chatId_, messageIds) {
1340
1294
  const peer = await this.getInputPeer(chatId_);
1341
1295
  let messages_ = new Array();
1342
- const chatId = (0, _0_utilities_js_1.peerToChatId)(peer);
1296
+ const chatId = (0, _2_tl_js_1.peerToChatId)(peer);
1343
1297
  let shouldFetch = false;
1344
1298
  for (const messageId of messageIds) {
1345
1299
  const message = await this.storage.getMessage(chatId, messageId);
@@ -1353,24 +1307,39 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1353
1307
  }
1354
1308
  }
1355
1309
  if (shouldFetch) {
1356
- if (peer instanceof types.InputPeerChannel) {
1357
- messages_ = await this.invoke(new functions.ChannelsGetMessages({
1358
- channel: new types.InputChannel({ channelId: peer.channelId, accessHash: peer.accessHash }),
1359
- id: messageIds.map((v) => new types.InputMessageID({ id: v })),
1360
- })).then((v) => v[_1_tl_object_js_1.as](types.MessagesChannelMessages).messages);
1310
+ if (peer instanceof _2_tl_js_1.types.InputPeerChannel) {
1311
+ messages_ = await this.invoke(new _2_tl_js_1.functions.ChannelsGetMessages({
1312
+ channel: new _2_tl_js_1.types.InputChannel({ channelId: peer.channelId, accessHash: peer.accessHash }),
1313
+ id: messageIds.map((v) => new _2_tl_js_1.types.InputMessageID({ id: v })),
1314
+ })).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.MessagesChannelMessages).messages);
1361
1315
  }
1362
1316
  else {
1363
- messages_ = await this.invoke(new functions.MessagesGetMessages({
1364
- id: messageIds.map((v) => new types.InputMessageID({ id: v })),
1365
- })).then((v) => v[_1_tl_object_js_1.as](types.MessagesMessages).messages);
1317
+ messages_ = await this.invoke(new _2_tl_js_1.functions.MessagesGetMessages({
1318
+ id: messageIds.map((v) => new _2_tl_js_1.types.InputMessageID({ id: v })),
1319
+ })).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.MessagesMessages).messages);
1366
1320
  }
1367
1321
  }
1368
1322
  const messages = new Array();
1369
1323
  for (const message_ of messages_) {
1370
- messages.push(await (0, _3_message_js_1.constructMessage)(message_, this[exports.getEntity].bind(this), null, this[exports.getStickerSetName].bind(this)));
1324
+ const message = await (0, _3_types_js_1.constructMessage)(message_, this[exports.getEntity].bind(this), null, this[exports.getStickerSetName].bind(this));
1325
+ const isReplyToMessage = message_ instanceof _2_tl_js_1.types.Message && message_.replyTo instanceof _2_tl_js_1.types.MessageReplyHeader;
1326
+ messages.push({ message, isReplyToMessage });
1371
1327
  }
1372
1328
  return messages;
1373
1329
  }
1330
+ /**
1331
+ * Retrieve multiple messages.
1332
+ *
1333
+ * @param chatId The identifier of the chat to retrieve the messages from.
1334
+ * @param messageIds The identifiers of the messages to retrieve.
1335
+ */
1336
+ async getMessages(chatId_, messageIds) {
1337
+ return await this.getMessagesInner(chatId_, messageIds).then((v) => v.map((v) => v.message));
1338
+ }
1339
+ async [exports.getMessageWithReply](chatId, messageId) {
1340
+ const messages = await this.getMessagesInner(chatId, [messageId]);
1341
+ return messages[0]?.message ?? null;
1342
+ }
1374
1343
  /**
1375
1344
  * Retrieve a single message.
1376
1345
  *
@@ -1384,8 +1353,8 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1384
1353
  async *downloadInner(location, dcId) {
1385
1354
  let client = null;
1386
1355
  if (dcId != undefined && dcId != this.dcId) {
1387
- const exportedAuth = await this.invoke(new functions.AuthExportAuthorization({ dcId }));
1388
- client = new Client(new _1_storage_memory_js_1.StorageMemory(), this.apiId, this.apiHash, {
1356
+ const exportedAuth = await this.invoke(new _2_tl_js_1.functions.AuthExportAuthorization({ dcId }));
1357
+ client = new Client(new _3_storage_js_1.StorageMemory(), this.apiId, this.apiHash, {
1389
1358
  transportProvider: this.transportProvider,
1390
1359
  appVersion: this.appVersion,
1391
1360
  deviceModel: this.deviceModel,
@@ -1406,8 +1375,8 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1406
1375
  const limit = 1024 * 1024;
1407
1376
  let offset = 0n;
1408
1377
  while (true) {
1409
- const file = await (client ?? this).invoke(new functions.UploadGetFile({ location, offset, limit }));
1410
- if (file instanceof types.UploadFile) {
1378
+ const file = await (client ?? this).invoke(new _2_tl_js_1.functions.UploadGetFile({ location, offset, limit }));
1379
+ if (file instanceof _2_tl_js_1.types.UploadFile) {
1411
1380
  yield file.bytes;
1412
1381
  if (file.bytes.length < limit) {
1413
1382
  break;
@@ -1417,7 +1386,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1417
1386
  }
1418
1387
  }
1419
1388
  else {
1420
- (0, _0_control_js_1.UNREACHABLE)();
1389
+ (0, _1_utilities_js_1.UNREACHABLE)();
1421
1390
  }
1422
1391
  }
1423
1392
  }
@@ -1427,19 +1396,19 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1427
1396
  * @param fileId The identifier of the file to download.
1428
1397
  */
1429
1398
  async download(fileId) {
1430
- const fileId_ = _0_file_id_js_1.FileID.decode(fileId);
1399
+ const fileId_ = _3_types_js_1.FileID.decode(fileId);
1431
1400
  switch (fileId_.fileType) {
1432
- case _0_file_id_js_1.FileType.ChatPhoto: {
1433
- const big = fileId_.params.thumbnailSource == _0_file_id_js_1.ThumbnailSource.ChatPhotoBig;
1401
+ case _3_types_js_1.FileType.ChatPhoto: {
1402
+ const big = fileId_.params.thumbnailSource == _3_types_js_1.ThumbnailSource.ChatPhotoBig;
1434
1403
  const peer = await this.getInputPeer(fileId_.params.chatId);
1435
- const location = new types.InputPeerPhotoFileLocation({ big: big ? true : undefined, peer, photoId: fileId_.params.mediaId });
1404
+ const location = new _2_tl_js_1.types.InputPeerPhotoFileLocation({ big: big ? true : undefined, peer, photoId: fileId_.params.mediaId });
1436
1405
  return this.downloadInner(location);
1437
1406
  }
1438
- case _0_file_id_js_1.FileType.Photo: {
1407
+ case _3_types_js_1.FileType.Photo: {
1439
1408
  if (fileId_.params.mediaId == undefined || fileId_.params.accessHash == undefined || fileId_.params.fileReference == undefined || fileId_.params.thumbnailSize == undefined) {
1440
- (0, _0_control_js_1.UNREACHABLE)();
1409
+ (0, _1_utilities_js_1.UNREACHABLE)();
1441
1410
  }
1442
- const location = new types.InputPhotoFileLocation({
1411
+ const location = new _2_tl_js_1.types.InputPhotoFileLocation({
1443
1412
  id: fileId_.params.mediaId,
1444
1413
  accessHash: fileId_.params.accessHash,
1445
1414
  fileReference: fileId_.params.fileReference,
@@ -1448,17 +1417,17 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1448
1417
  return this.downloadInner(location);
1449
1418
  }
1450
1419
  default:
1451
- (0, _0_control_js_1.UNREACHABLE)();
1420
+ (0, _1_utilities_js_1.UNREACHABLE)();
1452
1421
  }
1453
1422
  }
1454
1423
  async [exports.getStickerSetName](inputStickerSet, hash = 0) {
1455
1424
  const maybeStickerSetName = await this.storage.getStickerSetName(inputStickerSet.id, inputStickerSet.accessHash);
1456
- if (maybeStickerSetName != null && Date.now() - maybeStickerSetName[1].getTime() < constants_js_1.STICKER_SET_NAME_TTL) {
1425
+ if (maybeStickerSetName != null && Date.now() - maybeStickerSetName[1].getTime() < _4_constants_js_1.STICKER_SET_NAME_TTL) {
1457
1426
  return maybeStickerSetName[0];
1458
1427
  }
1459
1428
  else {
1460
- const stickerSet = await this.invoke(new functions.MessagesGetStickerSet({ stickerset: inputStickerSet, hash }));
1461
- const name = stickerSet[_1_tl_object_js_1.as](types.MessagesStickerSet).set.shortName;
1429
+ const stickerSet = await this.invoke(new _2_tl_js_1.functions.MessagesGetStickerSet({ stickerset: inputStickerSet, hash }));
1430
+ const name = stickerSet[_2_tl_js_1.as](_2_tl_js_1.types.MessagesStickerSet).set.shortName;
1462
1431
  await this.storage.updateStickerSetName(inputStickerSet.id, inputStickerSet.accessHash, name);
1463
1432
  return name;
1464
1433
  }
@@ -1471,11 +1440,11 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1471
1440
  * @param messageIds The identifiers of the messages to forward.
1472
1441
  */
1473
1442
  async forwardMessages(from, to, messageIds, params) {
1474
- const result = await this.invoke(new functions.MessagesForwardMessages({
1443
+ const result = await this.invoke(new _2_tl_js_1.functions.MessagesForwardMessages({
1475
1444
  fromPeer: await this.getInputPeer(from),
1476
1445
  toPeer: await this.getInputPeer(to),
1477
1446
  id: messageIds,
1478
- randomId: messageIds.map(() => (0, _0_bigint_js_1.getRandomId)()),
1447
+ randomId: messageIds.map(() => (0, _1_utilities_js_1.getRandomId)()),
1479
1448
  silent: params?.disableNotification || undefined,
1480
1449
  topMsgId: params?.messageThreadId,
1481
1450
  noforwards: params?.disableNotification || undefined,
@@ -1499,35 +1468,35 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1499
1468
  * Get information on the currently authorized user.
1500
1469
  */
1501
1470
  async getMe() {
1502
- const users = await this.invoke(new functions.UsersGetUsers({ id: [new types.InputUserSelf()] }));
1471
+ const users = await this.invoke(new _2_tl_js_1.functions.UsersGetUsers({ id: [new _2_tl_js_1.types.InputUserSelf()] }));
1503
1472
  if (users.length < 1) {
1504
- (0, _0_control_js_1.UNREACHABLE)();
1473
+ (0, _1_utilities_js_1.UNREACHABLE)();
1505
1474
  }
1506
- return (0, _1_user_js_1.constructUser)(users[0][_1_tl_object_js_1.as](types.User));
1475
+ return (0, _3_types_js_1.constructUser)(users[0][_2_tl_js_1.as](_2_tl_js_1.types.User));
1507
1476
  }
1508
1477
  // TODO: log errors
1509
1478
  async handleUpdate(update) {
1510
- if (update instanceof types.UpdateNewMessage || update instanceof types.UpdateNewMessage || update instanceof types.UpdateNewChannelMessage || update instanceof types.UpdateNewChannelMessage) {
1511
- if (update.message instanceof types.Message || update.message instanceof types.MessageService) {
1512
- await this.storage.setMessage((0, _0_utilities_js_1.peerToChatId)(update.message.peerId), update.message.id, update.message);
1479
+ if (update instanceof _2_tl_js_1.types.UpdateNewMessage || update instanceof _2_tl_js_1.types.UpdateNewMessage || update instanceof _2_tl_js_1.types.UpdateNewChannelMessage || update instanceof _2_tl_js_1.types.UpdateNewChannelMessage) {
1480
+ if (update.message instanceof _2_tl_js_1.types.Message || update.message instanceof _2_tl_js_1.types.MessageService) {
1481
+ await this.storage.setMessage((0, _2_tl_js_1.peerToChatId)(update.message.peerId), update.message.id, update.message);
1513
1482
  }
1514
1483
  }
1515
- if (update instanceof types.UpdateNewMessage ||
1516
- update instanceof types.UpdateNewChannelMessage ||
1517
- update instanceof types.UpdateEditMessage ||
1518
- update instanceof types.UpdateEditChannelMessage) {
1519
- const key = update instanceof types.UpdateNewMessage || update instanceof types.UpdateNewChannelMessage ? "message" : "editedMessage";
1520
- const message = await (0, _3_message_js_1.constructMessage)(update.message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this));
1484
+ if (update instanceof _2_tl_js_1.types.UpdateNewMessage ||
1485
+ update instanceof _2_tl_js_1.types.UpdateNewChannelMessage ||
1486
+ update instanceof _2_tl_js_1.types.UpdateEditMessage ||
1487
+ update instanceof _2_tl_js_1.types.UpdateEditChannelMessage) {
1488
+ const key = update instanceof _2_tl_js_1.types.UpdateNewMessage || update instanceof _2_tl_js_1.types.UpdateNewChannelMessage ? "message" : "editedMessage";
1489
+ const message = await (0, _3_types_js_1.constructMessage)(update.message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this));
1521
1490
  await this.handler({ [key]: message }, resolve);
1522
1491
  }
1523
- if (update instanceof types.UpdateDeleteMessages) {
1492
+ if (update instanceof _2_tl_js_1.types.UpdateDeleteMessages) {
1524
1493
  const deletedMessages = new Array();
1525
1494
  for (const messageId of update.messages) {
1526
1495
  const chatId = await this.storage.getMessageChat(messageId);
1527
1496
  if (chatId) {
1528
1497
  const message = await this.storage.getMessage(chatId, messageId);
1529
1498
  if (message != null) {
1530
- deletedMessages.push(await (0, _3_message_js_1.constructMessage)(message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this)));
1499
+ deletedMessages.push(await (0, _3_types_js_1.constructMessage)(message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this)));
1531
1500
  }
1532
1501
  await this.storage.setMessage(chatId, messageId, null);
1533
1502
  }
@@ -1536,13 +1505,13 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1536
1505
  await this.handler({ deletedMessages: deletedMessages }, resolve);
1537
1506
  }
1538
1507
  }
1539
- else if (update instanceof types.UpdateDeleteChannelMessages) {
1540
- const chatId = (0, _0_utilities_js_1.getChannelChatId)(update.channelId);
1508
+ else if (update instanceof _2_tl_js_1.types.UpdateDeleteChannelMessages) {
1509
+ const chatId = (0, _2_tl_js_1.getChannelChatId)(update.channelId);
1541
1510
  const deletedMessages = new Array();
1542
1511
  for (const messageId of update.messages) {
1543
1512
  const message = await this.storage.getMessage(chatId, messageId);
1544
1513
  if (message) {
1545
- deletedMessages.push(await (0, _3_message_js_1.constructMessage)(message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this)));
1514
+ deletedMessages.push(await (0, _3_types_js_1.constructMessage)(message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this)));
1546
1515
  }
1547
1516
  await this.storage.setMessage(chatId, messageId, null);
1548
1517
  }
@@ -1550,6 +1519,12 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1550
1519
  await this.handler({ deletedMessages: deletedMessages }, resolve);
1551
1520
  }
1552
1521
  }
1522
+ if (update instanceof _2_tl_js_1.types.UpdateBotCallbackQuery || update instanceof _2_tl_js_1.types.UpdateInlineBotCallbackQuery) {
1523
+ await this.handler({ callbackQuery: await (0, _3_types_js_1.constructCallbackQuery)(update, this[exports.getEntity].bind(this), this[exports.getMessageWithReply].bind(this)) }, resolve);
1524
+ }
1525
+ else if (update instanceof _2_tl_js_1.types.UpdateBotInlineQuery) {
1526
+ await this.handler({ inlineQuery: await (0, _3_types_js_1.constructInlineQuery)(update, this[exports.getEntity].bind(this)) }, resolve);
1527
+ }
1553
1528
  }
1554
1529
  use(middleware) {
1555
1530
  const handler = this.handler;
@@ -1586,6 +1561,19 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1586
1561
  }
1587
1562
  });
1588
1563
  }
1564
+ /**
1565
+ * Answer a callback query. Bot-only.
1566
+ *
1567
+ * @param id ID of the callback query to answer.
1568
+ */
1569
+ async answerCallbackQuery(id, params) {
1570
+ await this.invoke(new _2_tl_js_1.functions.MessagesSetBotCallbackAnswer({
1571
+ queryId: BigInt(id),
1572
+ cacheTime: params?.cacheTime ?? 0,
1573
+ message: params?.text,
1574
+ alert: params?.alert ? true : undefined,
1575
+ }));
1576
+ }
1589
1577
  }
1590
1578
  exports.Client = Client;
1591
1579
  const resolve = () => Promise.resolve();