@mtkruto/node 0.1.138 → 0.1.140

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 (287) hide show
  1. package/esm/3_types.d.ts +10 -36
  2. package/esm/3_types.js +10 -36
  3. package/esm/4_constants.d.ts +1 -1
  4. package/esm/4_constants.js +1 -1
  5. package/esm/5_client.d.ts +1 -1
  6. package/esm/5_client.js +1 -1
  7. package/esm/_dnt.polyfills.d.ts +6 -0
  8. package/esm/client/0_filters.d.ts +60 -0
  9. package/esm/client/0_filters.js +27 -0
  10. package/esm/client/0_message.js +2 -2
  11. package/esm/client/{3_params.d.ts → 0_params.d.ts} +30 -33
  12. package/esm/client/0_types.d.ts +39 -0
  13. package/esm/client/0_types.js +2 -0
  14. package/esm/client/0_utilities.d.ts +1 -47
  15. package/esm/client/0_utilities.js +0 -27
  16. package/esm/client/1_composer.d.ts +1 -1
  17. package/esm/client/1_composer.js +1 -1
  18. package/esm/client/1_file_manager.d.ts +10 -0
  19. package/esm/client/1_file_manager.js +241 -0
  20. package/esm/client/1_update_manager.d.ts +18 -0
  21. package/esm/client/1_update_manager.js +553 -0
  22. package/esm/client/2_message_manager.d.ts +40 -0
  23. package/esm/client/2_message_manager.js +621 -0
  24. package/esm/client/3_chat_list_manager.d.ts +21 -0
  25. package/esm/client/3_chat_list_manager.js +353 -0
  26. package/esm/client/3_reaction_manager.d.ts +16 -0
  27. package/esm/client/3_reaction_manager.js +61 -0
  28. package/esm/client/4_client.d.ts +187 -60
  29. package/esm/client/4_client.js +492 -1699
  30. package/esm/connection/1_connection_web_socket.js +6 -6
  31. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/main/deps.d.ts +1 -1
  32. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/main/deps.js +1 -1
  33. package/esm/deps/raw.githubusercontent.com/MTKruto/object-inspect/main/index.d.ts +1 -0
  34. package/esm/deps/raw.githubusercontent.com/MTKruto/object-inspect/main/index.js +524 -0
  35. package/esm/mod.d.ts +1 -0
  36. package/esm/mod.js +1 -0
  37. package/esm/storage/0_storage.d.ts +5 -3
  38. package/esm/storage/0_storage.js +14 -4
  39. package/esm/tl/1_tl_object.d.ts +1 -0
  40. package/esm/tl/1_tl_object.js +24 -0
  41. package/esm/types/0_bot_command.d.ts +1 -0
  42. package/esm/types/0_chat_member_rights.d.ts +37 -0
  43. package/esm/types/0_chat_photo.d.ts +4 -4
  44. package/esm/types/0_file_source.d.ts +5 -0
  45. package/esm/types/0_giveaway_parameters.js +2 -1
  46. package/esm/types/0_id.d.ts +4 -0
  47. package/esm/types/0_message_entity.d.ts +20 -20
  48. package/esm/types/1__getters.d.ts +2 -2
  49. package/esm/types/1_animation.d.ts +1 -1
  50. package/esm/types/1_bot_command_scope.d.ts +5 -4
  51. package/esm/types/1_chat_p.d.ts +5 -6
  52. package/esm/types/1_document.d.ts +1 -0
  53. package/esm/types/1_input_message_content.d.ts +88 -0
  54. package/esm/types/1_photo.d.ts +1 -1
  55. package/esm/types/1_sticker.d.ts +1 -1
  56. package/esm/types/1_user.d.ts +1 -1
  57. package/esm/types/1_video.d.ts +1 -1
  58. package/esm/types/1_video_note.d.ts +1 -1
  59. package/esm/types/2_inline_keyboard_button.d.ts +10 -10
  60. package/esm/types/2_message_reaction_count.d.ts +3 -0
  61. package/esm/types/2_message_reaction_count.js +17 -1
  62. package/esm/types/2_message_reactions.d.ts +15 -0
  63. package/esm/types/2_message_reactions.js +37 -0
  64. package/esm/types/3_reply_markup.d.ts +42 -0
  65. package/esm/types/3_reply_markup.js +117 -0
  66. package/esm/types/4_inline_query_result.d.ts +193 -0
  67. package/esm/types/{5_inline_query_result.js → 4_inline_query_result.js} +2 -2
  68. package/esm/types/4_message.d.ts +36 -39
  69. package/esm/types/4_message.js +7 -24
  70. package/esm/types/5_callback_query.d.ts +2 -1
  71. package/esm/types/5_chat.d.ts +8 -5
  72. package/esm/types/6_update.d.ts +12 -2
  73. package/esm/utilities/0_buffer.js +9 -6
  74. package/esm/utilities/0_object.d.ts +1 -1
  75. package/esm/utilities/0_object.js +1 -6
  76. package/esm/utilities/1_misc.d.ts +2 -0
  77. package/esm/utilities/1_misc.js +6 -0
  78. package/package.json +1 -2
  79. package/script/3_types.d.ts +10 -36
  80. package/script/3_types.js +10 -36
  81. package/script/4_constants.d.ts +1 -1
  82. package/script/4_constants.js +1 -1
  83. package/script/5_client.d.ts +1 -1
  84. package/script/5_client.js +1 -1
  85. package/script/_dnt.polyfills.d.ts +6 -0
  86. package/script/client/0_filters.d.ts +60 -0
  87. package/script/client/0_filters.js +31 -0
  88. package/script/client/0_message.js +1 -1
  89. package/script/client/{3_params.d.ts → 0_params.d.ts} +30 -33
  90. package/script/client/0_types.d.ts +39 -0
  91. package/script/client/0_types.js +6 -0
  92. package/script/client/0_utilities.d.ts +1 -47
  93. package/script/client/0_utilities.js +1 -29
  94. package/script/client/1_composer.d.ts +1 -1
  95. package/script/client/1_composer.js +2 -2
  96. package/script/client/1_file_manager.d.ts +10 -0
  97. package/script/client/1_file_manager.js +245 -0
  98. package/script/client/1_update_manager.d.ts +18 -0
  99. package/script/client/1_update_manager.js +557 -0
  100. package/script/client/2_message_manager.d.ts +40 -0
  101. package/script/client/2_message_manager.js +625 -0
  102. package/script/client/3_chat_list_manager.d.ts +21 -0
  103. package/script/client/3_chat_list_manager.js +357 -0
  104. package/script/client/3_reaction_manager.d.ts +16 -0
  105. package/script/client/3_reaction_manager.js +65 -0
  106. package/script/client/4_client.d.ts +187 -60
  107. package/script/client/4_client.js +491 -1699
  108. package/script/connection/1_connection_web_socket.js +5 -5
  109. package/script/deps/raw.githubusercontent.com/MTKruto/debug/main/deps.d.ts +1 -1
  110. package/script/deps/raw.githubusercontent.com/MTKruto/debug/main/deps.js +2 -2
  111. package/script/deps/raw.githubusercontent.com/MTKruto/object-inspect/main/index.d.ts +1 -0
  112. package/script/deps/raw.githubusercontent.com/MTKruto/object-inspect/main/index.js +550 -0
  113. package/script/mod.d.ts +1 -0
  114. package/script/mod.js +1 -0
  115. package/script/storage/0_storage.d.ts +5 -3
  116. package/script/storage/0_storage.js +14 -4
  117. package/script/tl/1_tl_object.d.ts +1 -0
  118. package/script/tl/1_tl_object.js +24 -0
  119. package/script/types/0_bot_command.d.ts +1 -0
  120. package/script/types/0_chat_member_rights.d.ts +37 -0
  121. package/script/types/0_chat_photo.d.ts +4 -4
  122. package/script/types/0_file_source.d.ts +5 -0
  123. package/script/types/0_giveaway_parameters.js +2 -1
  124. package/script/types/0_id.d.ts +4 -0
  125. package/script/types/0_message_entity.d.ts +20 -20
  126. package/script/types/1__getters.d.ts +2 -2
  127. package/script/types/1_animation.d.ts +1 -1
  128. package/script/types/1_bot_command_scope.d.ts +5 -4
  129. package/script/types/1_chat_p.d.ts +5 -6
  130. package/script/types/1_document.d.ts +1 -0
  131. package/script/types/1_input_message_content.d.ts +88 -0
  132. package/script/types/1_photo.d.ts +1 -1
  133. package/script/types/1_sticker.d.ts +1 -1
  134. package/script/types/1_user.d.ts +1 -1
  135. package/script/types/1_video.d.ts +1 -1
  136. package/script/types/1_video_note.d.ts +1 -1
  137. package/script/types/2_inline_keyboard_button.d.ts +10 -10
  138. package/script/types/2_message_reaction_count.d.ts +3 -0
  139. package/script/types/2_message_reaction_count.js +19 -0
  140. package/script/types/2_message_reactions.d.ts +15 -0
  141. package/script/types/2_message_reactions.js +41 -0
  142. package/script/types/3_reply_markup.d.ts +42 -0
  143. package/script/types/3_reply_markup.js +122 -0
  144. package/script/types/4_inline_query_result.d.ts +193 -0
  145. package/script/types/{5_inline_query_result.js → 4_inline_query_result.js} +3 -3
  146. package/script/types/4_message.d.ts +36 -39
  147. package/script/types/4_message.js +6 -23
  148. package/script/types/5_callback_query.d.ts +2 -1
  149. package/script/types/5_chat.d.ts +8 -5
  150. package/script/types/6_update.d.ts +12 -2
  151. package/script/utilities/0_buffer.js +9 -6
  152. package/script/utilities/0_object.d.ts +1 -1
  153. package/script/utilities/0_object.js +1 -6
  154. package/script/utilities/1_misc.d.ts +2 -0
  155. package/script/utilities/1_misc.js +9 -1
  156. package/esm/types/0_chat_id.d.ts +0 -4
  157. package/esm/types/0_force_reply.d.ts +0 -12
  158. package/esm/types/0_force_reply.js +0 -17
  159. package/esm/types/0_input_contact_message_content.d.ts +0 -11
  160. package/esm/types/0_input_location_message_content.d.ts +0 -15
  161. package/esm/types/0_input_venue_message_content.d.ts +0 -19
  162. package/esm/types/0_reply_keyboard_remove.d.ts +0 -10
  163. package/esm/types/0_reply_keyboard_remove.js +0 -8
  164. package/esm/types/1_input_invoice_message_content.d.ts +0 -23
  165. package/esm/types/1_input_text_message_content.d.ts +0 -8
  166. package/esm/types/1_input_text_message_content.js +0 -1
  167. package/esm/types/2_input_message_content.d.ts +0 -6
  168. package/esm/types/2_input_message_content.js +0 -1
  169. package/esm/types/2_reply_keyboard_markup.d.ts +0 -12
  170. package/esm/types/2_reply_keyboard_markup.js +0 -37
  171. package/esm/types/3_inline_keyboard_markup.d.ts +0 -8
  172. package/esm/types/3_inline_keyboard_markup.js +0 -24
  173. package/esm/types/4_inline_query_result_article.d.ts +0 -15
  174. package/esm/types/4_inline_query_result_article.js +0 -1
  175. package/esm/types/4_inline_query_result_audio.d.ts +0 -17
  176. package/esm/types/4_inline_query_result_audio.js +0 -1
  177. package/esm/types/4_inline_query_result_cached_audio.d.ts +0 -14
  178. package/esm/types/4_inline_query_result_cached_audio.js +0 -1
  179. package/esm/types/4_inline_query_result_cached_document.d.ts +0 -15
  180. package/esm/types/4_inline_query_result_cached_document.js +0 -1
  181. package/esm/types/4_inline_query_result_cached_gif.d.ts +0 -15
  182. package/esm/types/4_inline_query_result_cached_gif.js +0 -1
  183. package/esm/types/4_inline_query_result_cached_mpeg4_gif.d.ts +0 -15
  184. package/esm/types/4_inline_query_result_cached_mpeg4_gif.js +0 -1
  185. package/esm/types/4_inline_query_result_cached_photo.d.ts +0 -16
  186. package/esm/types/4_inline_query_result_cached_photo.js +0 -1
  187. package/esm/types/4_inline_query_result_cached_sticker.d.ts +0 -9
  188. package/esm/types/4_inline_query_result_cached_sticker.js +0 -1
  189. package/esm/types/4_inline_query_result_cached_video.d.ts +0 -16
  190. package/esm/types/4_inline_query_result_cached_video.js +0 -1
  191. package/esm/types/4_inline_query_result_cached_voice.d.ts +0 -15
  192. package/esm/types/4_inline_query_result_cached_voice.js +0 -1
  193. package/esm/types/4_inline_query_result_contact.d.ts +0 -15
  194. package/esm/types/4_inline_query_result_contact.js +0 -1
  195. package/esm/types/4_inline_query_result_document.d.ts +0 -18
  196. package/esm/types/4_inline_query_result_document.js +0 -1
  197. package/esm/types/4_inline_query_result_game.d.ts +0 -7
  198. package/esm/types/4_inline_query_result_game.js +0 -1
  199. package/esm/types/4_inline_query_result_gif.d.ts +0 -20
  200. package/esm/types/4_inline_query_result_gif.js +0 -1
  201. package/esm/types/4_inline_query_result_location.d.ts +0 -18
  202. package/esm/types/4_inline_query_result_location.js +0 -1
  203. package/esm/types/4_inline_query_result_mpeg4_gif.d.ts +0 -20
  204. package/esm/types/4_inline_query_result_mpeg4_gif.js +0 -1
  205. package/esm/types/4_inline_query_result_photo.d.ts +0 -19
  206. package/esm/types/4_inline_query_result_photo.js +0 -1
  207. package/esm/types/4_inline_query_result_venue.d.ts +0 -19
  208. package/esm/types/4_inline_query_result_venue.js +0 -1
  209. package/esm/types/4_inline_query_result_video.d.ts +0 -21
  210. package/esm/types/4_inline_query_result_video.js +0 -1
  211. package/esm/types/4_inline_query_result_voice.d.ts +0 -16
  212. package/esm/types/4_inline_query_result_voice.js +0 -1
  213. package/esm/types/4_reply_markup.d.ts +0 -7
  214. package/esm/types/4_reply_markup.js +0 -22
  215. package/esm/types/5_inline_query_result.d.ts +0 -28
  216. package/script/types/0_chat_id.d.ts +0 -4
  217. package/script/types/0_force_reply.d.ts +0 -12
  218. package/script/types/0_force_reply.js +0 -22
  219. package/script/types/0_input_contact_message_content.d.ts +0 -11
  220. package/script/types/0_input_location_message_content.d.ts +0 -15
  221. package/script/types/0_input_venue_message_content.d.ts +0 -19
  222. package/script/types/0_reply_keyboard_remove.d.ts +0 -10
  223. package/script/types/0_reply_keyboard_remove.js +0 -13
  224. package/script/types/1_input_invoice_message_content.d.ts +0 -23
  225. package/script/types/1_input_text_message_content.d.ts +0 -8
  226. package/script/types/1_input_text_message_content.js +0 -2
  227. package/script/types/2_input_message_content.d.ts +0 -6
  228. package/script/types/2_input_message_content.js +0 -2
  229. package/script/types/2_reply_keyboard_markup.d.ts +0 -12
  230. package/script/types/2_reply_keyboard_markup.js +0 -42
  231. package/script/types/3_inline_keyboard_markup.d.ts +0 -8
  232. package/script/types/3_inline_keyboard_markup.js +0 -29
  233. package/script/types/4_inline_query_result_article.d.ts +0 -15
  234. package/script/types/4_inline_query_result_article.js +0 -2
  235. package/script/types/4_inline_query_result_audio.d.ts +0 -17
  236. package/script/types/4_inline_query_result_audio.js +0 -2
  237. package/script/types/4_inline_query_result_cached_audio.d.ts +0 -14
  238. package/script/types/4_inline_query_result_cached_audio.js +0 -2
  239. package/script/types/4_inline_query_result_cached_document.d.ts +0 -15
  240. package/script/types/4_inline_query_result_cached_document.js +0 -2
  241. package/script/types/4_inline_query_result_cached_gif.d.ts +0 -15
  242. package/script/types/4_inline_query_result_cached_gif.js +0 -2
  243. package/script/types/4_inline_query_result_cached_mpeg4_gif.d.ts +0 -15
  244. package/script/types/4_inline_query_result_cached_mpeg4_gif.js +0 -2
  245. package/script/types/4_inline_query_result_cached_photo.d.ts +0 -16
  246. package/script/types/4_inline_query_result_cached_photo.js +0 -2
  247. package/script/types/4_inline_query_result_cached_sticker.d.ts +0 -9
  248. package/script/types/4_inline_query_result_cached_sticker.js +0 -2
  249. package/script/types/4_inline_query_result_cached_video.d.ts +0 -16
  250. package/script/types/4_inline_query_result_cached_video.js +0 -2
  251. package/script/types/4_inline_query_result_cached_voice.d.ts +0 -15
  252. package/script/types/4_inline_query_result_cached_voice.js +0 -2
  253. package/script/types/4_inline_query_result_contact.d.ts +0 -15
  254. package/script/types/4_inline_query_result_contact.js +0 -2
  255. package/script/types/4_inline_query_result_document.d.ts +0 -18
  256. package/script/types/4_inline_query_result_document.js +0 -2
  257. package/script/types/4_inline_query_result_game.d.ts +0 -7
  258. package/script/types/4_inline_query_result_game.js +0 -2
  259. package/script/types/4_inline_query_result_gif.d.ts +0 -20
  260. package/script/types/4_inline_query_result_gif.js +0 -2
  261. package/script/types/4_inline_query_result_location.d.ts +0 -18
  262. package/script/types/4_inline_query_result_location.js +0 -2
  263. package/script/types/4_inline_query_result_mpeg4_gif.d.ts +0 -20
  264. package/script/types/4_inline_query_result_mpeg4_gif.js +0 -2
  265. package/script/types/4_inline_query_result_photo.d.ts +0 -19
  266. package/script/types/4_inline_query_result_photo.js +0 -2
  267. package/script/types/4_inline_query_result_venue.d.ts +0 -19
  268. package/script/types/4_inline_query_result_venue.js +0 -2
  269. package/script/types/4_inline_query_result_video.d.ts +0 -21
  270. package/script/types/4_inline_query_result_video.js +0 -2
  271. package/script/types/4_inline_query_result_voice.d.ts +0 -16
  272. package/script/types/4_inline_query_result_voice.js +0 -2
  273. package/script/types/4_reply_markup.d.ts +0 -7
  274. package/script/types/4_reply_markup.js +0 -26
  275. package/script/types/5_inline_query_result.d.ts +0 -28
  276. /package/esm/{client/3_params.js → _dnt.polyfills.js} +0 -0
  277. /package/esm/{types/0_chat_id.js → client/0_params.js} +0 -0
  278. /package/esm/types/{0_input_contact_message_content.js → 0_chat_member_rights.js} +0 -0
  279. /package/esm/types/{0_input_location_message_content.js → 0_file_source.js} +0 -0
  280. /package/esm/types/{0_input_venue_message_content.js → 0_id.js} +0 -0
  281. /package/esm/types/{1_input_invoice_message_content.js → 1_input_message_content.js} +0 -0
  282. /package/script/{client/3_params.js → _dnt.polyfills.js} +0 -0
  283. /package/script/{types/0_chat_id.js → client/0_params.js} +0 -0
  284. /package/script/types/{0_input_contact_message_content.js → 0_chat_member_rights.js} +0 -0
  285. /package/script/types/{0_input_location_message_content.js → 0_file_source.js} +0 -0
  286. /package/script/types/{0_input_venue_message_content.js → 0_id.js} +0 -0
  287. /package/script/types/{1_input_invoice_message_content.js → 1_input_message_content.js} +0 -0
@@ -0,0 +1,353 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
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
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _ChatListManager_instances, _ChatListManager_c, _ChatListManager_sendChatUpdate, _ChatListManager_chats, _ChatListManager_archivedChats, _ChatListManager_chatsLoadedFromStorage, _ChatListManager_getChatList, _ChatListManager_loadChatsFromStorage, _ChatListManager_getLoadedChats, _ChatListManager_pinnedChats, _ChatListManager_pinnedArchiveChats, _ChatListManager_storageHadPinnedChats, _ChatListManager_pinnedChatsLoaded, _ChatListManager_loadPinnedChats, _ChatListManager_fetchPinnedChats, _ChatListManager_getPinnedChats, _ChatListManager_updateOrAddChat, _ChatListManager_removeChat, _ChatListManager_fetchChats;
13
+ import { debug } from "../0_deps.js";
14
+ import { toUnixTimestamp, UNREACHABLE } from "../1_utilities.js";
15
+ import { peerToChatId, types } from "../2_tl.js";
16
+ import { constructChat, constructChat3, constructChat4, getChatOrder } from "../3_types.js";
17
+ import { getChatListId } from "./0_utilities.js";
18
+ const d = debug("ChatListManager");
19
+ export class ChatListManager {
20
+ constructor(c) {
21
+ _ChatListManager_instances.add(this);
22
+ _ChatListManager_c.set(this, void 0);
23
+ _ChatListManager_chats.set(this, new Map());
24
+ _ChatListManager_archivedChats.set(this, new Map());
25
+ _ChatListManager_chatsLoadedFromStorage.set(this, false);
26
+ _ChatListManager_pinnedChats.set(this, new Array());
27
+ _ChatListManager_pinnedArchiveChats.set(this, new Array());
28
+ _ChatListManager_storageHadPinnedChats.set(this, false);
29
+ _ChatListManager_pinnedChatsLoaded.set(this, false);
30
+ __classPrivateFieldSet(this, _ChatListManager_c, c, "f");
31
+ }
32
+ async reassignChatLastMessage(chatId, add = false, sendUpdate = true) {
33
+ try {
34
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.assertUser("");
35
+ }
36
+ catch {
37
+ return () => Promise.resolve();
38
+ }
39
+ const [chat, listId] = this.getChatAnywhere(chatId);
40
+ if (!chat && !add) {
41
+ return () => Promise.resolve();
42
+ }
43
+ const message_ = await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getLastMessage(chatId);
44
+ if (message_ != null) {
45
+ const message = await __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.constructMessage(message_);
46
+ if (chat) {
47
+ chat.order = getChatOrder(message, chat.pinned);
48
+ chat.lastMessage = message;
49
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setChat(listId, chatId, chat.pinned, message.id, message.date);
50
+ }
51
+ else {
52
+ const pinnedChats = await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getPinnedChats).call(this, listId);
53
+ const chat = await constructChat3(chatId, pinnedChats.indexOf(chatId), message, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
54
+ if (chat == null) {
55
+ UNREACHABLE();
56
+ }
57
+ __classPrivateFieldGet(this, _ChatListManager_chats, "f").set(chatId, chat);
58
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setChat(listId, chatId, chat.pinned, chat.lastMessage?.id ?? 0, chat.lastMessage?.date ?? new Date(0));
59
+ }
60
+ if (sendUpdate) {
61
+ return () => __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, !chat);
62
+ }
63
+ return () => Promise.resolve();
64
+ }
65
+ const message = await __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getHistory(chatId, { limit: 1 }).then((v) => v[0]);
66
+ if (message) {
67
+ if (chat) {
68
+ chat.order = getChatOrder(message, chat.pinned);
69
+ chat.lastMessage = message;
70
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setChat(listId, chatId, chat.pinned, message.id, message.date);
71
+ }
72
+ else {
73
+ const pinnedChats = await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getPinnedChats).call(this, listId);
74
+ const chat = await constructChat3(chatId, pinnedChats.indexOf(chatId), message, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
75
+ if (chat == null) {
76
+ UNREACHABLE();
77
+ }
78
+ __classPrivateFieldGet(this, _ChatListManager_chats, "f").set(chatId, chat);
79
+ }
80
+ if (sendUpdate) {
81
+ return () => __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, !chat);
82
+ }
83
+ return () => Promise.resolve();
84
+ }
85
+ if (chat) {
86
+ chat.order = getChatOrder(undefined, chat.pinned);
87
+ chat.lastMessage = undefined;
88
+ if (sendUpdate) {
89
+ return () => __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, false);
90
+ }
91
+ }
92
+ return () => Promise.resolve();
93
+ }
94
+ tryGetChatId(username) {
95
+ username = username.toLowerCase();
96
+ for (const chat of __classPrivateFieldGet(this, _ChatListManager_chats, "f").values()) {
97
+ if ("username" in chat) {
98
+ if (chat.username === username || chat.also?.some((v) => v.toLowerCase() === username)) {
99
+ return chat.id;
100
+ }
101
+ }
102
+ }
103
+ for (const chat of __classPrivateFieldGet(this, _ChatListManager_archivedChats, "f").values()) {
104
+ if ("username" in chat) {
105
+ if (chat.username === username || chat.also?.some((v) => v.toLowerCase() === username)) {
106
+ return chat.id;
107
+ }
108
+ }
109
+ }
110
+ return null;
111
+ }
112
+ getChatAnywhere(chatId) {
113
+ let chat = __classPrivateFieldGet(this, _ChatListManager_chats, "f").get(chatId);
114
+ if (chat) {
115
+ return [chat, 0];
116
+ }
117
+ chat = __classPrivateFieldGet(this, _ChatListManager_archivedChats, "f").get(chatId);
118
+ if (chat) {
119
+ return [chat, 1];
120
+ }
121
+ return [undefined, -1];
122
+ }
123
+ async handelUpdateFolderPeers(update) {
124
+ for (const { peer, folder_id: listId } of update.folder_peers) {
125
+ const chatId = peerToChatId(peer);
126
+ const [chat, currentListId] = this.getChatAnywhere(chatId);
127
+ if (chat !== undefined && listId != currentListId) {
128
+ __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, currentListId).delete(chatId);
129
+ __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, listId).set(chatId, chat);
130
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, true);
131
+ }
132
+ }
133
+ }
134
+ async handleUpdatePinnedDialogs(update) {
135
+ const listId = update.folder_id ?? 0;
136
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_fetchPinnedChats).call(this, update.folder_id);
137
+ const chats = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, listId);
138
+ const pinnedChats = await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getPinnedChats).call(this, listId);
139
+ for (const [i, chatId] of pinnedChats.entries()) {
140
+ const chat = chats.get(chatId);
141
+ if (chat !== undefined) {
142
+ chat.order = getChatOrder(chat.lastMessage, i);
143
+ chat.pinned = i;
144
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, false);
145
+ }
146
+ }
147
+ for (const chat of chats.values()) {
148
+ if (chat.pinned != -1 && pinnedChats.indexOf(chat.id) == -1) {
149
+ chat.order = getChatOrder(chat.lastMessage, -1);
150
+ chat.pinned = -1;
151
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chat.id, false);
152
+ }
153
+ }
154
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setPinnedChats(listId, await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getPinnedChats).call(this, listId));
155
+ }
156
+ async handleUpdateChannel(update) {
157
+ const peer = new types.PeerChannel(update);
158
+ const channel = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity(peer);
159
+ if (channel != null && "left" in channel && channel.left) {
160
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, peerToChatId(peer));
161
+ }
162
+ else if (channel instanceof types.ChannelForbidden) {
163
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, peerToChatId(peer));
164
+ }
165
+ else if (channel instanceof types.Channel) {
166
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, peerToChatId(peer));
167
+ }
168
+ }
169
+ async handleUpdateChat(update) {
170
+ const peer = new types.PeerChat(update);
171
+ const chat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity(peer);
172
+ if (chat != null && "left" in chat && chat.left) {
173
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, peerToChatId(peer));
174
+ }
175
+ else if (chat instanceof types.ChatForbidden) {
176
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, peerToChatId(peer));
177
+ }
178
+ else if (chat instanceof types.Chat) {
179
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, peerToChatId(peer));
180
+ }
181
+ }
182
+ async handleUpdateUser(update) {
183
+ const peer = new types.PeerUser(update);
184
+ const chat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity(peer);
185
+ if (chat != null) {
186
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, peerToChatId(peer));
187
+ }
188
+ }
189
+ async getChats(from = "main", after, limit = 100) {
190
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.assertUser("getChats");
191
+ if (!__classPrivateFieldGet(this, _ChatListManager_chatsLoadedFromStorage, "f")) {
192
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_loadChatsFromStorage).call(this);
193
+ }
194
+ if (after && !__classPrivateFieldGet(this, _ChatListManager_chats, "f").get(after.id)) {
195
+ throw new Error("Invalid after");
196
+ }
197
+ if (limit <= 0 || limit > 100) {
198
+ limit = 100;
199
+ }
200
+ const listId = getChatListId(from);
201
+ let chats = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getLoadedChats).call(this, listId);
202
+ if (after) {
203
+ chats = chats
204
+ .filter((v) => v.order < after.order);
205
+ }
206
+ if (chats.length < limit) {
207
+ d("have only %d chats but %d more is needed", chats.length, limit - chats.length);
208
+ if (!await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.hasAllChats(listId)) {
209
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_fetchChats).call(this, listId, limit, after);
210
+ return await this.getChats(from, after, limit);
211
+ }
212
+ }
213
+ chats = chats.slice(0, limit);
214
+ return chats;
215
+ }
216
+ }
217
+ _ChatListManager_c = new WeakMap(), _ChatListManager_chats = new WeakMap(), _ChatListManager_archivedChats = new WeakMap(), _ChatListManager_chatsLoadedFromStorage = new WeakMap(), _ChatListManager_pinnedChats = new WeakMap(), _ChatListManager_pinnedArchiveChats = new WeakMap(), _ChatListManager_storageHadPinnedChats = new WeakMap(), _ChatListManager_pinnedChatsLoaded = new WeakMap(), _ChatListManager_instances = new WeakSet(), _ChatListManager_sendChatUpdate = async function _ChatListManager_sendChatUpdate(chatId, added) {
218
+ try {
219
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.assertUser("");
220
+ }
221
+ catch {
222
+ return;
223
+ }
224
+ const [chat] = this.getChatAnywhere(chatId);
225
+ const update = chat === undefined ? { deletedChat: { chatId } } : added ? { newChat: chat } : { editedChat: chat };
226
+ __classPrivateFieldGet(this, _ChatListManager_c, "f").handleUpdate(update);
227
+ }, _ChatListManager_getChatList = function _ChatListManager_getChatList(listId) {
228
+ switch (listId) {
229
+ case 0:
230
+ return __classPrivateFieldGet(this, _ChatListManager_chats, "f");
231
+ case 1:
232
+ return __classPrivateFieldGet(this, _ChatListManager_archivedChats, "f");
233
+ default:
234
+ throw new Error("Invalid chat list: " + listId);
235
+ }
236
+ }, _ChatListManager_loadChatsFromStorage = async function _ChatListManager_loadChatsFromStorage() {
237
+ const chats = await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getChats(0);
238
+ const archivedChats = await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getChats(1);
239
+ for (const { chatId, pinned, topMessageId } of chats) {
240
+ const chat = await constructChat4(chatId, pinned, topMessageId, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
241
+ if (chat == null) {
242
+ continue;
243
+ }
244
+ __classPrivateFieldGet(this, _ChatListManager_chats, "f").set(chat.id, chat);
245
+ }
246
+ for (const { chatId, pinned, topMessageId } of archivedChats) {
247
+ const chat = await constructChat4(chatId, pinned, topMessageId, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
248
+ if (chat == null) {
249
+ continue;
250
+ }
251
+ __classPrivateFieldGet(this, _ChatListManager_archivedChats, "f").set(chat.id, chat);
252
+ }
253
+ __classPrivateFieldSet(this, _ChatListManager_chatsLoadedFromStorage, true, "f");
254
+ }, _ChatListManager_getLoadedChats = function _ChatListManager_getLoadedChats(listId) {
255
+ const chats_ = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, listId);
256
+ const chats = new Array();
257
+ for (const chat of chats_.values()) {
258
+ chats.push(chat);
259
+ }
260
+ return chats
261
+ .sort((a, b) => b.id - a.id)
262
+ .sort((a, b) => b.order.localeCompare(a.order));
263
+ }, _ChatListManager_loadPinnedChats = async function _ChatListManager_loadPinnedChats() {
264
+ const [pinnedChats, pinnedArchiveChats] = await Promise.all([__classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getPinnedChats(0), __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getPinnedChats(1)]);
265
+ if (pinnedChats != null && pinnedArchiveChats != null) {
266
+ __classPrivateFieldSet(this, _ChatListManager_pinnedChats, pinnedChats, "f");
267
+ __classPrivateFieldSet(this, _ChatListManager_pinnedArchiveChats, pinnedArchiveChats, "f");
268
+ __classPrivateFieldSet(this, _ChatListManager_storageHadPinnedChats, true, "f");
269
+ }
270
+ __classPrivateFieldSet(this, _ChatListManager_pinnedChatsLoaded, true, "f");
271
+ }, _ChatListManager_fetchPinnedChats = async function _ChatListManager_fetchPinnedChats(listId = null) {
272
+ if (listId == null || listId == 0) {
273
+ const dialogs = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.messages.getPinnedDialogs({ folder_id: 0 });
274
+ const pinnedChats = new Array();
275
+ for (const dialog of dialogs.dialogs) {
276
+ pinnedChats.push(peerToChatId(dialog.peer));
277
+ }
278
+ __classPrivateFieldSet(this, _ChatListManager_pinnedChats, pinnedChats, "f");
279
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setPinnedChats(0, __classPrivateFieldGet(this, _ChatListManager_pinnedChats, "f"));
280
+ }
281
+ if (listId == null || listId == 1) {
282
+ const dialogs = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.messages.getPinnedDialogs({ folder_id: 1 });
283
+ const pinnedArchiveChats = new Array();
284
+ for (const dialog of dialogs.dialogs) {
285
+ pinnedArchiveChats.push(peerToChatId(dialog.peer));
286
+ }
287
+ __classPrivateFieldSet(this, _ChatListManager_pinnedArchiveChats, pinnedArchiveChats, "f");
288
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setPinnedChats(1, __classPrivateFieldGet(this, _ChatListManager_pinnedArchiveChats, "f"));
289
+ }
290
+ if (listId != null && listId != 0 && listId != 1) {
291
+ UNREACHABLE();
292
+ }
293
+ }, _ChatListManager_getPinnedChats = async function _ChatListManager_getPinnedChats(listId) {
294
+ if (!__classPrivateFieldGet(this, _ChatListManager_pinnedChatsLoaded, "f")) {
295
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_loadPinnedChats).call(this);
296
+ }
297
+ if (!__classPrivateFieldGet(this, _ChatListManager_storageHadPinnedChats, "f")) {
298
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_fetchPinnedChats).call(this);
299
+ }
300
+ switch (listId) {
301
+ case 0:
302
+ return __classPrivateFieldGet(this, _ChatListManager_pinnedChats, "f");
303
+ case 1:
304
+ return __classPrivateFieldGet(this, _ChatListManager_pinnedArchiveChats, "f");
305
+ default:
306
+ UNREACHABLE();
307
+ }
308
+ }, _ChatListManager_updateOrAddChat = async function _ChatListManager_updateOrAddChat(chatId) {
309
+ const [chat, listId] = this.getChatAnywhere(chatId);
310
+ if (chat !== undefined) {
311
+ const newChat = await constructChat3(chatId, chat.pinned, chat.lastMessage, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
312
+ if (newChat != null) {
313
+ __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, listId).set(chatId, newChat);
314
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, false);
315
+ }
316
+ }
317
+ else {
318
+ const chat = await constructChat4(chatId, -1, -1, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
319
+ if (chat != null) {
320
+ __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, 0).set(chatId, chat);
321
+ await this.reassignChatLastMessage(chatId, false, false);
322
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, true);
323
+ }
324
+ }
325
+ }, _ChatListManager_removeChat = async function _ChatListManager_removeChat(chatId) {
326
+ const [chat, listId] = this.getChatAnywhere(chatId);
327
+ if (chat !== undefined) {
328
+ __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, listId).delete(chatId);
329
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, false);
330
+ }
331
+ }, _ChatListManager_fetchChats = async function _ChatListManager_fetchChats(listId, limit, after) {
332
+ const dialogs = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.messages.getDialogs({
333
+ limit,
334
+ offset_id: after?.lastMessage?.id ?? 0,
335
+ offset_date: after?.lastMessage?.date ? toUnixTimestamp(after.lastMessage.date) : 0,
336
+ offset_peer: after ? await __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeer(after.id) : new types.InputPeerEmpty(),
337
+ hash: 0n,
338
+ folder_id: listId,
339
+ });
340
+ const pinnedChats = await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getPinnedChats).call(this, listId);
341
+ if (!(dialogs instanceof types.messages.Dialogs) && !(dialogs instanceof types.messages.DialogsSlice)) {
342
+ UNREACHABLE();
343
+ }
344
+ if (dialogs.dialogs.length < limit) {
345
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setHasAllChats(listId, true);
346
+ }
347
+ const chats = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, listId);
348
+ for (const dialog of dialogs.dialogs) {
349
+ const chat = await constructChat(dialog, dialogs, pinnedChats, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager), __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getStickerSetName.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
350
+ chats.set(chat.id, chat);
351
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setChat(listId, chat.id, chat.pinned, chat.lastMessage?.id ?? 0, chat.lastMessage?.date ?? new Date(0));
352
+ }
353
+ };
@@ -0,0 +1,16 @@
1
+ import { ID, Reaction } from "../3_types.js";
2
+ import { AddReactionParams, SetReactionsParams } from "./0_params.js";
3
+ import { C as C_ } from "./0_types.js";
4
+ import { MessageManager } from "./2_message_manager.js";
5
+ interface C extends C_ {
6
+ messageManager: MessageManager;
7
+ }
8
+ export declare class ReactionManager {
9
+ #private;
10
+ constructor(c: C);
11
+ setAvailableReactions(chatId: ID, availableReactions: "none" | "all" | Reaction[]): Promise<void>;
12
+ setReactions(chatId: number, messageId: number, reactions: Reaction[], params?: SetReactionsParams): Promise<void>;
13
+ addReaction(chatId: number, messageId: number, reaction: Reaction, params?: AddReactionParams): Promise<void>;
14
+ removeReaction(chatId: number, messageId: number, reaction: Reaction): Promise<void>;
15
+ }
16
+ export {};
@@ -0,0 +1,61 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
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
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _ReactionManager_instances, _ReactionManager_c, _ReactionManager_sendReaction;
13
+ import { UNREACHABLE } from "../1_utilities.js";
14
+ import { types } from "../2_tl.js";
15
+ import { reactionEqual, reactionToTlObject } from "../3_types.js";
16
+ export class ReactionManager {
17
+ constructor(c) {
18
+ _ReactionManager_instances.add(this);
19
+ _ReactionManager_c.set(this, void 0);
20
+ __classPrivateFieldSet(this, _ReactionManager_c, c, "f");
21
+ }
22
+ async setAvailableReactions(chatId, availableReactions) {
23
+ // TODO: sync with storage
24
+ await __classPrivateFieldGet(this, _ReactionManager_c, "f").api.messages.setChatAvailableReactions({
25
+ peer: await __classPrivateFieldGet(this, _ReactionManager_c, "f").getInputPeer(chatId),
26
+ available_reactions: availableReactions == "none" ? new types.ChatReactionsNone() : availableReactions == "all" ? new types.ChatReactionsAll() : Array.isArray(availableReactions) ? new types.ChatReactionsSome({ reactions: availableReactions.map((v) => v.type == "emoji" ? new types.ReactionEmoji({ emoticon: v.emoji }) : new types.ReactionCustomEmoji({ document_id: BigInt(v.id) })) }) : UNREACHABLE(),
27
+ });
28
+ }
29
+ async setReactions(chatId, messageId, reactions, params) {
30
+ await __classPrivateFieldGet(this, _ReactionManager_instances, "m", _ReactionManager_sendReaction).call(this, chatId, messageId, reactions, params);
31
+ }
32
+ async addReaction(chatId, messageId, reaction, params) {
33
+ const chosenReactions = await __classPrivateFieldGet(this, _ReactionManager_c, "f").messageManager.getMessage(chatId, messageId).then((v) => v?.reactions ?? []).then((v) => v.filter((v) => v.chosen));
34
+ for (const r of chosenReactions) {
35
+ if (reactionEqual(r.reaction, reaction)) {
36
+ return;
37
+ }
38
+ }
39
+ const reactions = [reaction, ...chosenReactions.map((v) => v.reaction)];
40
+ await this.setReactions(chatId, messageId, reactions, params);
41
+ }
42
+ async removeReaction(chatId, messageId, reaction) {
43
+ const chosenReactions = await __classPrivateFieldGet(this, _ReactionManager_c, "f").messageManager.getMessage(chatId, messageId).then((v) => v?.reactions ?? []).then((v) => v.filter((v) => v.chosen));
44
+ for (const r of chosenReactions) {
45
+ if (reactionEqual(r.reaction, reaction)) {
46
+ const reactions = chosenReactions.filter((v) => v != r).map((v) => v.reaction);
47
+ await this.setReactions(chatId, messageId, reactions);
48
+ break;
49
+ }
50
+ }
51
+ }
52
+ }
53
+ _ReactionManager_c = new WeakMap(), _ReactionManager_instances = new WeakSet(), _ReactionManager_sendReaction = async function _ReactionManager_sendReaction(chatId, messageId, reactions, params) {
54
+ await __classPrivateFieldGet(this, _ReactionManager_c, "f").api.messages.sendReaction({
55
+ peer: await __classPrivateFieldGet(this, _ReactionManager_c, "f").getInputPeer(chatId),
56
+ msg_id: messageId,
57
+ reaction: reactions.map((v) => reactionToTlObject(v)),
58
+ big: params?.big ? true : undefined,
59
+ add_to_recent: params?.addToRecents ? true : undefined,
60
+ });
61
+ };