@mtcute/core 0.30.3 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/client.cjs +85 -0
  2. package/client.js +85 -0
  3. package/highlevel/client.d.cts +411 -116
  4. package/highlevel/client.d.ts +411 -116
  5. package/highlevel/methods/auth/sign-in-qr.cjs +2 -0
  6. package/highlevel/methods/auth/sign-in-qr.js +2 -0
  7. package/highlevel/methods/auth/sign-in-qr.test.d.cts +1 -0
  8. package/highlevel/methods/auth/sign-in-qr.test.d.ts +1 -0
  9. package/highlevel/methods/chats/build-peers-index.cjs +45 -0
  10. package/highlevel/methods/chats/build-peers-index.d.cts +13 -0
  11. package/highlevel/methods/chats/build-peers-index.d.ts +13 -0
  12. package/highlevel/methods/chats/build-peers-index.js +40 -0
  13. package/highlevel/methods/chats/join-chat.cjs +1 -1
  14. package/highlevel/methods/chats/join-chat.d.cts +2 -1
  15. package/highlevel/methods/chats/join-chat.d.ts +2 -1
  16. package/highlevel/methods/chats/join-chat.js +1 -1
  17. package/highlevel/methods/chats/transfer-chat-ownership.cjs +6 -17
  18. package/highlevel/methods/chats/transfer-chat-ownership.js +6 -17
  19. package/highlevel/methods/communities/ban-community-participant.cjs +30 -0
  20. package/highlevel/methods/communities/ban-community-participant.d.cts +20 -0
  21. package/highlevel/methods/communities/ban-community-participant.d.ts +20 -0
  22. package/highlevel/methods/communities/ban-community-participant.js +25 -0
  23. package/highlevel/methods/communities/create-community.cjs +29 -0
  24. package/highlevel/methods/communities/create-community.d.cts +22 -0
  25. package/highlevel/methods/communities/create-community.d.ts +22 -0
  26. package/highlevel/methods/communities/create-community.js +24 -0
  27. package/highlevel/methods/communities/get-community-link-requests.cjs +27 -0
  28. package/highlevel/methods/communities/get-community-link-requests.d.cts +17 -0
  29. package/highlevel/methods/communities/get-community-link-requests.d.ts +17 -0
  30. package/highlevel/methods/communities/get-community-link-requests.js +22 -0
  31. package/highlevel/methods/communities/get-community-participant-chats.cjs +24 -0
  32. package/highlevel/methods/communities/get-community-participant-chats.d.cts +17 -0
  33. package/highlevel/methods/communities/get-community-participant-chats.d.ts +17 -0
  34. package/highlevel/methods/communities/get-community-participant-chats.js +19 -0
  35. package/highlevel/methods/communities/get-joined-communities.cjs +21 -0
  36. package/highlevel/methods/communities/get-joined-communities.d.cts +6 -0
  37. package/highlevel/methods/communities/get-joined-communities.d.ts +6 -0
  38. package/highlevel/methods/communities/get-joined-communities.js +16 -0
  39. package/highlevel/methods/communities/hide-community-link-request.cjs +30 -0
  40. package/highlevel/methods/communities/hide-community-link-request.d.cts +22 -0
  41. package/highlevel/methods/communities/hide-community-link-request.d.ts +22 -0
  42. package/highlevel/methods/communities/hide-community-link-request.js +25 -0
  43. package/highlevel/methods/communities/link-community-peer.cjs +32 -0
  44. package/highlevel/methods/communities/link-community-peer.d.cts +22 -0
  45. package/highlevel/methods/communities/link-community-peer.d.ts +22 -0
  46. package/highlevel/methods/communities/link-community-peer.js +27 -0
  47. package/highlevel/methods/communities/toggle-community-collapsed.cjs +18 -0
  48. package/highlevel/methods/communities/toggle-community-collapsed.d.cts +16 -0
  49. package/highlevel/methods/communities/toggle-community-collapsed.d.ts +16 -0
  50. package/highlevel/methods/communities/toggle-community-collapsed.js +13 -0
  51. package/highlevel/methods/ephemeral/delete-all-welcome-messages.cjs +17 -0
  52. package/highlevel/methods/ephemeral/delete-all-welcome-messages.d.cts +8 -0
  53. package/highlevel/methods/ephemeral/delete-all-welcome-messages.d.ts +8 -0
  54. package/highlevel/methods/ephemeral/delete-all-welcome-messages.js +12 -0
  55. package/highlevel/methods/ephemeral/delete-ephemeral-message.cjs +20 -0
  56. package/highlevel/methods/ephemeral/delete-ephemeral-message.d.cts +13 -0
  57. package/highlevel/methods/ephemeral/delete-ephemeral-message.d.ts +13 -0
  58. package/highlevel/methods/ephemeral/delete-ephemeral-message.js +15 -0
  59. package/highlevel/methods/ephemeral/delete-welcome-message.cjs +18 -0
  60. package/highlevel/methods/ephemeral/delete-welcome-message.d.cts +9 -0
  61. package/highlevel/methods/ephemeral/delete-welcome-message.d.ts +9 -0
  62. package/highlevel/methods/ephemeral/delete-welcome-message.js +13 -0
  63. package/highlevel/methods/ephemeral/edit-ephemeral-message.cjs +41 -0
  64. package/highlevel/methods/ephemeral/edit-ephemeral-message.d.cts +39 -0
  65. package/highlevel/methods/ephemeral/edit-ephemeral-message.d.ts +39 -0
  66. package/highlevel/methods/ephemeral/edit-ephemeral-message.js +36 -0
  67. package/highlevel/methods/ephemeral/find-in-update.cjs +27 -0
  68. package/highlevel/methods/ephemeral/find-in-update.d.cts +8 -0
  69. package/highlevel/methods/ephemeral/find-in-update.d.ts +8 -0
  70. package/highlevel/methods/ephemeral/find-in-update.js +22 -0
  71. package/highlevel/methods/ephemeral/get-ephemeral-callback-answer.cjs +31 -0
  72. package/highlevel/methods/ephemeral/get-ephemeral-callback-answer.d.cts +29 -0
  73. package/highlevel/methods/ephemeral/get-ephemeral-callback-answer.d.ts +29 -0
  74. package/highlevel/methods/ephemeral/get-ephemeral-callback-answer.js +26 -0
  75. package/highlevel/methods/ephemeral/get-welcome-messages.cjs +29 -0
  76. package/highlevel/methods/ephemeral/get-welcome-messages.d.cts +8 -0
  77. package/highlevel/methods/ephemeral/get-welcome-messages.d.ts +8 -0
  78. package/highlevel/methods/ephemeral/get-welcome-messages.js +24 -0
  79. package/highlevel/methods/ephemeral/send-ephemeral-message.cjs +48 -0
  80. package/highlevel/methods/ephemeral/send-ephemeral-message.d.cts +47 -0
  81. package/highlevel/methods/ephemeral/send-ephemeral-message.d.ts +47 -0
  82. package/highlevel/methods/ephemeral/send-ephemeral-message.js +43 -0
  83. package/highlevel/methods/files/download-iterable.cjs +7 -2
  84. package/highlevel/methods/files/download-iterable.js +7 -2
  85. package/highlevel/methods/files/download-iterable.test.d.cts +1 -0
  86. package/highlevel/methods/files/download-iterable.test.d.ts +1 -0
  87. package/highlevel/methods/files/download-stream.cjs +5 -6
  88. package/highlevel/methods/files/download-stream.js +5 -6
  89. package/highlevel/methods/files/normalize-input-media.cjs +25 -4
  90. package/highlevel/methods/files/normalize-input-media.js +25 -4
  91. package/highlevel/methods/forums/create-forum-topic.d.cts +7 -0
  92. package/highlevel/methods/forums/create-forum-topic.d.ts +7 -0
  93. package/highlevel/methods/forums/delete-forum-topic-history.d.cts +1 -1
  94. package/highlevel/methods/forums/delete-forum-topic-history.d.ts +1 -1
  95. package/highlevel/methods/forums/edit-forum-topic.cjs +2 -2
  96. package/highlevel/methods/forums/edit-forum-topic.d.cts +2 -2
  97. package/highlevel/methods/forums/edit-forum-topic.d.ts +2 -2
  98. package/highlevel/methods/forums/edit-forum-topic.js +2 -2
  99. package/highlevel/methods/forums/get-forum-topics-by-id.cjs +5 -1
  100. package/highlevel/methods/forums/get-forum-topics-by-id.d.cts +9 -1
  101. package/highlevel/methods/forums/get-forum-topics-by-id.d.ts +9 -1
  102. package/highlevel/methods/forums/get-forum-topics-by-id.js +5 -1
  103. package/highlevel/methods/forums/get-forum-topics-by-id.test.d.cts +1 -0
  104. package/highlevel/methods/forums/get-forum-topics-by-id.test.d.ts +1 -0
  105. package/highlevel/methods/forums/get-forum-topics.cjs +1 -1
  106. package/highlevel/methods/forums/get-forum-topics.js +1 -1
  107. package/highlevel/methods/forums/toggle-forum-topic-closed.cjs +1 -1
  108. package/highlevel/methods/forums/toggle-forum-topic-closed.d.cts +1 -1
  109. package/highlevel/methods/forums/toggle-forum-topic-closed.d.ts +1 -1
  110. package/highlevel/methods/forums/toggle-forum-topic-closed.js +1 -1
  111. package/highlevel/methods/forums/toggle-forum-topic-pinned.d.cts +1 -1
  112. package/highlevel/methods/forums/toggle-forum-topic-pinned.d.ts +1 -1
  113. package/highlevel/methods/forums/toggle-general-topic-hidden.cjs +3 -3
  114. package/highlevel/methods/forums/toggle-general-topic-hidden.js +4 -4
  115. package/highlevel/methods/gifts/buy-resale-gift.cjs +5 -2
  116. package/highlevel/methods/gifts/buy-resale-gift.d.cts +11 -1
  117. package/highlevel/methods/gifts/buy-resale-gift.d.ts +11 -1
  118. package/highlevel/methods/gifts/buy-resale-gift.js +5 -2
  119. package/highlevel/methods/messages/forward-messages.cjs +1 -0
  120. package/highlevel/methods/messages/forward-messages.d.cts +2 -0
  121. package/highlevel/methods/messages/forward-messages.d.ts +2 -0
  122. package/highlevel/methods/messages/forward-messages.js +1 -0
  123. package/highlevel/methods/messages/normalize-rich-message.cjs +3 -0
  124. package/highlevel/methods/messages/normalize-rich-message.js +3 -0
  125. package/highlevel/methods/messages/send-common.d.cts +7 -1
  126. package/highlevel/methods/messages/send-common.d.ts +7 -1
  127. package/highlevel/methods/messages/send-text.cjs +70 -35
  128. package/highlevel/methods/messages/send-text.js +70 -35
  129. package/highlevel/methods/messages/send-typing.d.cts +3 -3
  130. package/highlevel/methods/messages/send-typing.d.ts +3 -3
  131. package/highlevel/methods/messages/set-typing.cjs +1 -1
  132. package/highlevel/methods/messages/set-typing.d.cts +2 -2
  133. package/highlevel/methods/messages/set-typing.d.ts +2 -2
  134. package/highlevel/methods/messages/set-typing.js +1 -1
  135. package/highlevel/methods/users/resolve-peer.cjs +11 -1
  136. package/highlevel/methods/users/resolve-peer.js +11 -1
  137. package/highlevel/methods.d.cts +19 -0
  138. package/highlevel/methods.d.ts +19 -0
  139. package/highlevel/storage/service/peers.cjs +25 -0
  140. package/highlevel/storage/service/peers.js +25 -0
  141. package/highlevel/storage/service/peers.test.d.cts +1 -0
  142. package/highlevel/storage/service/peers.test.d.ts +1 -0
  143. package/highlevel/types/bots/keyboards/builder.cjs +5 -5
  144. package/highlevel/types/bots/keyboards/builder.d.cts +8 -9
  145. package/highlevel/types/bots/keyboards/builder.d.ts +8 -9
  146. package/highlevel/types/bots/keyboards/builder.js +5 -5
  147. package/highlevel/types/bots/keyboards/factories.cjs +51 -103
  148. package/highlevel/types/bots/keyboards/factories.d.cts +58 -89
  149. package/highlevel/types/bots/keyboards/factories.d.ts +58 -89
  150. package/highlevel/types/bots/keyboards/factories.js +51 -103
  151. package/highlevel/types/bots/keyboards/index.d.cts +3 -3
  152. package/highlevel/types/bots/keyboards/index.d.ts +3 -3
  153. package/highlevel/types/bots/keyboards/normalize.cjs +131 -0
  154. package/highlevel/types/bots/keyboards/normalize.d.cts +10 -0
  155. package/highlevel/types/bots/keyboards/normalize.d.ts +10 -0
  156. package/highlevel/types/bots/keyboards/normalize.js +126 -0
  157. package/highlevel/types/bots/keyboards/types.d.cts +160 -4
  158. package/highlevel/types/bots/keyboards/types.d.ts +160 -4
  159. package/highlevel/types/conversation.cjs +8 -0
  160. package/highlevel/types/conversation.d.cts +1 -0
  161. package/highlevel/types/conversation.d.ts +1 -0
  162. package/highlevel/types/conversation.js +10 -2
  163. package/highlevel/types/conversation.test.d.cts +1 -0
  164. package/highlevel/types/conversation.test.d.ts +1 -0
  165. package/highlevel/types/messages/dialog.cjs +8 -1
  166. package/highlevel/types/messages/dialog.d.cts +3 -0
  167. package/highlevel/types/messages/dialog.d.ts +3 -0
  168. package/highlevel/types/messages/dialog.js +8 -1
  169. package/highlevel/types/messages/dialog.test.d.cts +1 -0
  170. package/highlevel/types/messages/dialog.test.d.ts +1 -0
  171. package/highlevel/types/messages/ephemeral-message.cjs +135 -0
  172. package/highlevel/types/messages/ephemeral-message.d.cts +75 -0
  173. package/highlevel/types/messages/ephemeral-message.d.ts +75 -0
  174. package/highlevel/types/messages/ephemeral-message.js +130 -0
  175. package/highlevel/types/messages/index.d.cts +1 -0
  176. package/highlevel/types/messages/index.d.ts +1 -0
  177. package/highlevel/types/messages/message-action.cjs +14 -1
  178. package/highlevel/types/messages/message-action.d.cts +18 -1
  179. package/highlevel/types/messages/message-action.d.ts +18 -1
  180. package/highlevel/types/messages/message-action.js +14 -1
  181. package/highlevel/types/messages/message.cjs +7 -2
  182. package/highlevel/types/messages/message.d.cts +2 -2
  183. package/highlevel/types/messages/message.d.ts +2 -2
  184. package/highlevel/types/messages/message.js +8 -3
  185. package/highlevel/types/messages/replied-message.cjs +5 -1
  186. package/highlevel/types/messages/replied-message.d.cts +5 -1
  187. package/highlevel/types/messages/replied-message.d.ts +5 -1
  188. package/highlevel/types/messages/replied-message.js +5 -1
  189. package/highlevel/types/messages/rich/inner.cjs +37 -0
  190. package/highlevel/types/messages/rich/inner.d.cts +19 -0
  191. package/highlevel/types/messages/rich/inner.d.ts +19 -0
  192. package/highlevel/types/messages/rich/inner.js +37 -0
  193. package/highlevel/types/peers/chat.cjs +23 -3
  194. package/highlevel/types/peers/chat.d.cts +8 -3
  195. package/highlevel/types/peers/chat.d.ts +8 -3
  196. package/highlevel/types/peers/chat.js +24 -4
  197. package/highlevel/types/peers/community-peer.cjs +60 -0
  198. package/highlevel/types/peers/community-peer.d.cts +37 -0
  199. package/highlevel/types/peers/community-peer.d.ts +37 -0
  200. package/highlevel/types/peers/community-peer.js +55 -0
  201. package/highlevel/types/peers/full-chat.cjs +24 -5
  202. package/highlevel/types/peers/full-chat.d.cts +7 -0
  203. package/highlevel/types/peers/full-chat.d.ts +7 -0
  204. package/highlevel/types/peers/full-chat.js +24 -5
  205. package/highlevel/types/peers/index.d.cts +1 -0
  206. package/highlevel/types/peers/index.d.ts +1 -0
  207. package/highlevel/types/peers/peer.cjs +2 -0
  208. package/highlevel/types/peers/peer.js +2 -0
  209. package/highlevel/types/peers/typing-status.d.cts +4 -1
  210. package/highlevel/types/peers/typing-status.d.ts +4 -1
  211. package/highlevel/types/peers/user.cjs +6 -0
  212. package/highlevel/types/peers/user.d.cts +2 -0
  213. package/highlevel/types/peers/user.d.ts +2 -0
  214. package/highlevel/types/peers/user.js +6 -0
  215. package/highlevel/types/updates/delete-ephemeral-messages-update.cjs +27 -0
  216. package/highlevel/types/updates/delete-ephemeral-messages-update.d.cts +15 -0
  217. package/highlevel/types/updates/delete-ephemeral-messages-update.d.ts +15 -0
  218. package/highlevel/types/updates/delete-ephemeral-messages-update.js +22 -0
  219. package/highlevel/types/updates/ephemeral-callback-query.cjs +69 -0
  220. package/highlevel/types/updates/ephemeral-callback-query.d.cts +44 -0
  221. package/highlevel/types/updates/ephemeral-callback-query.d.ts +44 -0
  222. package/highlevel/types/updates/ephemeral-callback-query.js +64 -0
  223. package/highlevel/types/updates/index.d.cts +16 -2
  224. package/highlevel/types/updates/index.d.ts +16 -2
  225. package/highlevel/types/updates/parse-update.cjs +12 -1
  226. package/highlevel/types/updates/parse-update.js +12 -1
  227. package/highlevel/types/updates/user-typing-update.cjs +18 -0
  228. package/highlevel/types/updates/user-typing-update.d.cts +9 -0
  229. package/highlevel/types/updates/user-typing-update.d.ts +9 -0
  230. package/highlevel/types/updates/user-typing-update.js +18 -0
  231. package/highlevel/updates/manager.cjs +71 -41
  232. package/highlevel/updates/manager.d.cts +1 -0
  233. package/highlevel/updates/manager.d.ts +1 -0
  234. package/highlevel/updates/manager.js +71 -41
  235. package/highlevel/updates/manager.test.d.cts +1 -0
  236. package/highlevel/updates/manager.test.d.ts +1 -0
  237. package/highlevel/utils/stream-utils.cjs +8 -4
  238. package/highlevel/utils/stream-utils.js +8 -4
  239. package/highlevel/utils/stream-utils.test.d.cts +1 -0
  240. package/highlevel/utils/stream-utils.test.d.ts +1 -0
  241. package/highlevel/utils/walk-page-blocks.cjs +9 -0
  242. package/highlevel/utils/walk-page-blocks.js +9 -0
  243. package/index.cjs +10 -0
  244. package/index.js +11 -1
  245. package/methods.cjs +33 -0
  246. package/methods.js +33 -0
  247. package/network/client.cjs +4 -3
  248. package/network/client.d.cts +1 -0
  249. package/network/client.d.ts +1 -0
  250. package/network/client.js +4 -3
  251. package/network/middlewares/flood-waiter.cjs +2 -2
  252. package/network/middlewares/flood-waiter.js +2 -2
  253. package/network/middlewares/internal-errors.cjs +1 -1
  254. package/network/middlewares/internal-errors.js +1 -1
  255. package/network/middlewares/media-throttle.cjs +1 -1
  256. package/network/middlewares/media-throttle.js +1 -1
  257. package/network/mtproto-session.cjs +9 -2
  258. package/network/mtproto-session.d.cts +3 -1
  259. package/network/mtproto-session.d.ts +3 -1
  260. package/network/mtproto-session.js +9 -2
  261. package/network/mtproxy/index.cjs +4 -3
  262. package/network/mtproxy/index.d.cts +2 -2
  263. package/network/mtproxy/index.d.ts +2 -2
  264. package/network/mtproxy/index.js +4 -3
  265. package/network/network-manager.cjs +44 -16
  266. package/network/network-manager.d.cts +10 -3
  267. package/network/network-manager.d.ts +10 -3
  268. package/network/network-manager.js +45 -17
  269. package/network/network-manager.test.d.cts +1 -0
  270. package/network/network-manager.test.d.ts +1 -0
  271. package/network/persistent-connection.cjs +10 -2
  272. package/network/persistent-connection.js +10 -2
  273. package/network/session-connection.cjs +15 -6
  274. package/network/session-connection.js +15 -6
  275. package/network/session-connection.test.d.cts +1 -0
  276. package/network/session-connection.test.d.ts +1 -0
  277. package/network/transports/abstract.cjs +16 -0
  278. package/network/transports/abstract.d.cts +8 -2
  279. package/network/transports/abstract.d.ts +8 -2
  280. package/network/transports/abstract.js +17 -1
  281. package/network/transports/obfuscated.cjs +3 -1
  282. package/network/transports/obfuscated.js +3 -1
  283. package/package.json +6 -6
  284. package/tl/api-schema.json +1 -1
  285. package/tl/binary/reader.cjs +221 -103
  286. package/tl/binary/reader.js +221 -103
  287. package/tl/binary/writer.cjs +693 -277
  288. package/tl/binary/writer.js +693 -277
  289. package/tl/compat/reader.cjs +93 -0
  290. package/tl/compat/reader.js +93 -0
  291. package/tl/index.d.cts +12529 -4762
  292. package/tl/index.d.ts +12529 -4762
  293. package/tl/inner-tl.cjs +90 -24
  294. package/tl/inner-tl.js +90 -24
  295. package/tl/raw-errors.json +1 -1
  296. package/tl/rpc-error.test.d.cts +1 -0
  297. package/tl/rpc-error.test.d.ts +1 -0
  298. package/utils/abort-signal.cjs +1 -12
  299. package/utils/abort-signal.js +1 -12
  300. package/utils/abort-signal.test.d.cts +1 -0
  301. package/utils/abort-signal.test.d.ts +1 -0
  302. package/utils/binary/compat.cjs +189 -29
  303. package/utils/binary/compat.js +189 -29
  304. package/utils/early-timer.cjs +3 -11
  305. package/utils/early-timer.js +3 -11
  306. package/utils/early-timer.test.d.cts +1 -0
  307. package/utils/early-timer.test.d.ts +1 -0
  308. package/utils/function-utils.cjs +9 -4
  309. package/utils/function-utils.js +9 -4
  310. package/utils/links/bots.cjs +10 -2
  311. package/utils/links/bots.js +10 -2
  312. package/utils/peer-utils.cjs +8 -0
  313. package/utils/peer-utils.js +8 -0
@@ -85,7 +85,9 @@ async function signInQr(client, params) {
85
85
  ]);
86
86
  break;
87
87
  case "auth.loginTokenMigrateTo": {
88
+ abortSignal?.throwIfAborted();
88
89
  await client.changePrimaryDc(res.dcId);
90
+ abortSignal?.throwIfAborted();
89
91
  let res2;
90
92
  try {
91
93
  res2 = await client.call(
@@ -78,7 +78,9 @@ async function signInQr(client, params) {
78
78
  ]);
79
79
  break;
80
80
  case "auth.loginTokenMigrateTo": {
81
+ abortSignal?.throwIfAborted();
81
82
  await client.changePrimaryDc(res.dcId);
83
+ abortSignal?.throwIfAborted();
82
84
  let res2;
83
85
  try {
84
86
  res2 = await client.call(
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,45 @@
1
+ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
+ globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
+ console.warn("[@mtcute/core] CommonJS bundles are deprecated. They will be removed completely in one of the upcoming releases. No support is provided for CommonJS users. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
+ }
6
+ "use strict";
7
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ const errors = require("../../../types/errors.cjs");
9
+ const peerUtils = require("../../../utils/peer-utils.cjs");
10
+ const peersIndex = require("../../types/peers/peers-index.cjs");
11
+ const resolvePeer = require("../users/resolve-peer.cjs");
12
+ const batchedQueries = require("./batched-queries.cjs");
13
+ async function _buildPeersIndex(client, context, peersToFetch) {
14
+ const peers = new peersIndex.PeersIndex();
15
+ await Promise.all(peersToFetch.map(async (peer) => {
16
+ const id = peerUtils.getMarkedPeerId(peer);
17
+ let cached = await client.storage.peers.getCompleteById(id);
18
+ if (!cached) {
19
+ cached = await batchedQueries._getRawPeerBatched(client, await resolvePeer.resolvePeer(client, peer));
20
+ }
21
+ if (!cached) {
22
+ throw new errors.MtTypeAssertionError(`${context} (@ getCompleteById)`, "user | chat", "null");
23
+ }
24
+ switch (cached._) {
25
+ case "user":
26
+ peers.users.set(cached.id, cached);
27
+ break;
28
+ case "chat":
29
+ case "chatForbidden":
30
+ case "channel":
31
+ case "channelForbidden":
32
+ peers.chats.set(cached.id, cached);
33
+ break;
34
+ default:
35
+ throw new errors.MtTypeAssertionError(
36
+ `${context} (@ getCompleteById)`,
37
+ "user | chat | channel",
38
+ // not very accurate, but good enough
39
+ cached._
40
+ );
41
+ }
42
+ }));
43
+ return peers;
44
+ }
45
+ exports._buildPeersIndex = _buildPeersIndex;
@@ -0,0 +1,13 @@
1
+ import { tl } from '../../../tl/index.js';
2
+ import { ITelegramClient } from '../../client.types.js';
3
+ import { PeersIndex } from '../../types/peers/peers-index.js';
4
+ /**
5
+ * Build a {@link PeersIndex} for the given peers, using the local storage
6
+ * and falling back to fetching them from the server.
7
+ *
8
+ * Useful for responses that reference peers without including them.
9
+ *
10
+ * @internal
11
+ * @noemit
12
+ */
13
+ export declare function _buildPeersIndex(client: ITelegramClient, context: string, peersToFetch: (tl.TypePeer | tl.TypeInputPeer)[]): Promise<PeersIndex>;
@@ -0,0 +1,13 @@
1
+ import { tl } from '../../../tl/index.js';
2
+ import { ITelegramClient } from '../../client.types.js';
3
+ import { PeersIndex } from '../../types/peers/peers-index.js';
4
+ /**
5
+ * Build a {@link PeersIndex} for the given peers, using the local storage
6
+ * and falling back to fetching them from the server.
7
+ *
8
+ * Useful for responses that reference peers without including them.
9
+ *
10
+ * @internal
11
+ * @noemit
12
+ */
13
+ export declare function _buildPeersIndex(client: ITelegramClient, context: string, peersToFetch: (tl.TypePeer | tl.TypeInputPeer)[]): Promise<PeersIndex>;
@@ -0,0 +1,40 @@
1
+ import { MtTypeAssertionError } from "../../../types/errors.js";
2
+ import { getMarkedPeerId } from "../../../utils/peer-utils.js";
3
+ import { PeersIndex } from "../../types/peers/peers-index.js";
4
+ import { resolvePeer } from "../users/resolve-peer.js";
5
+ import { _getRawPeerBatched } from "./batched-queries.js";
6
+ async function _buildPeersIndex(client, context, peersToFetch) {
7
+ const peers = new PeersIndex();
8
+ await Promise.all(peersToFetch.map(async (peer) => {
9
+ const id = getMarkedPeerId(peer);
10
+ let cached = await client.storage.peers.getCompleteById(id);
11
+ if (!cached) {
12
+ cached = await _getRawPeerBatched(client, await resolvePeer(client, peer));
13
+ }
14
+ if (!cached) {
15
+ throw new MtTypeAssertionError(`${context} (@ getCompleteById)`, "user | chat", "null");
16
+ }
17
+ switch (cached._) {
18
+ case "user":
19
+ peers.users.set(cached.id, cached);
20
+ break;
21
+ case "chat":
22
+ case "chatForbidden":
23
+ case "channel":
24
+ case "channelForbidden":
25
+ peers.chats.set(cached.id, cached);
26
+ break;
27
+ default:
28
+ throw new MtTypeAssertionError(
29
+ `${context} (@ getCompleteById)`,
30
+ "user | chat | channel",
31
+ // not very accurate, but good enough
32
+ cached._
33
+ );
34
+ }
35
+ }));
36
+ return peers;
37
+ }
38
+ export {
39
+ _buildPeersIndex
40
+ };
@@ -47,7 +47,7 @@ async function joinChat(client, chatId) {
47
47
  return {
48
48
  status: "webview",
49
49
  bot: new user.User(peers.user(res.botId)),
50
- webview: res.webview
50
+ queryId: res.queryId
51
51
  };
52
52
  }
53
53
  }
@@ -7,6 +7,7 @@ import { tl } from '../../../tl/index.js';
7
7
  * - `status: 'ok'` - the chat was joined successfully
8
8
  * - `status: 'request_sent'` - a join request was sent and needs to be approved by the chat admin
9
9
  * - `status: 'webview'` - a guard bot requested you to open a webview before joining the chat
10
+ * (use `messages.requestChatJoinWebView` with `queryId` to obtain the webview url)
10
11
  */
11
12
  export type JoinChatResult = {
12
13
  status: 'ok';
@@ -16,7 +17,7 @@ export type JoinChatResult = {
16
17
  } | {
17
18
  status: 'webview';
18
19
  bot: User;
19
- webview: tl.TypeWebViewResult;
20
+ queryId: tl.Long;
20
21
  };
21
22
  /**
22
23
  * Join a channel or supergroup
@@ -7,6 +7,7 @@ import { tl } from '../../../tl/index.js';
7
7
  * - `status: 'ok'` - the chat was joined successfully
8
8
  * - `status: 'request_sent'` - a join request was sent and needs to be approved by the chat admin
9
9
  * - `status: 'webview'` - a guard bot requested you to open a webview before joining the chat
10
+ * (use `messages.requestChatJoinWebView` with `queryId` to obtain the webview url)
10
11
  */
11
12
  export type JoinChatResult = {
12
13
  status: 'ok';
@@ -16,7 +17,7 @@ export type JoinChatResult = {
16
17
  } | {
17
18
  status: 'webview';
18
19
  bot: User;
19
- webview: tl.TypeWebViewResult;
20
+ queryId: tl.Long;
20
21
  };
21
22
  /**
22
23
  * Join a channel or supergroup
@@ -40,7 +40,7 @@ async function joinChat(client, chatId) {
40
40
  return {
41
41
  status: "webview",
42
42
  bot: new User$2(peers.user(res.botId)),
43
- webview: res.webview
43
+ queryId: res.queryId
44
44
  };
45
45
  }
46
46
  }
@@ -5,7 +5,6 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
- const peerUtils = require("../../utils/peer-utils.cjs");
9
8
  const resolvePeer = require("../users/resolve-peer.cjs");
10
9
  async function transferChatOwnership(client, params) {
11
10
  const { chatId, userId } = params;
@@ -15,22 +14,12 @@ async function transferChatOwnership(client, params) {
15
14
  await client.call({ _: "account.getPassword" }),
16
15
  params.password
17
16
  );
18
- let res;
19
- if (peerUtils.isInputPeerChannel(peer)) {
20
- res = await client.call({
21
- _: "channels.editCreator",
22
- channel: peerUtils.toInputChannel(peer),
23
- userId: user,
24
- password
25
- });
26
- } else {
27
- res = await client.call({
28
- _: "messages.editChatCreator",
29
- peer,
30
- userId: user,
31
- password
32
- });
33
- }
17
+ const res = await client.call({
18
+ _: "messages.editChatCreator",
19
+ peer,
20
+ userId: user,
21
+ password
22
+ });
34
23
  client.handleClientUpdate(res);
35
24
  }
36
25
  exports.transferChatOwnership = transferChatOwnership;
@@ -1,4 +1,3 @@
1
- import { isInputPeerChannel, toInputChannel } from "../../utils/peer-utils.js";
2
1
  import { resolvePeer, resolveUser } from "../users/resolve-peer.js";
3
2
  async function transferChatOwnership(client, params) {
4
3
  const { chatId, userId } = params;
@@ -8,22 +7,12 @@ async function transferChatOwnership(client, params) {
8
7
  await client.call({ _: "account.getPassword" }),
9
8
  params.password
10
9
  );
11
- let res;
12
- if (isInputPeerChannel(peer)) {
13
- res = await client.call({
14
- _: "channels.editCreator",
15
- channel: toInputChannel(peer),
16
- userId: user,
17
- password
18
- });
19
- } else {
20
- res = await client.call({
21
- _: "messages.editChatCreator",
22
- peer,
23
- userId: user,
24
- password
25
- });
26
- }
10
+ const res = await client.call({
11
+ _: "messages.editChatCreator",
12
+ peer,
13
+ userId: user,
14
+ password
15
+ });
27
16
  client.handleClientUpdate(res);
28
17
  }
29
18
  export {
@@ -0,0 +1,30 @@
1
+ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
+ globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
+ console.warn("[@mtcute/core] CommonJS bundles are deprecated. They will be removed completely in one of the upcoming releases. No support is provided for CommonJS users. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
+ }
6
+ "use strict";
7
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ const typeAssertions = require("../../../utils/type-assertions.cjs");
9
+ const resolvePeer = require("../users/resolve-peer.cjs");
10
+ async function banCommunityParticipant(client, params) {
11
+ const { communityId, participantId } = params;
12
+ const r = await client.call({
13
+ _: "communities.toggleParticipantBanned",
14
+ community: await resolvePeer.resolveChannel(client, communityId),
15
+ participant: await resolvePeer.resolvePeer(client, participantId)
16
+ });
17
+ typeAssertions.assertTrue("communities.toggleParticipantBanned", r);
18
+ }
19
+ async function unbanCommunityParticipant(client, params) {
20
+ const { communityId, participantId } = params;
21
+ const r = await client.call({
22
+ _: "communities.toggleParticipantBanned",
23
+ community: await resolvePeer.resolveChannel(client, communityId),
24
+ participant: await resolvePeer.resolvePeer(client, participantId),
25
+ unban: true
26
+ });
27
+ typeAssertions.assertTrue("communities.toggleParticipantBanned", r);
28
+ }
29
+ exports.banCommunityParticipant = banCommunityParticipant;
30
+ exports.unbanCommunityParticipant = unbanCommunityParticipant;
@@ -0,0 +1,20 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike } from '../../types/index.js';
3
+ /**
4
+ * Ban a participant from a community
5
+ */
6
+ export declare function banCommunityParticipant(client: ITelegramClient, params: {
7
+ /** Community ID */
8
+ communityId: InputPeerLike;
9
+ /** Participant to ban */
10
+ participantId: InputPeerLike;
11
+ }): Promise<void>;
12
+ /**
13
+ * Unban a participant from a community
14
+ */
15
+ export declare function unbanCommunityParticipant(client: ITelegramClient, params: {
16
+ /** Community ID */
17
+ communityId: InputPeerLike;
18
+ /** Participant to unban */
19
+ participantId: InputPeerLike;
20
+ }): Promise<void>;
@@ -0,0 +1,20 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike } from '../../types/index.js';
3
+ /**
4
+ * Ban a participant from a community
5
+ */
6
+ export declare function banCommunityParticipant(client: ITelegramClient, params: {
7
+ /** Community ID */
8
+ communityId: InputPeerLike;
9
+ /** Participant to ban */
10
+ participantId: InputPeerLike;
11
+ }): Promise<void>;
12
+ /**
13
+ * Unban a participant from a community
14
+ */
15
+ export declare function unbanCommunityParticipant(client: ITelegramClient, params: {
16
+ /** Community ID */
17
+ communityId: InputPeerLike;
18
+ /** Participant to unban */
19
+ participantId: InputPeerLike;
20
+ }): Promise<void>;
@@ -0,0 +1,25 @@
1
+ import { assertTrue } from "../../../utils/type-assertions.js";
2
+ import { resolvePeer, resolveChannel } from "../users/resolve-peer.js";
3
+ async function banCommunityParticipant(client, params) {
4
+ const { communityId, participantId } = params;
5
+ const r = await client.call({
6
+ _: "communities.toggleParticipantBanned",
7
+ community: await resolveChannel(client, communityId),
8
+ participant: await resolvePeer(client, participantId)
9
+ });
10
+ assertTrue("communities.toggleParticipantBanned", r);
11
+ }
12
+ async function unbanCommunityParticipant(client, params) {
13
+ const { communityId, participantId } = params;
14
+ const r = await client.call({
15
+ _: "communities.toggleParticipantBanned",
16
+ community: await resolveChannel(client, communityId),
17
+ participant: await resolvePeer(client, participantId),
18
+ unban: true
19
+ });
20
+ assertTrue("communities.toggleParticipantBanned", r);
21
+ }
22
+ export {
23
+ banCommunityParticipant,
24
+ unbanCommunityParticipant
25
+ };
@@ -0,0 +1,29 @@
1
+ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
+ globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
+ console.warn("[@mtcute/core] CommonJS bundles are deprecated. They will be removed completely in one of the upcoming releases. No support is provided for CommonJS users. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
+ }
6
+ "use strict";
7
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ const errors = require("../../../types/errors.cjs");
9
+ const utils = require("../../updates/utils.cjs");
10
+ const resolvePeer = require("../users/resolve-peer.cjs");
11
+ const chat = require("../../types/peers/chat.cjs");
12
+ async function createCommunity(client, params) {
13
+ const { title, chatId, about, hidden, shouldDispatch } = params;
14
+ const res = await client.call({
15
+ _: "communities.create",
16
+ title,
17
+ about,
18
+ hidden,
19
+ peer: await resolvePeer.resolvePeer(client, chatId)
20
+ });
21
+ utils.assertIsUpdatesGroup("communities.create", res);
22
+ client.handleClientUpdate(res, !shouldDispatch);
23
+ const community = res.chats.find((it) => it._ === "community");
24
+ if (!community) {
25
+ throw new errors.MtTypeAssertionError("communities.create (@ .chats)", "community", "none");
26
+ }
27
+ return new chat.Chat(community);
28
+ }
29
+ exports.createCommunity = createCommunity;
@@ -0,0 +1,22 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike, Chat } from '../../types/index.js';
3
+ /**
4
+ * Create a new community
5
+ *
6
+ * @returns Newly created community
7
+ */
8
+ export declare function createCommunity(client: ITelegramClient, params: {
9
+ /** Community title */
10
+ title: string;
11
+ /** Chat to link to the community */
12
+ chatId: InputPeerLike;
13
+ /** Community description */
14
+ about?: string;
15
+ /** Whether the community should be hidden */
16
+ hidden?: boolean;
17
+ /**
18
+ * Whether to dispatch the returned updates
19
+ * to the client's update handler.
20
+ */
21
+ shouldDispatch?: true;
22
+ }): Promise<Chat>;
@@ -0,0 +1,22 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike, Chat } from '../../types/index.js';
3
+ /**
4
+ * Create a new community
5
+ *
6
+ * @returns Newly created community
7
+ */
8
+ export declare function createCommunity(client: ITelegramClient, params: {
9
+ /** Community title */
10
+ title: string;
11
+ /** Chat to link to the community */
12
+ chatId: InputPeerLike;
13
+ /** Community description */
14
+ about?: string;
15
+ /** Whether the community should be hidden */
16
+ hidden?: boolean;
17
+ /**
18
+ * Whether to dispatch the returned updates
19
+ * to the client's update handler.
20
+ */
21
+ shouldDispatch?: true;
22
+ }): Promise<Chat>;
@@ -0,0 +1,24 @@
1
+ import { MtTypeAssertionError } from "../../../types/errors.js";
2
+ import { assertIsUpdatesGroup } from "../../updates/utils.js";
3
+ import { resolvePeer } from "../users/resolve-peer.js";
4
+ import { Chat as Chat$2 } from "../../types/peers/chat.js";
5
+ async function createCommunity(client, params) {
6
+ const { title, chatId, about, hidden, shouldDispatch } = params;
7
+ const res = await client.call({
8
+ _: "communities.create",
9
+ title,
10
+ about,
11
+ hidden,
12
+ peer: await resolvePeer(client, chatId)
13
+ });
14
+ assertIsUpdatesGroup("communities.create", res);
15
+ client.handleClientUpdate(res, !shouldDispatch);
16
+ const community = res.chats.find((it) => it._ === "community");
17
+ if (!community) {
18
+ throw new MtTypeAssertionError("communities.create (@ .chats)", "community", "none");
19
+ }
20
+ return new Chat$2(community);
21
+ }
22
+ export {
23
+ createCommunity
24
+ };
@@ -0,0 +1,27 @@
1
+ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
+ globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
+ console.warn("[@mtcute/core] CommonJS bundles are deprecated. They will be removed completely in one of the upcoming releases. No support is provided for CommonJS users. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
+ }
6
+ "use strict";
7
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ const resolvePeer = require("../users/resolve-peer.cjs");
9
+ const miscUtils = require("../../utils/misc-utils.cjs");
10
+ const communityPeer = require("../../types/peers/community-peer.cjs");
11
+ const peersIndex = require("../../types/peers/peers-index.cjs");
12
+ async function getCommunityLinkRequests(client, communityId, params) {
13
+ const { offset = "", limit = 100 } = params ?? {};
14
+ const res = await client.call({
15
+ _: "communities.getPeerLinkRequests",
16
+ community: await resolvePeer.resolveChannel(client, communityId),
17
+ offset,
18
+ limit
19
+ });
20
+ const peers = peersIndex.PeersIndex.from(res);
21
+ return miscUtils.makeArrayPaginated(
22
+ res.requests.map((it) => new communityPeer.CommunityPeerRequest(it, peers)),
23
+ res.totalCount,
24
+ res.nextOffset
25
+ );
26
+ }
27
+ exports.getCommunityLinkRequests = getCommunityLinkRequests;
@@ -0,0 +1,17 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { ArrayPaginated, InputPeerLike, CommunityPeerRequest } from '../../types/index.js';
3
+ /**
4
+ * Get pending peer link requests for a community
5
+ *
6
+ * @param communityId Community ID
7
+ */
8
+ export declare function getCommunityLinkRequests(client: ITelegramClient, communityId: InputPeerLike, params?: {
9
+ /** Offset for pagination */
10
+ offset?: string;
11
+ /**
12
+ * Maximum number of requests to fetch
13
+ *
14
+ * @default 100
15
+ */
16
+ limit?: number;
17
+ }): Promise<ArrayPaginated<CommunityPeerRequest, string>>;
@@ -0,0 +1,17 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { ArrayPaginated, InputPeerLike, CommunityPeerRequest } from '../../types/index.js';
3
+ /**
4
+ * Get pending peer link requests for a community
5
+ *
6
+ * @param communityId Community ID
7
+ */
8
+ export declare function getCommunityLinkRequests(client: ITelegramClient, communityId: InputPeerLike, params?: {
9
+ /** Offset for pagination */
10
+ offset?: string;
11
+ /**
12
+ * Maximum number of requests to fetch
13
+ *
14
+ * @default 100
15
+ */
16
+ limit?: number;
17
+ }): Promise<ArrayPaginated<CommunityPeerRequest, string>>;
@@ -0,0 +1,22 @@
1
+ import { resolveChannel } from "../users/resolve-peer.js";
2
+ import { makeArrayPaginated } from "../../utils/misc-utils.js";
3
+ import { CommunityPeerRequest as CommunityPeerRequest$2 } from "../../types/peers/community-peer.js";
4
+ import { PeersIndex } from "../../types/peers/peers-index.js";
5
+ async function getCommunityLinkRequests(client, communityId, params) {
6
+ const { offset = "", limit = 100 } = params ?? {};
7
+ const res = await client.call({
8
+ _: "communities.getPeerLinkRequests",
9
+ community: await resolveChannel(client, communityId),
10
+ offset,
11
+ limit
12
+ });
13
+ const peers = PeersIndex.from(res);
14
+ return makeArrayPaginated(
15
+ res.requests.map((it) => new CommunityPeerRequest$2(it, peers)),
16
+ res.totalCount,
17
+ res.nextOffset
18
+ );
19
+ }
20
+ export {
21
+ getCommunityLinkRequests
22
+ };
@@ -0,0 +1,24 @@
1
+ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
+ globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
+ console.warn("[@mtcute/core] CommonJS bundles are deprecated. They will be removed completely in one of the upcoming releases. No support is provided for CommonJS users. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
+ }
6
+ "use strict";
7
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ const resolvePeer = require("../users/resolve-peer.cjs");
9
+ const peersIndex = require("../../types/peers/peers-index.cjs");
10
+ const chat = require("../../types/peers/chat.cjs");
11
+ async function getCommunityParticipantChats(client, params) {
12
+ const { communityId, participantId } = params;
13
+ const res = await client.call({
14
+ _: "communities.getParticipantJoinedChats",
15
+ community: await resolvePeer.resolveChannel(client, communityId),
16
+ participant: await resolvePeer.resolvePeer(client, participantId)
17
+ });
18
+ const peers = peersIndex.PeersIndex.from(res);
19
+ return {
20
+ creatorChats: res.creatorChatIds.map((it) => new chat.Chat(peers.chat(it))),
21
+ joinedChats: res.joinedChatIds.map((it) => new chat.Chat(peers.chat(it)))
22
+ };
23
+ }
24
+ exports.getCommunityParticipantChats = getCommunityParticipantChats;
@@ -0,0 +1,17 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike, Chat } from '../../types/index.js';
3
+ export interface CommunityParticipantChats {
4
+ /** Chats linked to the community that the participant has created */
5
+ creatorChats: Chat[];
6
+ /** Chats linked to the community that the participant has joined */
7
+ joinedChats: Chat[];
8
+ }
9
+ /**
10
+ * Get chats linked to a community that the given participant has joined or created
11
+ */
12
+ export declare function getCommunityParticipantChats(client: ITelegramClient, params: {
13
+ /** Community ID */
14
+ communityId: InputPeerLike;
15
+ /** Participant to fetch the chats for */
16
+ participantId: InputPeerLike;
17
+ }): Promise<CommunityParticipantChats>;
@@ -0,0 +1,17 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike, Chat } from '../../types/index.js';
3
+ export interface CommunityParticipantChats {
4
+ /** Chats linked to the community that the participant has created */
5
+ creatorChats: Chat[];
6
+ /** Chats linked to the community that the participant has joined */
7
+ joinedChats: Chat[];
8
+ }
9
+ /**
10
+ * Get chats linked to a community that the given participant has joined or created
11
+ */
12
+ export declare function getCommunityParticipantChats(client: ITelegramClient, params: {
13
+ /** Community ID */
14
+ communityId: InputPeerLike;
15
+ /** Participant to fetch the chats for */
16
+ participantId: InputPeerLike;
17
+ }): Promise<CommunityParticipantChats>;
@@ -0,0 +1,19 @@
1
+ import { resolvePeer, resolveChannel } from "../users/resolve-peer.js";
2
+ import { PeersIndex } from "../../types/peers/peers-index.js";
3
+ import { Chat as Chat$2 } from "../../types/peers/chat.js";
4
+ async function getCommunityParticipantChats(client, params) {
5
+ const { communityId, participantId } = params;
6
+ const res = await client.call({
7
+ _: "communities.getParticipantJoinedChats",
8
+ community: await resolveChannel(client, communityId),
9
+ participant: await resolvePeer(client, participantId)
10
+ });
11
+ const peers = PeersIndex.from(res);
12
+ return {
13
+ creatorChats: res.creatorChatIds.map((it) => new Chat$2(peers.chat(it))),
14
+ joinedChats: res.joinedChatIds.map((it) => new Chat$2(peers.chat(it)))
15
+ };
16
+ }
17
+ export {
18
+ getCommunityParticipantChats
19
+ };