@mtcute/core 0.11.0 → 0.12.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 (467) hide show
  1. package/cjs/highlevel/client.d.ts +198 -18
  2. package/cjs/highlevel/client.js +53 -0
  3. package/cjs/highlevel/client.js.map +1 -1
  4. package/cjs/highlevel/methods/_imports.js.map +1 -1
  5. package/cjs/highlevel/methods/auth/utils.d.ts +3 -0
  6. package/cjs/highlevel/methods/bots/normalize-command-scope.d.ts +5 -1
  7. package/cjs/highlevel/methods/chats/batched-queries.d.ts +10 -1
  8. package/cjs/highlevel/methods/chats/get-full-chat.d.ts +2 -2
  9. package/cjs/highlevel/methods/chats/get-full-chat.js +1 -1
  10. package/cjs/highlevel/methods/chats/get-full-chat.js.map +1 -1
  11. package/cjs/highlevel/methods/dialogs/get-folders.d.ts +3 -0
  12. package/cjs/highlevel/methods/files/normalize-file-to-document.d.ts +9 -1
  13. package/cjs/highlevel/methods/files/normalize-input-media.d.ts +1 -0
  14. package/cjs/highlevel/methods/files/normalize-input-media.js +11 -10
  15. package/cjs/highlevel/methods/files/normalize-input-media.js.map +1 -1
  16. package/cjs/highlevel/methods/messages/_business-connection.d.ts +7 -0
  17. package/cjs/highlevel/methods/messages/_business-connection.js +42 -0
  18. package/cjs/highlevel/methods/messages/_business-connection.js.map +1 -0
  19. package/cjs/highlevel/methods/messages/close-poll.js +1 -1
  20. package/cjs/highlevel/methods/messages/close-poll.js.map +1 -1
  21. package/cjs/highlevel/methods/messages/edit-message.d.ts +1 -0
  22. package/cjs/highlevel/methods/messages/edit-message.js +2 -1
  23. package/cjs/highlevel/methods/messages/edit-message.js.map +1 -1
  24. package/cjs/highlevel/methods/messages/find-in-update.d.ts +13 -1
  25. package/cjs/highlevel/methods/messages/find-in-update.js +7 -2
  26. package/cjs/highlevel/methods/messages/find-in-update.js.map +1 -1
  27. package/cjs/highlevel/methods/messages/forward-messages.d.ts +5 -0
  28. package/cjs/highlevel/methods/messages/forward-messages.js +2 -0
  29. package/cjs/highlevel/methods/messages/forward-messages.js.map +1 -1
  30. package/cjs/highlevel/methods/messages/get-all-scheduled-messages.d.ts +8 -0
  31. package/cjs/highlevel/methods/messages/get-all-scheduled-messages.js +32 -0
  32. package/cjs/highlevel/methods/messages/get-all-scheduled-messages.js.map +1 -0
  33. package/cjs/highlevel/methods/messages/get-discussion-message.d.ts +4 -0
  34. package/cjs/highlevel/methods/messages/iter-search-global.js +2 -1
  35. package/cjs/highlevel/methods/messages/iter-search-global.js.map +1 -1
  36. package/cjs/highlevel/methods/messages/search-global.d.ts +4 -0
  37. package/cjs/highlevel/methods/messages/search-global.js +2 -1
  38. package/cjs/highlevel/methods/messages/search-global.js.map +1 -1
  39. package/cjs/highlevel/methods/messages/send-common.d.ts +28 -0
  40. package/cjs/highlevel/methods/messages/send-common.js +21 -1
  41. package/cjs/highlevel/methods/messages/send-common.js.map +1 -1
  42. package/cjs/highlevel/methods/messages/send-media-group.js +5 -2
  43. package/cjs/highlevel/methods/messages/send-media-group.js.map +1 -1
  44. package/cjs/highlevel/methods/messages/send-media.js +4 -2
  45. package/cjs/highlevel/methods/messages/send-media.js.map +1 -1
  46. package/cjs/highlevel/methods/messages/send-text.js +4 -2
  47. package/cjs/highlevel/methods/messages/send-text.js.map +1 -1
  48. package/cjs/highlevel/methods/messages/send-typing.d.ts +4 -0
  49. package/cjs/highlevel/methods/messages/send-typing.js +2 -1
  50. package/cjs/highlevel/methods/messages/send-typing.js.map +1 -1
  51. package/cjs/highlevel/methods/misc/chain-id.d.ts +4 -1
  52. package/cjs/highlevel/methods/misc/get-collectible-info.d.ts +6 -0
  53. package/cjs/highlevel/methods/misc/get-collectible-info.js +26 -0
  54. package/cjs/highlevel/methods/misc/get-collectible-info.js.map +1 -0
  55. package/cjs/highlevel/methods/misc/normalize-text.d.ts +5 -1
  56. package/cjs/highlevel/methods/premium/create-business-chat-link.d.ts +12 -0
  57. package/cjs/highlevel/methods/premium/create-business-chat-link.js +26 -0
  58. package/cjs/highlevel/methods/premium/create-business-chat-link.js.map +1 -0
  59. package/cjs/highlevel/methods/premium/edit-business-chat-link.d.ts +20 -0
  60. package/cjs/highlevel/methods/premium/edit-business-chat-link.js +42 -0
  61. package/cjs/highlevel/methods/premium/edit-business-chat-link.js.map +1 -0
  62. package/cjs/highlevel/methods/premium/get-business-chat-links.d.ts +6 -0
  63. package/cjs/highlevel/methods/premium/get-business-chat-links.js +14 -0
  64. package/cjs/highlevel/methods/premium/get-business-chat-links.js.map +1 -0
  65. package/cjs/highlevel/methods/premium/get-business-connection.d.ts +8 -0
  66. package/cjs/highlevel/methods/premium/get-business-connection.js +25 -0
  67. package/cjs/highlevel/methods/premium/get-business-connection.js.map +1 -0
  68. package/cjs/highlevel/methods/premium/set-business-intro.d.ts +22 -0
  69. package/cjs/highlevel/methods/premium/set-business-intro.js +42 -0
  70. package/cjs/highlevel/methods/premium/set-business-intro.js.map +1 -0
  71. package/cjs/highlevel/methods/premium/set-business-work-hours.d.ts +18 -0
  72. package/cjs/highlevel/methods/premium/set-business-work-hours.js +33 -0
  73. package/cjs/highlevel/methods/premium/set-business-work-hours.js.map +1 -0
  74. package/cjs/highlevel/methods/stickers/_utils.d.ts +10 -0
  75. package/cjs/highlevel/methods/stickers/_utils.js +27 -0
  76. package/cjs/highlevel/methods/stickers/_utils.js.map +1 -0
  77. package/cjs/highlevel/methods/stickers/add-sticker-to-set.d.ts +1 -2
  78. package/cjs/highlevel/methods/stickers/add-sticker-to-set.js +3 -17
  79. package/cjs/highlevel/methods/stickers/add-sticker-to-set.js.map +1 -1
  80. package/cjs/highlevel/methods/stickers/create-sticker-set.d.ts +0 -3
  81. package/cjs/highlevel/methods/stickers/create-sticker-set.js +2 -19
  82. package/cjs/highlevel/methods/stickers/create-sticker-set.js.map +1 -1
  83. package/cjs/highlevel/methods/stickers/delete-sticker-from-set.d.ts +1 -2
  84. package/cjs/highlevel/methods/stickers/delete-sticker-from-set.js +1 -2
  85. package/cjs/highlevel/methods/stickers/delete-sticker-from-set.js.map +1 -1
  86. package/cjs/highlevel/methods/stickers/get-installed-stickers.d.ts +1 -2
  87. package/cjs/highlevel/methods/stickers/get-installed-stickers.js +1 -2
  88. package/cjs/highlevel/methods/stickers/get-installed-stickers.js.map +1 -1
  89. package/cjs/highlevel/methods/stickers/get-my-sticker-sets.d.ts +13 -0
  90. package/cjs/highlevel/methods/stickers/get-my-sticker-sets.js +24 -0
  91. package/cjs/highlevel/methods/stickers/get-my-sticker-sets.js.map +1 -0
  92. package/cjs/highlevel/methods/stickers/get-sticker-set.d.ts +2 -2
  93. package/cjs/highlevel/methods/stickers/get-sticker-set.js +2 -2
  94. package/cjs/highlevel/methods/stickers/get-sticker-set.js.map +1 -1
  95. package/cjs/highlevel/methods/stickers/move-sticker-in-set.d.ts +2 -3
  96. package/cjs/highlevel/methods/stickers/move-sticker-in-set.js +2 -3
  97. package/cjs/highlevel/methods/stickers/move-sticker-in-set.js.map +1 -1
  98. package/cjs/highlevel/methods/stickers/replace-sticker-in-set.d.ts +24 -0
  99. package/cjs/highlevel/methods/stickers/replace-sticker-in-set.js +32 -0
  100. package/cjs/highlevel/methods/stickers/replace-sticker-in-set.js.map +1 -0
  101. package/cjs/highlevel/methods/stories/find-in-update.d.ts +5 -1
  102. package/cjs/highlevel/methods/users/set-my-birthday.d.ts +12 -0
  103. package/cjs/highlevel/methods/users/set-my-birthday.js +22 -0
  104. package/cjs/highlevel/methods/users/set-my-birthday.js.map +1 -0
  105. package/cjs/highlevel/methods.d.ts +12 -0
  106. package/cjs/highlevel/methods.js +33 -3
  107. package/cjs/highlevel/methods.js.map +1 -1
  108. package/cjs/highlevel/storage/storage.d.ts +7 -2
  109. package/cjs/highlevel/types/auth/sent-code.d.ts +7 -2
  110. package/cjs/highlevel/types/auth/sent-code.js +14 -0
  111. package/cjs/highlevel/types/auth/sent-code.js.map +1 -1
  112. package/cjs/highlevel/types/bots/inline-message/factories.d.ts +5 -1
  113. package/cjs/highlevel/types/bots/inline-result/factories.d.ts +4 -1
  114. package/cjs/highlevel/types/bots/keyboards/factories.d.ts +7 -1
  115. package/cjs/highlevel/types/calls/discard-reason.d.ts +5 -0
  116. package/cjs/highlevel/types/files/uploaded-file.d.ts +2 -0
  117. package/cjs/highlevel/types/files/utils.d.ts +6 -5
  118. package/cjs/highlevel/types/files/utils.js.map +1 -1
  119. package/cjs/highlevel/types/media/document-utils.d.ts +5 -0
  120. package/cjs/highlevel/types/media/document-utils.js +9 -2
  121. package/cjs/highlevel/types/media/document-utils.js.map +1 -1
  122. package/cjs/highlevel/types/media/input-media/types.d.ts +2 -2
  123. package/cjs/highlevel/types/media/input-media/types.js.map +1 -1
  124. package/cjs/highlevel/types/media/poll.d.ts +17 -6
  125. package/cjs/highlevel/types/media/poll.js +65 -18
  126. package/cjs/highlevel/types/media/poll.js.map +1 -1
  127. package/cjs/highlevel/types/messages/dialog.js +1 -12
  128. package/cjs/highlevel/types/messages/dialog.js.map +1 -1
  129. package/cjs/highlevel/types/messages/input-message-id.d.ts +5 -0
  130. package/cjs/highlevel/types/messages/message-action.d.ts +19 -2
  131. package/cjs/highlevel/types/messages/message-action.js +6 -0
  132. package/cjs/highlevel/types/messages/message-action.js.map +1 -1
  133. package/cjs/highlevel/types/messages/message-media.d.ts +4 -0
  134. package/cjs/highlevel/types/messages/message.d.ts +59 -1
  135. package/cjs/highlevel/types/messages/message.js +96 -1
  136. package/cjs/highlevel/types/messages/message.js.map +1 -1
  137. package/cjs/highlevel/types/misc/collectible-info.d.ts +27 -0
  138. package/cjs/highlevel/types/misc/collectible-info.js +46 -0
  139. package/cjs/highlevel/types/misc/collectible-info.js.map +1 -0
  140. package/cjs/highlevel/types/misc/entities.d.ts +7 -0
  141. package/cjs/highlevel/types/misc/entities.js +15 -0
  142. package/cjs/highlevel/types/misc/entities.js.map +1 -1
  143. package/cjs/highlevel/types/misc/index.d.ts +1 -0
  144. package/cjs/highlevel/types/misc/index.js +1 -0
  145. package/cjs/highlevel/types/misc/index.js.map +1 -1
  146. package/cjs/highlevel/types/misc/sticker-set.d.ts +8 -1
  147. package/cjs/highlevel/types/misc/sticker-set.js +36 -5
  148. package/cjs/highlevel/types/misc/sticker-set.js.map +1 -1
  149. package/cjs/highlevel/types/peers/chat-event/actions.d.ts +3 -0
  150. package/cjs/highlevel/types/peers/chat-event/filters.d.ts +2 -0
  151. package/cjs/highlevel/types/peers/chat.d.ts +7 -93
  152. package/cjs/highlevel/types/peers/chat.js +2 -195
  153. package/cjs/highlevel/types/peers/chat.js.map +1 -1
  154. package/cjs/highlevel/types/peers/full-chat.d.ts +103 -0
  155. package/cjs/highlevel/types/peers/full-chat.js +237 -0
  156. package/cjs/highlevel/types/peers/full-chat.js.map +1 -0
  157. package/cjs/highlevel/types/peers/index.d.ts +1 -0
  158. package/cjs/highlevel/types/peers/index.js +1 -0
  159. package/cjs/highlevel/types/peers/index.js.map +1 -1
  160. package/cjs/highlevel/types/peers/user.d.ts +5 -0
  161. package/cjs/highlevel/types/peers/user.js +7 -0
  162. package/cjs/highlevel/types/peers/user.js.map +1 -1
  163. package/cjs/highlevel/types/premium/business-account.d.ts +19 -0
  164. package/cjs/highlevel/types/premium/business-account.js +45 -0
  165. package/cjs/highlevel/types/premium/business-account.js.map +1 -0
  166. package/cjs/highlevel/types/premium/business-chat-link.d.ts +19 -0
  167. package/cjs/highlevel/types/premium/business-chat-link.js +39 -0
  168. package/cjs/highlevel/types/premium/business-chat-link.js.map +1 -0
  169. package/cjs/highlevel/types/premium/business-connection.d.ts +23 -0
  170. package/cjs/highlevel/types/premium/business-connection.js +45 -0
  171. package/cjs/highlevel/types/premium/business-connection.js.map +1 -0
  172. package/cjs/highlevel/types/premium/business-intro.d.ts +22 -0
  173. package/cjs/highlevel/types/premium/business-intro.js +43 -0
  174. package/cjs/highlevel/types/premium/business-intro.js.map +1 -0
  175. package/cjs/highlevel/types/premium/business-location.d.ts +10 -0
  176. package/cjs/highlevel/types/premium/business-location.js +26 -0
  177. package/cjs/highlevel/types/premium/business-location.js.map +1 -0
  178. package/cjs/highlevel/types/premium/business-work-hours.d.ts +42 -0
  179. package/cjs/highlevel/types/premium/business-work-hours.js +141 -0
  180. package/cjs/highlevel/types/premium/business-work-hours.js.map +1 -0
  181. package/cjs/highlevel/types/premium/index.d.ts +5 -0
  182. package/cjs/highlevel/types/premium/index.js +5 -0
  183. package/cjs/highlevel/types/premium/index.js.map +1 -1
  184. package/cjs/highlevel/types/updates/business-message.d.ts +18 -0
  185. package/cjs/highlevel/types/updates/business-message.js +35 -0
  186. package/cjs/highlevel/types/updates/business-message.js.map +1 -0
  187. package/cjs/highlevel/types/updates/delete-business-message-update.d.ts +21 -0
  188. package/cjs/highlevel/types/updates/delete-business-message-update.js +37 -0
  189. package/cjs/highlevel/types/updates/delete-business-message-update.js.map +1 -0
  190. package/cjs/highlevel/types/updates/index.d.ts +19 -2
  191. package/cjs/highlevel/types/updates/index.js +5 -1
  192. package/cjs/highlevel/types/updates/index.js.map +1 -1
  193. package/cjs/highlevel/types/updates/parse-update.d.ts +4 -1
  194. package/cjs/highlevel/types/updates/parse-update.js +8 -0
  195. package/cjs/highlevel/types/updates/parse-update.js.map +1 -1
  196. package/cjs/highlevel/types/updates/poll-update.js +2 -2
  197. package/cjs/highlevel/types/updates/poll-update.js.map +1 -1
  198. package/cjs/highlevel/updates/manager.d.ts +0 -1
  199. package/cjs/highlevel/updates/manager.js +7 -2
  200. package/cjs/highlevel/updates/manager.js.map +1 -1
  201. package/cjs/highlevel/updates/parsed.js +8 -2
  202. package/cjs/highlevel/updates/parsed.js.map +1 -1
  203. package/cjs/highlevel/updates/types.d.ts +57 -0
  204. package/cjs/highlevel/updates/utils.d.ts +2 -0
  205. package/cjs/highlevel/utils/inspectable.js +7 -0
  206. package/cjs/highlevel/utils/inspectable.js.map +1 -1
  207. package/cjs/highlevel/worker/index.js +6 -0
  208. package/cjs/highlevel/worker/protocol.d.ts +0 -1
  209. package/cjs/index.js +6 -0
  210. package/cjs/network/client.d.ts +0 -1
  211. package/cjs/network/mtproto-session.d.ts +0 -1
  212. package/cjs/network/multi-session-connection.d.ts +0 -1
  213. package/cjs/network/network-manager.d.ts +8 -0
  214. package/cjs/network/network-manager.js +9 -4
  215. package/cjs/network/network-manager.js.map +1 -1
  216. package/cjs/network/persistent-connection.d.ts +0 -1
  217. package/cjs/network/session-connection.js +10 -0
  218. package/cjs/network/session-connection.js.map +1 -1
  219. package/cjs/network/transports/abstract.d.ts +0 -1
  220. package/cjs/network/transports/streamed.d.ts +0 -1
  221. package/cjs/network/transports/wrapped.d.ts +0 -1
  222. package/cjs/platform.js +6 -0
  223. package/cjs/storage/sqlite/repository/peers.js +1 -2
  224. package/cjs/storage/sqlite/repository/peers.js.map +1 -1
  225. package/cjs/storage/storage.d.ts +21 -0
  226. package/cjs/types/utils.d.ts +1 -0
  227. package/cjs/types/utils.js.map +1 -1
  228. package/cjs/utils/index.js +6 -0
  229. package/cjs/utils/reloadable.d.ts +0 -1
  230. package/client.d.ts +1 -0
  231. package/client.js +1 -0
  232. package/esm/highlevel/client.d.ts +198 -18
  233. package/esm/highlevel/client.js +47 -0
  234. package/esm/highlevel/client.js.map +1 -1
  235. package/esm/highlevel/methods/_imports.js.map +1 -1
  236. package/esm/highlevel/methods/auth/utils.d.ts +3 -0
  237. package/esm/highlevel/methods/bots/normalize-command-scope.d.ts +5 -1
  238. package/esm/highlevel/methods/chats/batched-queries.d.ts +10 -1
  239. package/esm/highlevel/methods/chats/get-full-chat.d.ts +2 -2
  240. package/esm/highlevel/methods/chats/get-full-chat.js +2 -2
  241. package/esm/highlevel/methods/chats/get-full-chat.js.map +1 -1
  242. package/esm/highlevel/methods/dialogs/get-folders.d.ts +3 -0
  243. package/esm/highlevel/methods/files/normalize-file-to-document.d.ts +9 -1
  244. package/esm/highlevel/methods/files/normalize-input-media.d.ts +1 -0
  245. package/esm/highlevel/methods/files/normalize-input-media.js +11 -10
  246. package/esm/highlevel/methods/files/normalize-input-media.js.map +1 -1
  247. package/esm/highlevel/methods/messages/_business-connection.d.ts +7 -0
  248. package/esm/highlevel/methods/messages/_business-connection.js +38 -0
  249. package/esm/highlevel/methods/messages/_business-connection.js.map +1 -0
  250. package/esm/highlevel/methods/messages/close-poll.js +1 -1
  251. package/esm/highlevel/methods/messages/close-poll.js.map +1 -1
  252. package/esm/highlevel/methods/messages/edit-message.d.ts +1 -0
  253. package/esm/highlevel/methods/messages/edit-message.js +2 -1
  254. package/esm/highlevel/methods/messages/edit-message.js.map +1 -1
  255. package/esm/highlevel/methods/messages/find-in-update.d.ts +13 -1
  256. package/esm/highlevel/methods/messages/find-in-update.js +7 -2
  257. package/esm/highlevel/methods/messages/find-in-update.js.map +1 -1
  258. package/esm/highlevel/methods/messages/forward-messages.d.ts +5 -0
  259. package/esm/highlevel/methods/messages/forward-messages.js +2 -0
  260. package/esm/highlevel/methods/messages/forward-messages.js.map +1 -1
  261. package/esm/highlevel/methods/messages/get-all-scheduled-messages.d.ts +8 -0
  262. package/esm/highlevel/methods/messages/get-all-scheduled-messages.js +25 -0
  263. package/esm/highlevel/methods/messages/get-all-scheduled-messages.js.map +1 -0
  264. package/esm/highlevel/methods/messages/get-discussion-message.d.ts +4 -0
  265. package/esm/highlevel/methods/messages/iter-search-global.js +2 -1
  266. package/esm/highlevel/methods/messages/iter-search-global.js.map +1 -1
  267. package/esm/highlevel/methods/messages/search-global.d.ts +4 -0
  268. package/esm/highlevel/methods/messages/search-global.js +2 -1
  269. package/esm/highlevel/methods/messages/search-global.js.map +1 -1
  270. package/esm/highlevel/methods/messages/send-common.d.ts +28 -0
  271. package/esm/highlevel/methods/messages/send-common.js +19 -0
  272. package/esm/highlevel/methods/messages/send-common.js.map +1 -1
  273. package/esm/highlevel/methods/messages/send-media-group.js +5 -2
  274. package/esm/highlevel/methods/messages/send-media-group.js.map +1 -1
  275. package/esm/highlevel/methods/messages/send-media.js +4 -2
  276. package/esm/highlevel/methods/messages/send-media.js.map +1 -1
  277. package/esm/highlevel/methods/messages/send-text.js +4 -2
  278. package/esm/highlevel/methods/messages/send-text.js.map +1 -1
  279. package/esm/highlevel/methods/messages/send-typing.d.ts +4 -0
  280. package/esm/highlevel/methods/messages/send-typing.js +2 -1
  281. package/esm/highlevel/methods/messages/send-typing.js.map +1 -1
  282. package/esm/highlevel/methods/misc/chain-id.d.ts +4 -1
  283. package/esm/highlevel/methods/misc/get-collectible-info.d.ts +6 -0
  284. package/esm/highlevel/methods/misc/get-collectible-info.js +22 -0
  285. package/esm/highlevel/methods/misc/get-collectible-info.js.map +1 -0
  286. package/esm/highlevel/methods/misc/normalize-text.d.ts +5 -1
  287. package/esm/highlevel/methods/premium/create-business-chat-link.d.ts +12 -0
  288. package/esm/highlevel/methods/premium/create-business-chat-link.js +22 -0
  289. package/esm/highlevel/methods/premium/create-business-chat-link.js.map +1 -0
  290. package/esm/highlevel/methods/premium/edit-business-chat-link.d.ts +20 -0
  291. package/esm/highlevel/methods/premium/edit-business-chat-link.js +37 -0
  292. package/esm/highlevel/methods/premium/edit-business-chat-link.js.map +1 -0
  293. package/esm/highlevel/methods/premium/get-business-chat-links.d.ts +6 -0
  294. package/esm/highlevel/methods/premium/get-business-chat-links.js +10 -0
  295. package/esm/highlevel/methods/premium/get-business-chat-links.js.map +1 -0
  296. package/esm/highlevel/methods/premium/get-business-connection.d.ts +8 -0
  297. package/esm/highlevel/methods/premium/get-business-connection.js +21 -0
  298. package/esm/highlevel/methods/premium/get-business-connection.js.map +1 -0
  299. package/esm/highlevel/methods/premium/set-business-intro.d.ts +22 -0
  300. package/esm/highlevel/methods/premium/set-business-intro.js +38 -0
  301. package/esm/highlevel/methods/premium/set-business-intro.js.map +1 -0
  302. package/esm/highlevel/methods/premium/set-business-work-hours.d.ts +18 -0
  303. package/esm/highlevel/methods/premium/set-business-work-hours.js +29 -0
  304. package/esm/highlevel/methods/premium/set-business-work-hours.js.map +1 -0
  305. package/esm/highlevel/methods/stickers/_utils.d.ts +10 -0
  306. package/esm/highlevel/methods/stickers/_utils.js +23 -0
  307. package/esm/highlevel/methods/stickers/_utils.js.map +1 -0
  308. package/esm/highlevel/methods/stickers/add-sticker-to-set.d.ts +1 -2
  309. package/esm/highlevel/methods/stickers/add-sticker-to-set.js +4 -18
  310. package/esm/highlevel/methods/stickers/add-sticker-to-set.js.map +1 -1
  311. package/esm/highlevel/methods/stickers/create-sticker-set.d.ts +0 -3
  312. package/esm/highlevel/methods/stickers/create-sticker-set.js +3 -20
  313. package/esm/highlevel/methods/stickers/create-sticker-set.js.map +1 -1
  314. package/esm/highlevel/methods/stickers/delete-sticker-from-set.d.ts +1 -2
  315. package/esm/highlevel/methods/stickers/delete-sticker-from-set.js +1 -2
  316. package/esm/highlevel/methods/stickers/delete-sticker-from-set.js.map +1 -1
  317. package/esm/highlevel/methods/stickers/get-installed-stickers.d.ts +1 -2
  318. package/esm/highlevel/methods/stickers/get-installed-stickers.js +1 -2
  319. package/esm/highlevel/methods/stickers/get-installed-stickers.js.map +1 -1
  320. package/esm/highlevel/methods/stickers/get-my-sticker-sets.d.ts +13 -0
  321. package/esm/highlevel/methods/stickers/get-my-sticker-sets.js +17 -0
  322. package/esm/highlevel/methods/stickers/get-my-sticker-sets.js.map +1 -0
  323. package/esm/highlevel/methods/stickers/get-sticker-set.d.ts +2 -2
  324. package/esm/highlevel/methods/stickers/get-sticker-set.js +2 -2
  325. package/esm/highlevel/methods/stickers/get-sticker-set.js.map +1 -1
  326. package/esm/highlevel/methods/stickers/move-sticker-in-set.d.ts +2 -3
  327. package/esm/highlevel/methods/stickers/move-sticker-in-set.js +2 -3
  328. package/esm/highlevel/methods/stickers/move-sticker-in-set.js.map +1 -1
  329. package/esm/highlevel/methods/stickers/replace-sticker-in-set.d.ts +24 -0
  330. package/esm/highlevel/methods/stickers/replace-sticker-in-set.js +28 -0
  331. package/esm/highlevel/methods/stickers/replace-sticker-in-set.js.map +1 -0
  332. package/esm/highlevel/methods/stories/find-in-update.d.ts +5 -1
  333. package/esm/highlevel/methods/users/set-my-birthday.d.ts +12 -0
  334. package/esm/highlevel/methods/users/set-my-birthday.js +18 -0
  335. package/esm/highlevel/methods/users/set-my-birthday.js.map +1 -0
  336. package/esm/highlevel/methods.d.ts +12 -0
  337. package/esm/highlevel/methods.js +12 -0
  338. package/esm/highlevel/methods.js.map +1 -1
  339. package/esm/highlevel/storage/storage.d.ts +7 -2
  340. package/esm/highlevel/types/auth/sent-code.d.ts +7 -2
  341. package/esm/highlevel/types/auth/sent-code.js +14 -0
  342. package/esm/highlevel/types/auth/sent-code.js.map +1 -1
  343. package/esm/highlevel/types/bots/inline-message/factories.d.ts +5 -1
  344. package/esm/highlevel/types/bots/inline-result/factories.d.ts +4 -1
  345. package/esm/highlevel/types/bots/keyboards/factories.d.ts +7 -1
  346. package/esm/highlevel/types/calls/discard-reason.d.ts +5 -0
  347. package/esm/highlevel/types/files/uploaded-file.d.ts +2 -0
  348. package/esm/highlevel/types/files/utils.d.ts +6 -5
  349. package/esm/highlevel/types/files/utils.js.map +1 -1
  350. package/esm/highlevel/types/media/document-utils.d.ts +5 -0
  351. package/esm/highlevel/types/media/document-utils.js +7 -1
  352. package/esm/highlevel/types/media/document-utils.js.map +1 -1
  353. package/esm/highlevel/types/media/input-media/types.d.ts +2 -2
  354. package/esm/highlevel/types/media/input-media/types.js.map +1 -1
  355. package/esm/highlevel/types/media/poll.d.ts +17 -6
  356. package/esm/highlevel/types/media/poll.js +64 -17
  357. package/esm/highlevel/types/media/poll.js.map +1 -1
  358. package/esm/highlevel/types/messages/dialog.js +1 -12
  359. package/esm/highlevel/types/messages/dialog.js.map +1 -1
  360. package/esm/highlevel/types/messages/input-message-id.d.ts +5 -0
  361. package/esm/highlevel/types/messages/message-action.d.ts +19 -2
  362. package/esm/highlevel/types/messages/message-action.js +6 -0
  363. package/esm/highlevel/types/messages/message-action.js.map +1 -1
  364. package/esm/highlevel/types/messages/message-media.d.ts +4 -0
  365. package/esm/highlevel/types/messages/message.d.ts +59 -1
  366. package/esm/highlevel/types/messages/message.js +96 -1
  367. package/esm/highlevel/types/messages/message.js.map +1 -1
  368. package/esm/highlevel/types/misc/collectible-info.d.ts +27 -0
  369. package/esm/highlevel/types/misc/collectible-info.js +43 -0
  370. package/esm/highlevel/types/misc/collectible-info.js.map +1 -0
  371. package/esm/highlevel/types/misc/entities.d.ts +7 -0
  372. package/esm/highlevel/types/misc/entities.js +13 -1
  373. package/esm/highlevel/types/misc/entities.js.map +1 -1
  374. package/esm/highlevel/types/misc/index.d.ts +1 -0
  375. package/esm/highlevel/types/misc/index.js +1 -0
  376. package/esm/highlevel/types/misc/index.js.map +1 -1
  377. package/esm/highlevel/types/misc/sticker-set.d.ts +8 -1
  378. package/esm/highlevel/types/misc/sticker-set.js +38 -7
  379. package/esm/highlevel/types/misc/sticker-set.js.map +1 -1
  380. package/esm/highlevel/types/peers/chat-event/actions.d.ts +3 -0
  381. package/esm/highlevel/types/peers/chat-event/filters.d.ts +2 -0
  382. package/esm/highlevel/types/peers/chat.d.ts +7 -93
  383. package/esm/highlevel/types/peers/chat.js +2 -195
  384. package/esm/highlevel/types/peers/chat.js.map +1 -1
  385. package/esm/highlevel/types/peers/full-chat.d.ts +103 -0
  386. package/esm/highlevel/types/peers/full-chat.js +234 -0
  387. package/esm/highlevel/types/peers/full-chat.js.map +1 -0
  388. package/esm/highlevel/types/peers/index.d.ts +1 -0
  389. package/esm/highlevel/types/peers/index.js +1 -0
  390. package/esm/highlevel/types/peers/index.js.map +1 -1
  391. package/esm/highlevel/types/peers/user.d.ts +5 -0
  392. package/esm/highlevel/types/peers/user.js +7 -0
  393. package/esm/highlevel/types/peers/user.js.map +1 -1
  394. package/esm/highlevel/types/premium/business-account.d.ts +19 -0
  395. package/esm/highlevel/types/premium/business-account.js +42 -0
  396. package/esm/highlevel/types/premium/business-account.js.map +1 -0
  397. package/esm/highlevel/types/premium/business-chat-link.d.ts +19 -0
  398. package/esm/highlevel/types/premium/business-chat-link.js +36 -0
  399. package/esm/highlevel/types/premium/business-chat-link.js.map +1 -0
  400. package/esm/highlevel/types/premium/business-connection.d.ts +23 -0
  401. package/esm/highlevel/types/premium/business-connection.js +42 -0
  402. package/esm/highlevel/types/premium/business-connection.js.map +1 -0
  403. package/esm/highlevel/types/premium/business-intro.d.ts +22 -0
  404. package/esm/highlevel/types/premium/business-intro.js +40 -0
  405. package/esm/highlevel/types/premium/business-intro.js.map +1 -0
  406. package/esm/highlevel/types/premium/business-location.d.ts +10 -0
  407. package/esm/highlevel/types/premium/business-location.js +23 -0
  408. package/esm/highlevel/types/premium/business-location.js.map +1 -0
  409. package/esm/highlevel/types/premium/business-work-hours.d.ts +42 -0
  410. package/esm/highlevel/types/premium/business-work-hours.js +137 -0
  411. package/esm/highlevel/types/premium/business-work-hours.js.map +1 -0
  412. package/esm/highlevel/types/premium/index.d.ts +5 -0
  413. package/esm/highlevel/types/premium/index.js +5 -0
  414. package/esm/highlevel/types/premium/index.js.map +1 -1
  415. package/esm/highlevel/types/updates/business-message.d.ts +18 -0
  416. package/esm/highlevel/types/updates/business-message.js +31 -0
  417. package/esm/highlevel/types/updates/business-message.js.map +1 -0
  418. package/esm/highlevel/types/updates/delete-business-message-update.d.ts +21 -0
  419. package/esm/highlevel/types/updates/delete-business-message-update.js +34 -0
  420. package/esm/highlevel/types/updates/delete-business-message-update.js.map +1 -0
  421. package/esm/highlevel/types/updates/index.d.ts +19 -2
  422. package/esm/highlevel/types/updates/index.js +3 -1
  423. package/esm/highlevel/types/updates/index.js.map +1 -1
  424. package/esm/highlevel/types/updates/parse-update.d.ts +4 -1
  425. package/esm/highlevel/types/updates/parse-update.js +9 -1
  426. package/esm/highlevel/types/updates/parse-update.js.map +1 -1
  427. package/esm/highlevel/types/updates/poll-update.js +2 -2
  428. package/esm/highlevel/types/updates/poll-update.js.map +1 -1
  429. package/esm/highlevel/updates/manager.d.ts +0 -1
  430. package/esm/highlevel/updates/manager.js +7 -2
  431. package/esm/highlevel/updates/manager.js.map +1 -1
  432. package/esm/highlevel/updates/parsed.js +8 -2
  433. package/esm/highlevel/updates/parsed.js.map +1 -1
  434. package/esm/highlevel/updates/types.d.ts +57 -0
  435. package/esm/highlevel/updates/utils.d.ts +2 -0
  436. package/esm/highlevel/utils/inspectable.js +4 -0
  437. package/esm/highlevel/utils/inspectable.js.map +1 -1
  438. package/esm/highlevel/worker/protocol.d.ts +0 -1
  439. package/esm/network/client.d.ts +0 -1
  440. package/esm/network/mtproto-session.d.ts +0 -1
  441. package/esm/network/multi-session-connection.d.ts +0 -1
  442. package/esm/network/network-manager.d.ts +8 -0
  443. package/esm/network/network-manager.js +9 -4
  444. package/esm/network/network-manager.js.map +1 -1
  445. package/esm/network/persistent-connection.d.ts +0 -1
  446. package/esm/network/session-connection.js +10 -0
  447. package/esm/network/session-connection.js.map +1 -1
  448. package/esm/network/transports/abstract.d.ts +0 -1
  449. package/esm/network/transports/streamed.d.ts +0 -1
  450. package/esm/network/transports/wrapped.d.ts +0 -1
  451. package/esm/storage/sqlite/repository/peers.js +1 -2
  452. package/esm/storage/sqlite/repository/peers.js.map +1 -1
  453. package/esm/storage/storage.d.ts +21 -0
  454. package/esm/types/utils.d.ts +1 -0
  455. package/esm/types/utils.js.map +1 -1
  456. package/esm/utils/reloadable.d.ts +0 -1
  457. package/index.d.ts +1 -0
  458. package/index.js +1 -0
  459. package/methods.d.ts +1 -0
  460. package/methods.js +1 -0
  461. package/package.json +5 -5
  462. package/platform.d.ts +1 -0
  463. package/platform.js +1 -0
  464. package/utils.d.ts +1 -0
  465. package/utils.js +1 -0
  466. package/worker.d.ts +1 -0
  467. package/worker.js +1 -0
@@ -12,6 +12,8 @@ const sentCodeMap = {
12
12
  'auth.sentCodeTypeSetUpEmailRequired': 'email_required',
13
13
  'auth.sentCodeTypeFragmentSms': 'fragment',
14
14
  'auth.sentCodeTypeFirebaseSms': 'firebase',
15
+ 'auth.sentCodeTypeSmsWord': 'sms_word',
16
+ 'auth.sentCodeTypeSmsPhrase': 'sms_phrase',
15
17
  };
16
18
  const nextCodeMap = {
17
19
  'auth.codeTypeCall': 'call',
@@ -54,6 +56,18 @@ class SentCode {
54
56
  get timeout() {
55
57
  return this.raw.timeout ?? 0;
56
58
  }
59
+ /**
60
+ * If the code is sent via SMS with a word/phrase, this field *may* contain the beginning of the message
61
+ */
62
+ get beginning() {
63
+ switch (this.raw.type._) {
64
+ case 'auth.sentCodeTypeSmsPhrase':
65
+ case 'auth.sentCodeTypeSmsWord':
66
+ return this.raw.type.beginning;
67
+ default:
68
+ return undefined;
69
+ }
70
+ }
57
71
  /**
58
72
  * Length of the code (0 for flash calls)
59
73
  */
@@ -1 +1 @@
1
- {"version":3,"file":"sent-code.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/auth/sent-code.ts"],"names":[],"mappings":";;;AAEA,mDAAsD;AAEtD,MAAM,WAAW,GAAgE;IAC7E,sBAAsB,EAAE,KAAK;IAC7B,uBAAuB,EAAE,MAAM;IAC/B,4BAA4B,EAAE,YAAY;IAC1C,sBAAsB,EAAE,KAAK;IAC7B,6BAA6B,EAAE,aAAa;IAC5C,4BAA4B,EAAE,OAAO;IACrC,qCAAqC,EAAE,gBAAgB;IACvD,8BAA8B,EAAE,UAAU;IAC1C,8BAA8B,EAAE,UAAU;CAC7C,CAAA;AAED,MAAM,WAAW,GAA4D;IACzE,mBAAmB,EAAE,MAAM;IAC3B,wBAAwB,EAAE,YAAY;IACtC,kBAAkB,EAAE,KAAK;IACzB,yBAAyB,EAAE,aAAa;IACxC,0BAA0B,EAAE,UAAU;CACzC,CAAA;AAmCD;;GAEG;AACH,MAAa,QAAQ;IACI;IAArB,YAAqB,GAAwB;QAAxB,QAAG,GAAH,GAAG,CAAqB;IAAG,CAAC;IAEjD;;OAEG;IACH,IAAI,IAAI;QACJ,OAAO,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACvC,CAAC;IAED;;;OAGG;IACH,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;IACxE,CAAC;IAED;;;OAGG;IACH,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAA;IACjC,CAAC;IAED;;OAEG;IACH,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACN,OAAO,QAAQ,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IAC/D,CAAC;CACJ;AAvCD,4BAuCC;AAED,IAAA,0BAAe,EAAC,QAAQ,CAAC,CAAA","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { makeInspectable } from '../../utils/index.js'\n\nconst sentCodeMap: Record<tl.auth.TypeSentCodeType['_'], SentCodeDeliveryType> = {\n 'auth.sentCodeTypeApp': 'app',\n 'auth.sentCodeTypeCall': 'call',\n 'auth.sentCodeTypeFlashCall': 'flash_call',\n 'auth.sentCodeTypeSms': 'sms',\n 'auth.sentCodeTypeMissedCall': 'missed_call',\n 'auth.sentCodeTypeEmailCode': 'email',\n 'auth.sentCodeTypeSetUpEmailRequired': 'email_required',\n 'auth.sentCodeTypeFragmentSms': 'fragment',\n 'auth.sentCodeTypeFirebaseSms': 'firebase',\n}\n\nconst nextCodeMap: Record<tl.auth.TypeCodeType['_'], NextCodeDeliveryType> = {\n 'auth.codeTypeCall': 'call',\n 'auth.codeTypeFlashCall': 'flash_call',\n 'auth.codeTypeSms': 'sms',\n 'auth.codeTypeMissedCall': 'missed_call',\n 'auth.codeTypeFragmentSms': 'fragment',\n}\n\n/**\n * Type describing code delivery type.\n * - `app`: Code is delivered via Telegram account\n * - `sms`: Code is sent via SMS\n * - `call`: Code is sent via voice call\n * - `flash_call`: Code is the last 5 digits of the caller's phone number\n * - `missed_call`: Code is the last 5 digits of the caller's phone number\n * - `email`: Code is sent via Email\n * - `email_required`: Code sending via email setup is required\n * - `fragment`: Code is sent via Fragment anonymous numbers\n * - `firebase`: Code is sent via Firebase\n * - `Success`: Code is not needed, you're already logged in (only for future auth tokens)\n */\nexport type SentCodeDeliveryType =\n | 'app'\n | 'sms'\n | 'call'\n | 'flash_call'\n | 'missed_call'\n | 'email'\n | 'email_required'\n | 'fragment'\n | 'firebase'\n | 'success'\n\n/**\n * Type describing next code delivery type.\n * See {@link DeliveryType} for information on values.\n *\n * Additionally, can be `none` if no more types are available\n */\nexport type NextCodeDeliveryType = Exclude<SentCodeDeliveryType, 'app'> | 'none'\n\n/**\n * Information about sent confirmation code\n */\nexport class SentCode {\n constructor(readonly raw: tl.auth.RawSentCode) {}\n\n /**\n * Type of currently sent confirmation code\n */\n get type(): SentCodeDeliveryType {\n return sentCodeMap[this.raw.type._]\n }\n\n /**\n * Type of the confirmation code that will be sent\n * if you call {@link TelegramClient.resendCode}.\n */\n get nextType(): NextCodeDeliveryType {\n return this.raw.nextType ? nextCodeMap[this.raw.nextType._] : 'none'\n }\n\n /**\n * Confirmation code identifier used for the next authorization steps\n * (like {@link TelegramClient.signIn} and {@link TelegramClient.signUp})\n */\n get phoneCodeHash(): string {\n return this.raw.phoneCodeHash\n }\n\n /**\n * Delay in seconds to wait before calling {@link TelegramClient.resendCode}\n */\n get timeout(): number {\n return this.raw.timeout ?? 0\n }\n\n /**\n * Length of the code (0 for flash calls)\n */\n get length(): number {\n return 'length' in this.raw.type ? this.raw.type.length : 0\n }\n}\n\nmakeInspectable(SentCode)\n"]}
1
+ {"version":3,"file":"sent-code.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/auth/sent-code.ts"],"names":[],"mappings":";;;AAEA,mDAAsD;AAEtD,MAAM,WAAW,GAAgE;IAC7E,sBAAsB,EAAE,KAAK;IAC7B,uBAAuB,EAAE,MAAM;IAC/B,4BAA4B,EAAE,YAAY;IAC1C,sBAAsB,EAAE,KAAK;IAC7B,6BAA6B,EAAE,aAAa;IAC5C,4BAA4B,EAAE,OAAO;IACrC,qCAAqC,EAAE,gBAAgB;IACvD,8BAA8B,EAAE,UAAU;IAC1C,8BAA8B,EAAE,UAAU;IAC1C,0BAA0B,EAAE,UAAU;IACtC,4BAA4B,EAAE,YAAY;CAC7C,CAAA;AAED,MAAM,WAAW,GAA4D;IACzE,mBAAmB,EAAE,MAAM;IAC3B,wBAAwB,EAAE,YAAY;IACtC,kBAAkB,EAAE,KAAK;IACzB,yBAAyB,EAAE,aAAa;IACxC,0BAA0B,EAAE,UAAU;CACzC,CAAA;AAsCD;;GAEG;AACH,MAAa,QAAQ;IACI;IAArB,YAAqB,GAAwB;QAAxB,QAAG,GAAH,GAAG,CAAqB;IAAG,CAAC;IAEjD;;OAEG;IACH,IAAI,IAAI;QACJ,OAAO,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACvC,CAAC;IAED;;;OAGG;IACH,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;IACxE,CAAC;IAED;;;OAGG;IACH,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAA;IACjC,CAAC;IAED;;OAEG;IACH,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;OAEG;IACH,IAAI,SAAS;QACT,QAAQ,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YACtB,KAAK,4BAA4B,CAAC;YAClC,KAAK,0BAA0B;gBAC3B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAA;YAClC;gBACI,OAAO,SAAS,CAAA;QACxB,CAAC;IACL,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACN,OAAO,QAAQ,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IAC/D,CAAC;CACJ;AApDD,4BAoDC;AAED,IAAA,0BAAe,EAAC,QAAQ,CAAC,CAAA","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { makeInspectable } from '../../utils/index.js'\n\nconst sentCodeMap: Record<tl.auth.TypeSentCodeType['_'], SentCodeDeliveryType> = {\n 'auth.sentCodeTypeApp': 'app',\n 'auth.sentCodeTypeCall': 'call',\n 'auth.sentCodeTypeFlashCall': 'flash_call',\n 'auth.sentCodeTypeSms': 'sms',\n 'auth.sentCodeTypeMissedCall': 'missed_call',\n 'auth.sentCodeTypeEmailCode': 'email',\n 'auth.sentCodeTypeSetUpEmailRequired': 'email_required',\n 'auth.sentCodeTypeFragmentSms': 'fragment',\n 'auth.sentCodeTypeFirebaseSms': 'firebase',\n 'auth.sentCodeTypeSmsWord': 'sms_word',\n 'auth.sentCodeTypeSmsPhrase': 'sms_phrase',\n}\n\nconst nextCodeMap: Record<tl.auth.TypeCodeType['_'], NextCodeDeliveryType> = {\n 'auth.codeTypeCall': 'call',\n 'auth.codeTypeFlashCall': 'flash_call',\n 'auth.codeTypeSms': 'sms',\n 'auth.codeTypeMissedCall': 'missed_call',\n 'auth.codeTypeFragmentSms': 'fragment',\n}\n\n/**\n * Type describing code delivery type.\n * - `app`: Code is delivered via Telegram account\n * - `sms`: Code is sent via SMS\n * - `call`: Code is sent via voice call\n * - `flash_call`: Code is the last 5 digits of the caller's phone number\n * - `missed_call`: Code is the last 5 digits of the caller's phone number\n * - `email`: Code is sent via Email\n * - `email_required`: Code sending via email setup is required\n * - `fragment`: Code is sent via Fragment anonymous numbers\n * - `firebase`: Code is sent via Firebase\n * - `sms_word`, `sms_phrase`: Code is sent via SMS with a word/phrase (see {@link SentCode#beginning})\n * - `success`: Code is not needed, you're already logged in (only for future auth tokens)\n */\nexport type SentCodeDeliveryType =\n | 'app'\n | 'sms'\n | 'call'\n | 'flash_call'\n | 'missed_call'\n | 'email'\n | 'email_required'\n | 'fragment'\n | 'firebase'\n | 'sms_word'\n | 'sms_phrase'\n | 'success'\n\n/**\n * Type describing next code delivery type.\n * See {@link DeliveryType} for information on values.\n *\n * Additionally, can be `none` if no more types are available\n */\nexport type NextCodeDeliveryType = Exclude<SentCodeDeliveryType, 'app'> | 'none'\n\n/**\n * Information about sent confirmation code\n */\nexport class SentCode {\n constructor(readonly raw: tl.auth.RawSentCode) {}\n\n /**\n * Type of currently sent confirmation code\n */\n get type(): SentCodeDeliveryType {\n return sentCodeMap[this.raw.type._]\n }\n\n /**\n * Type of the confirmation code that will be sent\n * if you call {@link TelegramClient.resendCode}.\n */\n get nextType(): NextCodeDeliveryType {\n return this.raw.nextType ? nextCodeMap[this.raw.nextType._] : 'none'\n }\n\n /**\n * Confirmation code identifier used for the next authorization steps\n * (like {@link TelegramClient.signIn} and {@link TelegramClient.signUp})\n */\n get phoneCodeHash(): string {\n return this.raw.phoneCodeHash\n }\n\n /**\n * Delay in seconds to wait before calling {@link TelegramClient.resendCode}\n */\n get timeout(): number {\n return this.raw.timeout ?? 0\n }\n\n /**\n * If the code is sent via SMS with a word/phrase, this field *may* contain the beginning of the message\n */\n get beginning(): string | undefined {\n switch (this.raw.type._) {\n case 'auth.sentCodeTypeSmsPhrase':\n case 'auth.sentCodeTypeSmsWord':\n return this.raw.type.beginning\n default:\n return undefined\n }\n }\n\n /**\n * Length of the code (0 for flash calls)\n */\n get length(): number {\n return 'length' in this.raw.type ? this.raw.type.length : 0\n }\n}\n\nmakeInspectable(SentCode)\n"]}
@@ -1,5 +1,7 @@
1
+ import { tl } from '@mtcute/tl';
2
+ import { ITelegramClient } from '../../../client.types.js';
1
3
  import { InputText } from '../../../types/misc/entities.js';
2
- import { InputInlineMessageContact, InputInlineMessageGame, InputInlineMessageGeo, InputInlineMessageGeoLive, InputInlineMessageMedia, InputInlineMessageText, InputInlineMessageVenue, InputInlineMessageWebpage } from './types.js';
4
+ import { InputInlineMessage, InputInlineMessageContact, InputInlineMessageGame, InputInlineMessageGeo, InputInlineMessageGeoLive, InputInlineMessageMedia, InputInlineMessageText, InputInlineMessageVenue, InputInlineMessageWebpage } from './types.js';
3
5
  /**
4
6
  * Create a text inline message
5
7
  *
@@ -41,3 +43,5 @@ export declare function contact(params: Omit<InputInlineMessageContact, 'type'>)
41
43
  * Create an inline message containing a webpage
42
44
  */
43
45
  export declare function webpage(params: Omit<InputInlineMessageWebpage, 'type'>): InputInlineMessageWebpage;
46
+ /** @internal */
47
+ export declare function _convertToTl(client: ITelegramClient, obj: InputInlineMessage): Promise<tl.TypeInputBotInlineMessage>;
@@ -1,5 +1,6 @@
1
1
  import { tl } from '@mtcute/tl';
2
- import { InputInlineResultArticle, InputInlineResultAudio, InputInlineResultContact, InputInlineResultFile, InputInlineResultGame, InputInlineResultGeo, InputInlineResultGif, InputInlineResultPhoto, InputInlineResultSticker, InputInlineResultVenue, InputInlineResultVideo, InputInlineResultVoice } from './types.js';
2
+ import { ITelegramClient } from '../../../client.types.js';
3
+ import { InputInlineResult, InputInlineResultArticle, InputInlineResultAudio, InputInlineResultContact, InputInlineResultFile, InputInlineResultGame, InputInlineResultGeo, InputInlineResultGif, InputInlineResultPhoto, InputInlineResultSticker, InputInlineResultVenue, InputInlineResultVideo, InputInlineResultVoice } from './types.js';
3
4
  /**
4
5
  * Create an inline result containing an article
5
6
  *
@@ -92,3 +93,5 @@ export declare function contact(id: string, params: Omit<InputInlineResultContac
92
93
  * @param params Additional parameters
93
94
  */
94
95
  export declare function game(id: string, shortName: string, params?: Omit<InputInlineResultGame, 'type' | 'id' | 'shortName'>): InputInlineResultGame;
96
+ /** @internal */
97
+ export declare function _convertToTl(client: ITelegramClient, results: InputInlineResult[]): Promise<[boolean, tl.TypeInputBotInlineResult[]]>;
@@ -1,6 +1,6 @@
1
1
  import { tl } from '@mtcute/tl';
2
2
  import { BotKeyboardBuilder } from './builder.js';
3
- import { InlineKeyboardMarkup, ReplyKeyboardForceReply, ReplyKeyboardHide, ReplyKeyboardMarkup } from './types.js';
3
+ import { InlineKeyboardMarkup, ReplyKeyboardForceReply, ReplyKeyboardHide, ReplyKeyboardMarkup, ReplyMarkup } from './types.js';
4
4
  /** Create a keyboard builder */
5
5
  export declare function builder(maxRowWidth?: number | null): BotKeyboardBuilder;
6
6
  /**
@@ -193,3 +193,9 @@ export declare function requestPeer(text: string, buttonId: number, params: {
193
193
  * @param predicate Button text or predicate function
194
194
  */
195
195
  export declare function findButton(buttons: tl.TypeKeyboardButton[][], predicate: string | ((btn: tl.TypeKeyboardButton) => boolean)): tl.TypeKeyboardButton | null;
196
+ /** @internal */
197
+ export declare function _rowsTo2d(rows: tl.RawKeyboardButtonRow[]): tl.TypeKeyboardButton[][];
198
+ /** @internal */
199
+ export declare function _2dToRows(arr: tl.TypeKeyboardButton[][], inline: boolean): tl.RawKeyboardButtonRow[];
200
+ /** @internal */
201
+ export declare function _convertToTl(obj?: ReplyMarkup): tl.TypeReplyMarkup | undefined;
@@ -1,3 +1,4 @@
1
+ import { tl } from '@mtcute/tl';
1
2
  /**
2
3
  * Phone call discard reason. Can be:
3
4
  * - `missed`: The call was missed
@@ -6,3 +7,7 @@
6
7
  * - `busy`: The call was discarded because the user is in another call
7
8
  */
8
9
  export type CallDiscardReason = 'missed' | 'disconnect' | 'hangup' | 'busy';
10
+ /** @internal */
11
+ export declare function _callDiscardReasonFromTl(raw: tl.TypePhoneCallDiscardReason): CallDiscardReason;
12
+ /** @internal */
13
+ export declare function _callDiscardReasonToTl(r: CallDiscardReason): tl.TypePhoneCallDiscardReason;
@@ -20,3 +20,5 @@ export interface UploadedFile {
20
20
  */
21
21
  mime: string;
22
22
  }
23
+ /** @internal */
24
+ export declare function isUploadedFile(obj: unknown): obj is UploadedFile;
@@ -1,8 +1,6 @@
1
-
2
- /// <reference types="node" />
3
- import type { ReadStream } from 'node:fs';
4
1
  import { tdFileId } from '@mtcute/file-id';
5
2
  import { tl } from '@mtcute/tl';
3
+ import { AnyToNever } from '../../../types/utils.js';
6
4
  import { FileLocation } from './file-location.js';
7
5
  import { UploadedFile } from './uploaded-file.js';
8
6
  /**
@@ -12,13 +10,14 @@ import { UploadedFile } from './uploaded-file.js';
12
10
  * - `File`, `Blob` (from the Web API)
13
11
  * - `string`, which will be interpreted as file path (**non-browser only!**)
14
12
  * - `URL` (from the Web API, will be `fetch()`-ed; `file://` URLs are not available in browsers)
15
- * - `ReadStream` (for Node.js/Bun, from the `fs` module)
13
+ * - `ReadStream` (for Node.js/Bun, from the `node:fs` module)
16
14
  * - `BunFile` (from `Bun.file()`)
15
+ * - `Deno.FsFile` (from `Deno.open()` in Deno)
17
16
  * - `ReadableStream` (Web API readable stream)
18
17
  * - `Readable` (Node.js/Bun readable stream)
19
18
  * - `Response` (from `window.fetch`)
20
19
  */
21
- export type UploadFileLike = URL | Uint8Array | File | Blob | string | ReadStream | ReadableStream<Uint8Array> | NodeJS.ReadableStream | Response;
20
+ export type UploadFileLike = URL | Uint8Array | File | Blob | string | AnyToNever<import('node:fs').ReadStream> | AnyToNever<ReadableStream<Uint8Array>> | AnyToNever<NodeJS.ReadableStream> | AnyToNever<Response> | AnyToNever<Deno.FsFile>;
22
21
  /**
23
22
  * Describes types that can be used as an input
24
23
  * to any methods that send media (like {@link TelegramClient.sendPhoto})
@@ -29,6 +28,8 @@ export type UploadFileLike = URL | Uint8Array | File | Blob | string | ReadStrea
29
28
  * - `ReadStream` (for Node.js/Bun, from the `fs` module)
30
29
  * - `ReadableStream` (from the Web API, base readable stream)
31
30
  * - `Readable` (for Node.js/Bun, base readable stream)
31
+ * - `BunFile` (from `Bun.file()`)
32
+ * - `Deno.FsFile` (from `Deno.open()` in Deno)
32
33
  * - {@link UploadedFile} returned from {@link TelegramClient.uploadFile}
33
34
  * - `tl.TypeInputFile` and `tl.TypeInputMedia` TL objects
34
35
  * - `string` with a path to a local file prepended with `file:` (non-browser only) (e.g. `file:image.jpg`)
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/files/utils.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable no-restricted-imports */\nimport type { ReadStream } from 'node:fs'\n\nimport { tdFileId } from '@mtcute/file-id'\nimport { tl } from '@mtcute/tl'\n\nimport { FileLocation } from './file-location.js'\nimport { UploadedFile } from './uploaded-file.js'\n\n/**\n * Describes types that can be used in {@link TelegramClient.uploadFile}\n * method. Can be one of:\n * - `Uint8Array`/`Buffer`, which will be interpreted as raw file contents\n * - `File`, `Blob` (from the Web API)\n * - `string`, which will be interpreted as file path (**non-browser only!**)\n * - `URL` (from the Web API, will be `fetch()`-ed; `file://` URLs are not available in browsers)\n * - `ReadStream` (for Node.js/Bun, from the `fs` module)\n * - `BunFile` (from `Bun.file()`)\n * - `ReadableStream` (Web API readable stream)\n * - `Readable` (Node.js/Bun readable stream)\n * - `Response` (from `window.fetch`)\n */\nexport type UploadFileLike =\n | URL\n | Uint8Array\n | File\n | Blob\n | string\n | ReadStream\n | ReadableStream<Uint8Array>\n | NodeJS.ReadableStream\n | Response\n\n/**\n * Describes types that can be used as an input\n * to any methods that send media (like {@link TelegramClient.sendPhoto})\n *\n * Can be one of:\n * - `Buffer`, which will be interpreted as raw file contents\n * - `File` (from the Web API)\n * - `ReadStream` (for Node.js/Bun, from the `fs` module)\n * - `ReadableStream` (from the Web API, base readable stream)\n * - `Readable` (for Node.js/Bun, base readable stream)\n * - {@link UploadedFile} returned from {@link TelegramClient.uploadFile}\n * - `tl.TypeInputFile` and `tl.TypeInputMedia` TL objects\n * - `string` with a path to a local file prepended with `file:` (non-browser only) (e.g. `file:image.jpg`)\n * - `string` with a URL to remote files (e.g. `https://example.com/image.jpg`)\n * - `string` with TDLib and Bot API compatible File ID.\n * - `URL` (from the Web API, will be `fetch()`-ed if needed; `file://` URLs are not available in browsers)\n * - `td.RawFullRemoteFileLocation` (parsed File ID)\n */\nexport type InputFileLike =\n | UploadFileLike\n | UploadedFile\n | tl.TypeInputFile\n | tl.TypeInputMedia\n | tdFileId.RawFullRemoteFileLocation\n\n/**\n * File location which should be downloaded.\n * You can also provide TDLib and Bot API compatible File ID\n */\nexport type FileDownloadLocation = tl.TypeInputFileLocation | tl.TypeInputWebFileLocation | FileLocation | string\n\nexport interface FileDownloadParameters {\n /**\n * Total file size, if known.\n * Used to determine upload part size.\n * In some cases can be inferred from `file` automatically.\n */\n fileSize?: number\n\n /**\n * Download part size (in KB).\n * By default, automatically selected depending on the file size\n * (or 64, if not provided). Must not be bigger than 512,\n * must not be a fraction, and must be divisible by 4.\n */\n partSize?: number\n\n /**\n * DC id from which the file will be downloaded.\n *\n * If provided DC is not the one storing the file,\n * redirection will be handled automatically.\n */\n dcId?: number\n\n /**\n * Offset in bytes. Must be divisible by 4096 (4 KB).\n */\n offset?: number\n\n /**\n * Number of bytes to be downloaded.\n * By default, downloads the entire file\n */\n limit?: number\n\n /**\n * Function that will be called after some part has been downloaded.\n *\n * @param uploaded Number of bytes already downloaded\n * @param total Total file size (`Infinity` if not available)\n */\n progressCallback?: (downloaded: number, total: number) => void\n\n /**\n * Abort signal that can be used to cancel the download.\n */\n abortSignal?: AbortSignal\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/files/utils.ts"],"names":[],"mappings":"","sourcesContent":["import { tdFileId } from '@mtcute/file-id'\nimport { tl } from '@mtcute/tl'\n\nimport { AnyToNever } from '../../../types/utils.js'\nimport { FileLocation } from './file-location.js'\nimport { UploadedFile } from './uploaded-file.js'\n\n/**\n * Describes types that can be used in {@link TelegramClient.uploadFile}\n * method. Can be one of:\n * - `Uint8Array`/`Buffer`, which will be interpreted as raw file contents\n * - `File`, `Blob` (from the Web API)\n * - `string`, which will be interpreted as file path (**non-browser only!**)\n * - `URL` (from the Web API, will be `fetch()`-ed; `file://` URLs are not available in browsers)\n * - `ReadStream` (for Node.js/Bun, from the `node:fs` module)\n * - `BunFile` (from `Bun.file()`)\n * - `Deno.FsFile` (from `Deno.open()` in Deno)\n * - `ReadableStream` (Web API readable stream)\n * - `Readable` (Node.js/Bun readable stream)\n * - `Response` (from `window.fetch`)\n */\nexport type UploadFileLike =\n | URL\n | Uint8Array\n | File\n | Blob\n | string\n | AnyToNever<import('node:fs').ReadStream>\n | AnyToNever<ReadableStream<Uint8Array>>\n | AnyToNever<NodeJS.ReadableStream>\n | AnyToNever<Response>\n | AnyToNever<Deno.FsFile>\n\n// AnyToNever in the above type ensures we don't make the entire type `any`\n// if some of the types are not available in the current environment\n\n/**\n * Describes types that can be used as an input\n * to any methods that send media (like {@link TelegramClient.sendPhoto})\n *\n * Can be one of:\n * - `Buffer`, which will be interpreted as raw file contents\n * - `File` (from the Web API)\n * - `ReadStream` (for Node.js/Bun, from the `fs` module)\n * - `ReadableStream` (from the Web API, base readable stream)\n * - `Readable` (for Node.js/Bun, base readable stream)\n * - `BunFile` (from `Bun.file()`)\n * - `Deno.FsFile` (from `Deno.open()` in Deno)\n * - {@link UploadedFile} returned from {@link TelegramClient.uploadFile}\n * - `tl.TypeInputFile` and `tl.TypeInputMedia` TL objects\n * - `string` with a path to a local file prepended with `file:` (non-browser only) (e.g. `file:image.jpg`)\n * - `string` with a URL to remote files (e.g. `https://example.com/image.jpg`)\n * - `string` with TDLib and Bot API compatible File ID.\n * - `URL` (from the Web API, will be `fetch()`-ed if needed; `file://` URLs are not available in browsers)\n * - `td.RawFullRemoteFileLocation` (parsed File ID)\n */\nexport type InputFileLike =\n | UploadFileLike\n | UploadedFile\n | tl.TypeInputFile\n | tl.TypeInputMedia\n | tdFileId.RawFullRemoteFileLocation\n\n/**\n * File location which should be downloaded.\n * You can also provide TDLib and Bot API compatible File ID\n */\nexport type FileDownloadLocation = tl.TypeInputFileLocation | tl.TypeInputWebFileLocation | FileLocation | string\n\nexport interface FileDownloadParameters {\n /**\n * Total file size, if known.\n * Used to determine upload part size.\n * In some cases can be inferred from `file` automatically.\n */\n fileSize?: number\n\n /**\n * Download part size (in KB).\n * By default, automatically selected depending on the file size\n * (or 64, if not provided). Must not be bigger than 512,\n * must not be a fraction, and must be divisible by 4.\n */\n partSize?: number\n\n /**\n * DC id from which the file will be downloaded.\n *\n * If provided DC is not the one storing the file,\n * redirection will be handled automatically.\n */\n dcId?: number\n\n /**\n * Offset in bytes. Must be divisible by 4096 (4 KB).\n */\n offset?: number\n\n /**\n * Number of bytes to be downloaded.\n * By default, downloads the entire file\n */\n limit?: number\n\n /**\n * Function that will be called after some part has been downloaded.\n *\n * @param uploaded Number of bytes already downloaded\n * @param total Total file size (`Infinity` if not available)\n */\n progressCallback?: (downloaded: number, total: number) => void\n\n /**\n * Abort signal that can be used to cancel the download.\n */\n abortSignal?: AbortSignal\n}\n"]}
@@ -1,6 +1,11 @@
1
+ import { tl } from '@mtcute/tl';
1
2
  import { Audio } from './audio.js';
2
3
  import { Document } from './document.js';
3
4
  import { Sticker } from './sticker.js';
4
5
  import { Video } from './video.js';
5
6
  import { Voice } from './voice.js';
6
7
  export type ParsedDocument = Sticker | Voice | Audio | Video | Document;
8
+ /** @internal */
9
+ export declare function parseSticker(doc: tl.RawDocument): Sticker | undefined;
10
+ /** @internal */
11
+ export declare function parseDocument(doc: tl.RawDocument, media?: tl.RawMessageMediaDocument): ParsedDocument;
@@ -1,18 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseDocument = void 0;
3
+ exports.parseDocument = exports.parseSticker = void 0;
4
4
  const audio_js_1 = require("./audio.js");
5
5
  const document_js_1 = require("./document.js");
6
6
  const sticker_js_1 = require("./sticker.js");
7
7
  const video_js_1 = require("./video.js");
8
8
  const voice_js_1 = require("./voice.js");
9
9
  /** @internal */
10
- function parseDocument(doc, media) {
10
+ function parseSticker(doc) {
11
11
  const stickerAttr = doc.attributes.find((a) => a._ === 'documentAttributeSticker' || a._ === 'documentAttributeCustomEmoji');
12
12
  if (stickerAttr) {
13
13
  const sz = doc.attributes.find((it) => it._ === 'documentAttributeImageSize' || it._ === 'documentAttributeVideo');
14
14
  return new sticker_js_1.Sticker(doc, stickerAttr, sz);
15
15
  }
16
+ }
17
+ exports.parseSticker = parseSticker;
18
+ /** @internal */
19
+ function parseDocument(doc, media) {
20
+ const sticker = parseSticker(doc);
21
+ if (sticker)
22
+ return sticker;
16
23
  for (const attr of doc.attributes) {
17
24
  switch (attr._) {
18
25
  case 'documentAttributeAudio':
@@ -1 +1 @@
1
- {"version":3,"file":"document-utils.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/media/document-utils.ts"],"names":[],"mappings":";;;AAEA,yCAAkC;AAClC,+CAAwC;AACxC,6CAAsC;AACtC,yCAAkC;AAClC,yCAAkC;AAIlC,gBAAgB;AAChB,SAAgB,aAAa,CAAC,GAAmB,EAAE,KAAkC;IACjF,MAAM,WAAW,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,CACnC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,0BAA0B,IAAI,CAAC,CAAC,CAAC,KAAK,8BAA8B,CACtF,CAAA;IAED,IAAI,WAAW,EAAE,CAAC;QACd,MAAM,EAAE,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,CAC1B,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,4BAA4B,IAAI,EAAE,CAAC,CAAC,KAAK,wBAAwB,CACjB,CAAA;QAErE,OAAO,IAAI,oBAAO,CAAC,GAAG,EAAE,WAAkF,EAAE,EAAE,CAAC,CAAA;IACnH,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;QAChC,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC;YACb,KAAK,wBAAwB;gBACzB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;oBACb,OAAO,IAAI,gBAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;gBAC/B,CAAC;gBAED,OAAO,IAAI,gBAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;YAE/B,KAAK,wBAAwB;gBACzB,OAAO,IAAI,gBAAK,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;YAEtC,KAAK,4BAA4B;gBAC7B,aAAa;gBACb,IAAI,GAAG,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;oBAC/B,OAAO,IAAI,gBAAK,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;gBACtC,CAAC;QACT,CAAC;IACL,CAAC;IAED,OAAO,IAAI,sBAAQ,CAAC,GAAG,CAAC,CAAA;AAC5B,CAAC;AAlCD,sCAkCC","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { Audio } from './audio.js'\nimport { Document } from './document.js'\nimport { Sticker } from './sticker.js'\nimport { Video } from './video.js'\nimport { Voice } from './voice.js'\n\nexport type ParsedDocument = Sticker | Voice | Audio | Video | Document\n\n/** @internal */\nexport function parseDocument(doc: tl.RawDocument, media?: tl.RawMessageMediaDocument): ParsedDocument {\n const stickerAttr = doc.attributes.find(\n (a) => a._ === 'documentAttributeSticker' || a._ === 'documentAttributeCustomEmoji',\n )\n\n if (stickerAttr) {\n const sz = doc.attributes.find(\n (it) => it._ === 'documentAttributeImageSize' || it._ === 'documentAttributeVideo',\n )! as tl.RawDocumentAttributeImageSize | tl.RawDocumentAttributeVideo\n\n return new Sticker(doc, stickerAttr as tl.RawDocumentAttributeSticker | tl.RawDocumentAttributeCustomEmoji, sz)\n }\n\n for (const attr of doc.attributes) {\n switch (attr._) {\n case 'documentAttributeAudio':\n if (attr.voice) {\n return new Voice(doc, attr)\n }\n\n return new Audio(doc, attr)\n\n case 'documentAttributeVideo':\n return new Video(doc, attr, media)\n\n case 'documentAttributeImageSize':\n // legacy gif\n if (doc.mimeType === 'image/gif') {\n return new Video(doc, attr, media)\n }\n }\n }\n\n return new Document(doc)\n}\n"]}
1
+ {"version":3,"file":"document-utils.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/media/document-utils.ts"],"names":[],"mappings":";;;AAEA,yCAAkC;AAClC,+CAAwC;AACxC,6CAAsC;AACtC,yCAAkC;AAClC,yCAAkC;AAIlC,gBAAgB;AAChB,SAAgB,YAAY,CAAC,GAAmB;IAC5C,MAAM,WAAW,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,CACnC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,0BAA0B,IAAI,CAAC,CAAC,CAAC,KAAK,8BAA8B,CACtF,CAAA;IAED,IAAI,WAAW,EAAE,CAAC;QACd,MAAM,EAAE,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,CAC1B,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,4BAA4B,IAAI,EAAE,CAAC,CAAC,KAAK,wBAAwB,CACjB,CAAA;QAErE,OAAO,IAAI,oBAAO,CAAC,GAAG,EAAE,WAAkF,EAAE,EAAE,CAAC,CAAA;IACnH,CAAC;AACL,CAAC;AAZD,oCAYC;AAED,gBAAgB;AAChB,SAAgB,aAAa,CAAC,GAAmB,EAAE,KAAkC;IACjF,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,CAAA;IACjC,IAAI,OAAO;QAAE,OAAO,OAAO,CAAA;IAE3B,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;QAChC,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC;YACb,KAAK,wBAAwB;gBACzB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;oBACb,OAAO,IAAI,gBAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;gBAC/B,CAAC;gBAED,OAAO,IAAI,gBAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;YAE/B,KAAK,wBAAwB;gBACzB,OAAO,IAAI,gBAAK,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;YAEtC,KAAK,4BAA4B;gBAC7B,aAAa;gBACb,IAAI,GAAG,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;oBAC/B,OAAO,IAAI,gBAAK,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;gBACtC,CAAC;QACT,CAAC;IACL,CAAC;IAED,OAAO,IAAI,sBAAQ,CAAC,GAAG,CAAC,CAAA;AAC5B,CAAC;AAzBD,sCAyBC","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { Audio } from './audio.js'\nimport { Document } from './document.js'\nimport { Sticker } from './sticker.js'\nimport { Video } from './video.js'\nimport { Voice } from './voice.js'\n\nexport type ParsedDocument = Sticker | Voice | Audio | Video | Document\n\n/** @internal */\nexport function parseSticker(doc: tl.RawDocument) {\n const stickerAttr = doc.attributes.find(\n (a) => a._ === 'documentAttributeSticker' || a._ === 'documentAttributeCustomEmoji',\n )\n\n if (stickerAttr) {\n const sz = doc.attributes.find(\n (it) => it._ === 'documentAttributeImageSize' || it._ === 'documentAttributeVideo',\n )! as tl.RawDocumentAttributeImageSize | tl.RawDocumentAttributeVideo\n\n return new Sticker(doc, stickerAttr as tl.RawDocumentAttributeSticker | tl.RawDocumentAttributeCustomEmoji, sz)\n }\n}\n\n/** @internal */\nexport function parseDocument(doc: tl.RawDocument, media?: tl.RawMessageMediaDocument): ParsedDocument {\n const sticker = parseSticker(doc)\n if (sticker) return sticker\n\n for (const attr of doc.attributes) {\n switch (attr._) {\n case 'documentAttributeAudio':\n if (attr.voice) {\n return new Voice(doc, attr)\n }\n\n return new Audio(doc, attr)\n\n case 'documentAttributeVideo':\n return new Video(doc, attr, media)\n\n case 'documentAttributeImageSize':\n // legacy gif\n if (doc.mimeType === 'image/gif') {\n return new Video(doc, attr, media)\n }\n }\n }\n\n return new Document(doc)\n}\n"]}
@@ -392,7 +392,7 @@ export interface InputMediaPoll extends CaptionMixin {
392
392
  /**
393
393
  * Question of the poll (1-255 chars for users, 1-300 chars for bots)
394
394
  */
395
- question: string;
395
+ question: InputText;
396
396
  /**
397
397
  * Answers of the poll.
398
398
  *
@@ -402,7 +402,7 @@ export interface InputMediaPoll extends CaptionMixin {
402
402
  * objects, with a single=byte incrementing
403
403
  * `option` value.
404
404
  */
405
- answers: (string | tl.TypePollAnswer)[];
405
+ answers: (InputText | tl.TypePollAnswer)[];
406
406
  /**
407
407
  * Whether this is poll is closed
408
408
  * (i.e. nobody can vote anymore)
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/highlevel/types/media/input-media/types.ts"],"names":[],"mappings":"","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { MaybeArray } from '../../../../types/utils.js'\nimport { InputText } from '../../../types/misc/entities.js'\nimport { InputFileLike } from '../../files/index.js'\nimport { InputPeerLike } from '../../peers/index.js'\nimport { VenueSource } from '../venue.js'\n\nexport interface CaptionMixin {\n /**\n * Caption of the media\n */\n caption?: InputText\n}\n\nexport interface FileMixin {\n /**\n * File to be sent\n */\n file: InputFileLike\n\n /**\n * Override file name for the file.\n *\n * Only applicable to newly uploaded files.\n */\n fileName?: string\n\n /**\n * Override MIME type for the file\n *\n * Only applicable to newly uploaded files.\n */\n fileMime?: string\n\n /**\n * Override file size for the file\n *\n * Only applicable to newly uploaded files.\n */\n fileSize?: number\n\n /**\n * TTL for the media in seconds.\n *\n * Only applicable to some media types\n */\n ttlSeconds?: number\n}\n\n/**\n * Automatically detect media type based on file contents.\n *\n * Photo type is only inferred for reused files,\n * newly uploaded photos with `auto` will be\n * uploaded as a document\n */\nexport interface InputMediaAuto extends FileMixin, CaptionMixin {\n type: 'auto'\n}\n\n/**\n * An audio file or voice message to be sent\n */\nexport interface InputMediaAudio extends FileMixin, CaptionMixin {\n type: 'audio'\n\n /**\n * Thumbnail of the audio file album cover.\n *\n * The thumbnail should be in JPEG format and less than 200 KB in size.\n * A thumbnail's width and height should not exceed 320 pixels.\n * Thumbnails can't be reused and can be only uploaded as a new file.\n *\n * Only applicable to newly uploaded files.\n */\n thumb?: InputFileLike\n\n /**\n * Duration of the audio in seconds\n *\n * Only applicable to newly uploaded files.\n */\n duration?: number\n\n /**\n * Performer of the audio\n *\n * Only applicable to newly uploaded files.\n */\n performer?: string\n\n /**\n * Title of the audio\n *\n * Only applicable to newly uploaded files.\n */\n title?: string\n}\n\n/**\n * Voice message to be sent\n */\nexport interface InputMediaVoice extends FileMixin, CaptionMixin {\n type: 'voice'\n\n /**\n * Duration of the voice message in seconds\n *\n * Only applicable to newly uploaded files.\n */\n duration?: number\n\n /**\n * Waveform of the voice message.\n *\n * Represented with integers in range [0, 31],\n * usually has length of 100.\n * Generated by the server if omitted.\n *\n * Only applicable to newly uploaded files.\n */\n waveform?: number[]\n}\n\n/**\n * A generic file to be sent\n */\nexport interface InputMediaDocument extends FileMixin, CaptionMixin {\n type: 'document'\n\n /**\n * Thumbnail of the document.\n *\n * The thumbnail should be in JPEG format and less than 200 KB in size.\n * A thumbnail's width and height should not exceed 320 pixels.\n * Thumbnails can't be reused and can be only uploaded as a new file.\n *\n * Only applicable to newly uploaded files.\n */\n thumb?: InputFileLike\n}\n\n/**\n * A photo to be sent\n */\nexport interface InputMediaPhoto extends FileMixin, CaptionMixin {\n type: 'photo'\n\n /**\n * Whether this photo should be hidden with a spoiler\n */\n spoiler?: boolean\n}\n\n/**\n * A sticker to be sent\n */\nexport interface InputMediaSticker extends FileMixin, CaptionMixin {\n type: 'sticker'\n\n /**\n * Whether this sticker is animated?\n *\n * Note that animated stickers must be in TGS\n * format, which is Lottie JSON compressed using GZip\n *\n * Only applicable to newly uploaded files.\n *\n * @default false\n */\n isAnimated?: boolean\n\n /**\n * An emoji representing this sticker\n *\n * Only applicable to newly uploaded files,\n * for some reason doesn't work with animated stickers.\n */\n alt?: string\n}\n\n/**\n * A video to be sent\n */\nexport interface InputMediaVideo extends FileMixin, CaptionMixin {\n type: 'video'\n\n /**\n * Thumbnail of the video.\n *\n * The thumbnail should be in JPEG format and less than 200 KB in size.\n * A thumbnail's width and height should not exceed 320 pixels.\n * Thumbnails can't be reused and can be only uploaded as a new file.\n *\n * Only applicable to newly uploaded files.\n */\n thumb?: InputFileLike\n\n /**\n * Width of the video in pixels\n *\n * Only applicable to newly uploaded files.\n */\n width?: number\n\n /**\n * Height of the video in pixels\n *\n * Only applicable to newly uploaded files.\n */\n height?: number\n\n /**\n * Duration of the video in seconds\n *\n * Only applicable to newly uploaded files.\n */\n duration?: number\n\n /**\n * Whether the video is suitable for streaming\n *\n * Only applicable to newly uploaded files.\n */\n supportsStreaming?: boolean\n\n /**\n * Whether this video is an animated GIF\n *\n * Only applicable to newly uploaded files.\n */\n isAnimated?: boolean\n\n /**\n * Whether this video is a round message (aka video note)\n *\n * Only applicable to newly uploaded files.\n */\n isRound?: boolean\n\n /**\n * Whether this video should be hidden with a spoiler\n */\n spoiler?: boolean\n}\n\n/**\n * A geolocation to be sent\n */\nexport interface InputMediaGeo extends CaptionMixin {\n type: 'geo'\n\n /**\n * Latitude of the geolocation\n */\n latitude: number\n\n /**\n * Longitude of the geolocation\n */\n longitude: number\n\n /**\n * The estimated horizontal accuracy of the\n * geolocation, in meters (0-1500)\n */\n accuracy?: number\n}\n\n/**\n * A live geolocation to be sent\n */\nexport interface InputMediaGeoLive extends Omit<InputMediaGeo, 'type'> {\n type: 'geo_live'\n\n /**\n * Whether sending of the geolocation has stopped\n */\n stopped?: boolean\n\n /**\n * Direction in which the location moves, in degrees (1-360)\n */\n heading?: number\n\n /**\n * Validity period of the live location\n */\n period?: number\n\n /**\n * Maximum distance to another chat member for proximity\n * alerts, in meters (0-100000)\n */\n proximityNotificationRadius?: number\n}\n\n/**\n * An animated dice with a random value to be sent\n *\n * For convenience, known dice emojis are available\n * as static members of {@link Dice}.\n *\n * Note that dice result value is generated randomly on the server,\n * you can't influence it in any way!\n */\nexport interface InputMediaDice extends CaptionMixin {\n type: 'dice'\n\n /**\n * Emoji representing a dice\n */\n emoji: string\n}\n\n/**\n * A venue to be sent\n */\nexport interface InputMediaVenue extends CaptionMixin {\n type: 'venue'\n\n /**\n * Latitude of the geolocation\n */\n latitude: number\n\n /**\n * Longitude of the geolocation\n */\n longitude: number\n\n /**\n * Venue name\n */\n title: string\n\n /**\n * Venue address\n */\n address: string\n\n /**\n * When available, source from where this venue was acquired\n */\n source?: VenueSource\n}\n\n/**\n * A contact to be sent\n */\nexport interface InputMediaContact extends CaptionMixin {\n type: 'contact'\n\n /**\n * Contact's phone number\n */\n phone: string\n\n /**\n * Contact's first name\n */\n firstName: string\n\n /**\n * Contact's last name\n */\n lastName?: string\n\n /**\n * Additional data about the contact\n * as a vCard (0-2048 bytes)\n */\n vcard?: string\n}\n\n/**\n * A game to be sent\n */\nexport interface InputMediaGame extends CaptionMixin {\n type: 'game'\n\n /**\n * Game's short name, or a TL object with an input game\n */\n game: string | tl.TypeInputGame\n}\n\n/**\n * An invoice to be sent (see https://core.telegram.org/bots/payments)\n */\nexport interface InputMediaInvoice extends CaptionMixin {\n type: 'invoice'\n\n /**\n * Product name (1-32 chars)\n */\n title: string\n\n /**\n * Product description (1-255 chars)\n */\n description: string\n\n /**\n * The invoice itself\n */\n invoice: tl.TypeInvoice\n\n /**\n * Bot-defined invoice payload (1-128 bytes).\n *\n * Will not be displayed to the user and can be used\n * for internal processes\n */\n payload: Uint8Array\n\n /**\n * Payments provider token, obtained from\n * [@BotFather](//t.me/botfather)\n */\n token: string\n\n /**\n * Data about the invoice as a plain JS object, which\n * will be shared with the payment provider. A detailed\n * description of required fields should be provided by\n * the payment provider.\n */\n providerData: unknown\n\n /**\n * Start parameter for the bot\n */\n startParam: string\n\n /**\n * Product photo. Can be a photo of the goods or a marketing image for a service.\n *\n * Can be a URL, or a TL object with input web document\n */\n photo?: string | tl.TypeInputWebDocument\n\n /**\n * Extended media (i.e. media that will be available once the invoice is paid)\n */\n extendedMedia?: InputMediaLike\n}\n\n/**\n * A simple poll to be sent\n *\n * > **Note**: when using user account,\n * > the poll can't be sent to PMs, only to channels/groups,\n * > otherwise there will be `MEDIA_INVALID` error.\n */\nexport interface InputMediaPoll extends CaptionMixin {\n type: 'poll'\n\n /**\n * Question of the poll (1-255 chars for users, 1-300 chars for bots)\n */\n question: string\n\n /**\n * Answers of the poll.\n *\n * You can either provide a string, or a\n * TL object representing an answer.\n * Strings will be transformed to TL\n * objects, with a single=byte incrementing\n * `option` value.\n */\n answers: (string | tl.TypePollAnswer)[]\n\n /**\n * Whether this is poll is closed\n * (i.e. nobody can vote anymore)\n */\n closed?: boolean\n\n /**\n * Whether this is a public poll\n * (i.e. users who have voted are visible to everyone)\n */\n public?: boolean\n\n /**\n * Whether users can select multiple answers\n * as an answer\n */\n multiple?: boolean\n\n /**\n * Amount of time in seconds the poll will be active after creation (5-600).\n *\n * Can't be used together with `closeDate`.\n */\n closePeriod?: number\n\n /**\n * Point in time when the poll will be automatically closed.\n *\n * Must be at least 5 and no more than 600 seconds in the future,\n * can't be used together with `closePeriod`.\n *\n * When `number` is used, UNIX time in ms is expected\n */\n closeDate?: number | Date\n}\n\n/**\n * A quiz to be sent.\n *\n * Quiz is an extended version of a poll, but quizzes have\n * correct answers, and votes can't be retracted from them\n */\nexport interface InputMediaQuiz extends Omit<InputMediaPoll, 'type'> {\n type: 'quiz'\n\n /**\n * Correct answer ID(s) or index(es).\n *\n * > **Note**: even though quizzes can actually\n * > only have exactly one correct answer,\n * > the API itself has the possibility to pass\n * > multiple or zero correct answers,\n * > but that would result in `QUIZ_CORRECT_ANSWERS_TOO_MUCH`\n * > and `QUIZ_CORRECT_ANSWERS_EMPTY` errors respectively.\n * >\n * > But since the API has that option, we also provide it,\n * > maybe to future-proof this :shrug:\n */\n correct: MaybeArray<number | Uint8Array>\n\n /**\n * Explanation of the quiz solution\n */\n solution?: InputText\n}\n\n/**\n * A story to be sent\n */\nexport interface InputMediaStory extends CaptionMixin {\n type: 'story'\n\n /**\n * Owner of the story\n */\n peer: InputPeerLike\n\n /**\n * ID of the story\n */\n id: number\n}\n\n/** A webpage to be sent */\nexport interface InputMediaWebpage extends CaptionMixin {\n type: 'webpage'\n\n /**\n * Whether the link must be present in the message\n * for the preview to appear\n */\n required?: boolean\n\n /**\n * By default, size of the media in the preview\n * is determined based on content type.\n *\n * You can override this behaviour by passing the wanted size here\n */\n size?: 'large' | 'small'\n\n /** Webpage URL */\n url: string\n}\n\n/**\n * Input media that can be sent somewhere.\n *\n * Note that meta-fields (like `duration`) are only\n * applicable if `file` is {@link UploadFileLike},\n * otherwise they are ignored.\n *\n * @link InputMedia\n */\nexport type InputMediaLike =\n | InputMediaAudio\n | InputMediaVoice\n | InputMediaDocument\n | InputMediaPhoto\n | InputMediaVideo\n | InputMediaAuto\n | InputMediaSticker\n | InputMediaVenue\n | InputMediaGeo\n | InputMediaGeoLive\n | InputMediaDice\n | InputMediaContact\n | InputMediaGame\n | InputMediaInvoice\n | InputMediaPoll\n | InputMediaQuiz\n | InputMediaStory\n | InputMediaWebpage\n | tl.TypeInputMedia\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/highlevel/types/media/input-media/types.ts"],"names":[],"mappings":"","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { MaybeArray } from '../../../../types/utils.js'\nimport { InputText } from '../../../types/misc/entities.js'\nimport { InputFileLike } from '../../files/index.js'\nimport { InputPeerLike } from '../../peers/index.js'\nimport { VenueSource } from '../venue.js'\n\nexport interface CaptionMixin {\n /**\n * Caption of the media\n */\n caption?: InputText\n}\n\nexport interface FileMixin {\n /**\n * File to be sent\n */\n file: InputFileLike\n\n /**\n * Override file name for the file.\n *\n * Only applicable to newly uploaded files.\n */\n fileName?: string\n\n /**\n * Override MIME type for the file\n *\n * Only applicable to newly uploaded files.\n */\n fileMime?: string\n\n /**\n * Override file size for the file\n *\n * Only applicable to newly uploaded files.\n */\n fileSize?: number\n\n /**\n * TTL for the media in seconds.\n *\n * Only applicable to some media types\n */\n ttlSeconds?: number\n}\n\n/**\n * Automatically detect media type based on file contents.\n *\n * Photo type is only inferred for reused files,\n * newly uploaded photos with `auto` will be\n * uploaded as a document\n */\nexport interface InputMediaAuto extends FileMixin, CaptionMixin {\n type: 'auto'\n}\n\n/**\n * An audio file or voice message to be sent\n */\nexport interface InputMediaAudio extends FileMixin, CaptionMixin {\n type: 'audio'\n\n /**\n * Thumbnail of the audio file album cover.\n *\n * The thumbnail should be in JPEG format and less than 200 KB in size.\n * A thumbnail's width and height should not exceed 320 pixels.\n * Thumbnails can't be reused and can be only uploaded as a new file.\n *\n * Only applicable to newly uploaded files.\n */\n thumb?: InputFileLike\n\n /**\n * Duration of the audio in seconds\n *\n * Only applicable to newly uploaded files.\n */\n duration?: number\n\n /**\n * Performer of the audio\n *\n * Only applicable to newly uploaded files.\n */\n performer?: string\n\n /**\n * Title of the audio\n *\n * Only applicable to newly uploaded files.\n */\n title?: string\n}\n\n/**\n * Voice message to be sent\n */\nexport interface InputMediaVoice extends FileMixin, CaptionMixin {\n type: 'voice'\n\n /**\n * Duration of the voice message in seconds\n *\n * Only applicable to newly uploaded files.\n */\n duration?: number\n\n /**\n * Waveform of the voice message.\n *\n * Represented with integers in range [0, 31],\n * usually has length of 100.\n * Generated by the server if omitted.\n *\n * Only applicable to newly uploaded files.\n */\n waveform?: number[]\n}\n\n/**\n * A generic file to be sent\n */\nexport interface InputMediaDocument extends FileMixin, CaptionMixin {\n type: 'document'\n\n /**\n * Thumbnail of the document.\n *\n * The thumbnail should be in JPEG format and less than 200 KB in size.\n * A thumbnail's width and height should not exceed 320 pixels.\n * Thumbnails can't be reused and can be only uploaded as a new file.\n *\n * Only applicable to newly uploaded files.\n */\n thumb?: InputFileLike\n}\n\n/**\n * A photo to be sent\n */\nexport interface InputMediaPhoto extends FileMixin, CaptionMixin {\n type: 'photo'\n\n /**\n * Whether this photo should be hidden with a spoiler\n */\n spoiler?: boolean\n}\n\n/**\n * A sticker to be sent\n */\nexport interface InputMediaSticker extends FileMixin, CaptionMixin {\n type: 'sticker'\n\n /**\n * Whether this sticker is animated?\n *\n * Note that animated stickers must be in TGS\n * format, which is Lottie JSON compressed using GZip\n *\n * Only applicable to newly uploaded files.\n *\n * @default false\n */\n isAnimated?: boolean\n\n /**\n * An emoji representing this sticker\n *\n * Only applicable to newly uploaded files,\n * for some reason doesn't work with animated stickers.\n */\n alt?: string\n}\n\n/**\n * A video to be sent\n */\nexport interface InputMediaVideo extends FileMixin, CaptionMixin {\n type: 'video'\n\n /**\n * Thumbnail of the video.\n *\n * The thumbnail should be in JPEG format and less than 200 KB in size.\n * A thumbnail's width and height should not exceed 320 pixels.\n * Thumbnails can't be reused and can be only uploaded as a new file.\n *\n * Only applicable to newly uploaded files.\n */\n thumb?: InputFileLike\n\n /**\n * Width of the video in pixels\n *\n * Only applicable to newly uploaded files.\n */\n width?: number\n\n /**\n * Height of the video in pixels\n *\n * Only applicable to newly uploaded files.\n */\n height?: number\n\n /**\n * Duration of the video in seconds\n *\n * Only applicable to newly uploaded files.\n */\n duration?: number\n\n /**\n * Whether the video is suitable for streaming\n *\n * Only applicable to newly uploaded files.\n */\n supportsStreaming?: boolean\n\n /**\n * Whether this video is an animated GIF\n *\n * Only applicable to newly uploaded files.\n */\n isAnimated?: boolean\n\n /**\n * Whether this video is a round message (aka video note)\n *\n * Only applicable to newly uploaded files.\n */\n isRound?: boolean\n\n /**\n * Whether this video should be hidden with a spoiler\n */\n spoiler?: boolean\n}\n\n/**\n * A geolocation to be sent\n */\nexport interface InputMediaGeo extends CaptionMixin {\n type: 'geo'\n\n /**\n * Latitude of the geolocation\n */\n latitude: number\n\n /**\n * Longitude of the geolocation\n */\n longitude: number\n\n /**\n * The estimated horizontal accuracy of the\n * geolocation, in meters (0-1500)\n */\n accuracy?: number\n}\n\n/**\n * A live geolocation to be sent\n */\nexport interface InputMediaGeoLive extends Omit<InputMediaGeo, 'type'> {\n type: 'geo_live'\n\n /**\n * Whether sending of the geolocation has stopped\n */\n stopped?: boolean\n\n /**\n * Direction in which the location moves, in degrees (1-360)\n */\n heading?: number\n\n /**\n * Validity period of the live location\n */\n period?: number\n\n /**\n * Maximum distance to another chat member for proximity\n * alerts, in meters (0-100000)\n */\n proximityNotificationRadius?: number\n}\n\n/**\n * An animated dice with a random value to be sent\n *\n * For convenience, known dice emojis are available\n * as static members of {@link Dice}.\n *\n * Note that dice result value is generated randomly on the server,\n * you can't influence it in any way!\n */\nexport interface InputMediaDice extends CaptionMixin {\n type: 'dice'\n\n /**\n * Emoji representing a dice\n */\n emoji: string\n}\n\n/**\n * A venue to be sent\n */\nexport interface InputMediaVenue extends CaptionMixin {\n type: 'venue'\n\n /**\n * Latitude of the geolocation\n */\n latitude: number\n\n /**\n * Longitude of the geolocation\n */\n longitude: number\n\n /**\n * Venue name\n */\n title: string\n\n /**\n * Venue address\n */\n address: string\n\n /**\n * When available, source from where this venue was acquired\n */\n source?: VenueSource\n}\n\n/**\n * A contact to be sent\n */\nexport interface InputMediaContact extends CaptionMixin {\n type: 'contact'\n\n /**\n * Contact's phone number\n */\n phone: string\n\n /**\n * Contact's first name\n */\n firstName: string\n\n /**\n * Contact's last name\n */\n lastName?: string\n\n /**\n * Additional data about the contact\n * as a vCard (0-2048 bytes)\n */\n vcard?: string\n}\n\n/**\n * A game to be sent\n */\nexport interface InputMediaGame extends CaptionMixin {\n type: 'game'\n\n /**\n * Game's short name, or a TL object with an input game\n */\n game: string | tl.TypeInputGame\n}\n\n/**\n * An invoice to be sent (see https://core.telegram.org/bots/payments)\n */\nexport interface InputMediaInvoice extends CaptionMixin {\n type: 'invoice'\n\n /**\n * Product name (1-32 chars)\n */\n title: string\n\n /**\n * Product description (1-255 chars)\n */\n description: string\n\n /**\n * The invoice itself\n */\n invoice: tl.TypeInvoice\n\n /**\n * Bot-defined invoice payload (1-128 bytes).\n *\n * Will not be displayed to the user and can be used\n * for internal processes\n */\n payload: Uint8Array\n\n /**\n * Payments provider token, obtained from\n * [@BotFather](//t.me/botfather)\n */\n token: string\n\n /**\n * Data about the invoice as a plain JS object, which\n * will be shared with the payment provider. A detailed\n * description of required fields should be provided by\n * the payment provider.\n */\n providerData: unknown\n\n /**\n * Start parameter for the bot\n */\n startParam: string\n\n /**\n * Product photo. Can be a photo of the goods or a marketing image for a service.\n *\n * Can be a URL, or a TL object with input web document\n */\n photo?: string | tl.TypeInputWebDocument\n\n /**\n * Extended media (i.e. media that will be available once the invoice is paid)\n */\n extendedMedia?: InputMediaLike\n}\n\n/**\n * A simple poll to be sent\n *\n * > **Note**: when using user account,\n * > the poll can't be sent to PMs, only to channels/groups,\n * > otherwise there will be `MEDIA_INVALID` error.\n */\nexport interface InputMediaPoll extends CaptionMixin {\n type: 'poll'\n\n /**\n * Question of the poll (1-255 chars for users, 1-300 chars for bots)\n */\n question: InputText\n\n /**\n * Answers of the poll.\n *\n * You can either provide a string, or a\n * TL object representing an answer.\n * Strings will be transformed to TL\n * objects, with a single=byte incrementing\n * `option` value.\n */\n answers: (InputText | tl.TypePollAnswer)[]\n\n /**\n * Whether this is poll is closed\n * (i.e. nobody can vote anymore)\n */\n closed?: boolean\n\n /**\n * Whether this is a public poll\n * (i.e. users who have voted are visible to everyone)\n */\n public?: boolean\n\n /**\n * Whether users can select multiple answers\n * as an answer\n */\n multiple?: boolean\n\n /**\n * Amount of time in seconds the poll will be active after creation (5-600).\n *\n * Can't be used together with `closeDate`.\n */\n closePeriod?: number\n\n /**\n * Point in time when the poll will be automatically closed.\n *\n * Must be at least 5 and no more than 600 seconds in the future,\n * can't be used together with `closePeriod`.\n *\n * When `number` is used, UNIX time in ms is expected\n */\n closeDate?: number | Date\n}\n\n/**\n * A quiz to be sent.\n *\n * Quiz is an extended version of a poll, but quizzes have\n * correct answers, and votes can't be retracted from them\n */\nexport interface InputMediaQuiz extends Omit<InputMediaPoll, 'type'> {\n type: 'quiz'\n\n /**\n * Correct answer ID(s) or index(es).\n *\n * > **Note**: even though quizzes can actually\n * > only have exactly one correct answer,\n * > the API itself has the possibility to pass\n * > multiple or zero correct answers,\n * > but that would result in `QUIZ_CORRECT_ANSWERS_TOO_MUCH`\n * > and `QUIZ_CORRECT_ANSWERS_EMPTY` errors respectively.\n * >\n * > But since the API has that option, we also provide it,\n * > maybe to future-proof this :shrug:\n */\n correct: MaybeArray<number | Uint8Array>\n\n /**\n * Explanation of the quiz solution\n */\n solution?: InputText\n}\n\n/**\n * A story to be sent\n */\nexport interface InputMediaStory extends CaptionMixin {\n type: 'story'\n\n /**\n * Owner of the story\n */\n peer: InputPeerLike\n\n /**\n * ID of the story\n */\n id: number\n}\n\n/** A webpage to be sent */\nexport interface InputMediaWebpage extends CaptionMixin {\n type: 'webpage'\n\n /**\n * Whether the link must be present in the message\n * for the preview to appear\n */\n required?: boolean\n\n /**\n * By default, size of the media in the preview\n * is determined based on content type.\n *\n * You can override this behaviour by passing the wanted size here\n */\n size?: 'large' | 'small'\n\n /** Webpage URL */\n url: string\n}\n\n/**\n * Input media that can be sent somewhere.\n *\n * Note that meta-fields (like `duration`) are only\n * applicable if `file` is {@link UploadFileLike},\n * otherwise they are ignored.\n *\n * @link InputMedia\n */\nexport type InputMediaLike =\n | InputMediaAudio\n | InputMediaVoice\n | InputMediaDocument\n | InputMediaPhoto\n | InputMediaVideo\n | InputMediaAuto\n | InputMediaSticker\n | InputMediaVenue\n | InputMediaGeo\n | InputMediaGeoLive\n | InputMediaDice\n | InputMediaContact\n | InputMediaGame\n | InputMediaInvoice\n | InputMediaPoll\n | InputMediaQuiz\n | InputMediaStory\n | InputMediaWebpage\n | tl.TypeInputMedia\n"]}
@@ -1,34 +1,41 @@
1
1
  import { tl } from '@mtcute/tl';
2
2
  import { MessageEntity } from '../messages/message-entity.js';
3
3
  import { PeersIndex } from '../peers/peers-index.js';
4
- export interface PollAnswer {
4
+ export declare class PollAnswer {
5
+ readonly raw: tl.TypePollAnswer;
6
+ readonly result?: tl.RawPollAnswerVoters | undefined;
7
+ constructor(raw: tl.TypePollAnswer, result?: tl.RawPollAnswerVoters | undefined);
5
8
  /**
6
9
  * Answer text
7
10
  */
8
- text: string;
11
+ get text(): string;
12
+ /**
13
+ * Format entities for {@link text}, currently may only contain custom emojis
14
+ */
15
+ get textEntities(): ReadonlyArray<MessageEntity>;
9
16
  /**
10
17
  * Answer data, to be passed to
11
18
  * {@link TelegramClient.sendVote}
12
19
  */
13
- data: Uint8Array;
20
+ get data(): Uint8Array;
14
21
  /**
15
22
  * Number of people who has chosen this result.
16
23
  * If not available (i.e. not voted yet)
17
24
  *
18
25
  * @default `0`
19
26
  */
20
- voters: number;
27
+ get voters(): number;
21
28
  /**
22
29
  * Whether this answer was chosen by the current user
23
30
  */
24
- chosen: boolean;
31
+ get chosen(): boolean;
25
32
  /**
26
33
  * Whether this answer is correct (for quizzes).
27
34
  * Not available before choosing an answer
28
35
  *
29
36
  * @default `false`
30
37
  */
31
- correct: boolean;
38
+ get correct(): boolean;
32
39
  }
33
40
  export declare class Poll {
34
41
  readonly raw: tl.TypePoll;
@@ -44,6 +51,10 @@ export declare class Poll {
44
51
  * Poll question
45
52
  */
46
53
  get question(): string;
54
+ /**
55
+ * Format entities for {@link question} (currently may only contain custom emojis)
56
+ */
57
+ get questionEntities(): ReadonlyArray<MessageEntity>;
47
58
  /**
48
59
  * List of answers in this poll
49
60
  */
@@ -3,11 +3,65 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Poll = void 0;
6
+ exports.Poll = exports.PollAnswer = void 0;
7
7
  const long_1 = __importDefault(require("long"));
8
8
  const index_js_1 = require("../../utils/index.js");
9
9
  const memoize_js_1 = require("../../utils/memoize.js");
10
10
  const message_entity_js_1 = require("../messages/message-entity.js");
11
+ class PollAnswer {
12
+ raw;
13
+ result;
14
+ constructor(raw, result) {
15
+ this.raw = raw;
16
+ this.result = result;
17
+ }
18
+ /**
19
+ * Answer text
20
+ */
21
+ get text() {
22
+ return this.raw.text.text;
23
+ }
24
+ /**
25
+ * Format entities for {@link text}, currently may only contain custom emojis
26
+ */
27
+ get textEntities() {
28
+ return this.raw.text.entities.map((ent) => new message_entity_js_1.MessageEntity(ent, this.raw.text.text));
29
+ }
30
+ /**
31
+ * Answer data, to be passed to
32
+ * {@link TelegramClient.sendVote}
33
+ */
34
+ get data() {
35
+ return this.raw.option;
36
+ }
37
+ /**
38
+ * Number of people who has chosen this result.
39
+ * If not available (i.e. not voted yet)
40
+ *
41
+ * @default `0`
42
+ */
43
+ get voters() {
44
+ return this.result?.voters ?? 0;
45
+ }
46
+ /**
47
+ * Whether this answer was chosen by the current user
48
+ */
49
+ get chosen() {
50
+ return Boolean(this.result?.chosen);
51
+ }
52
+ /**
53
+ * Whether this answer is correct (for quizzes).
54
+ * Not available before choosing an answer
55
+ *
56
+ * @default `false`
57
+ */
58
+ get correct() {
59
+ return Boolean(this.result?.correct);
60
+ }
61
+ }
62
+ exports.PollAnswer = PollAnswer;
63
+ (0, memoize_js_1.memoizeGetters)(PollAnswer, ['textEntities']);
64
+ (0, index_js_1.makeInspectable)(PollAnswer);
11
65
  class Poll {
12
66
  raw;
13
67
  _peers;
@@ -28,7 +82,13 @@ class Poll {
28
82
  * Poll question
29
83
  */
30
84
  get question() {
31
- return this.raw.question;
85
+ return this.raw.question.text;
86
+ }
87
+ /**
88
+ * Format entities for {@link question} (currently may only contain custom emojis)
89
+ */
90
+ get questionEntities() {
91
+ return this.raw.question.entities.map((ent) => new message_entity_js_1.MessageEntity(ent, this.raw.question.text));
32
92
  }
33
93
  /**
34
94
  * List of answers in this poll
@@ -37,22 +97,9 @@ class Poll {
37
97
  const results = this.results?.results;
38
98
  return this.raw.answers.map((ans, idx) => {
39
99
  if (results) {
40
- const res = results[idx];
41
- return {
42
- text: ans.text,
43
- data: ans.option,
44
- voters: res.voters,
45
- chosen: Boolean(res.chosen),
46
- correct: Boolean(res.correct),
47
- };
100
+ return new PollAnswer(ans, results[idx]);
48
101
  }
49
- return {
50
- text: ans.text,
51
- data: ans.option,
52
- voters: 0,
53
- chosen: false,
54
- correct: false,
55
- };
102
+ return new PollAnswer(ans);
56
103
  });
57
104
  }
58
105
  /**
@@ -142,6 +189,6 @@ class Poll {
142
189
  }
143
190
  }
144
191
  exports.Poll = Poll;
145
- (0, memoize_js_1.memoizeGetters)(Poll, ['answers', 'solutionEntities']);
192
+ (0, memoize_js_1.memoizeGetters)(Poll, ['answers', 'solutionEntities', 'questionEntities']);
146
193
  (0, index_js_1.makeInspectable)(Poll, undefined, ['inputMedia']);
147
194
  //# sourceMappingURL=poll.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"poll.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/media/poll.ts"],"names":[],"mappings":"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","sourcesContent":["import Long from 'long'\n\nimport { tl } from '@mtcute/tl'\n\nimport { makeInspectable } from '../../utils/index.js'\nimport { memoizeGetters } from '../../utils/memoize.js'\nimport { MessageEntity } from '../messages/message-entity.js'\nimport { PeersIndex } from '../peers/peers-index.js'\n\nexport interface PollAnswer {\n /**\n * Answer text\n */\n text: string\n\n /**\n * Answer data, to be passed to\n * {@link TelegramClient.sendVote}\n */\n data: Uint8Array\n\n /**\n * Number of people who has chosen this result.\n * If not available (i.e. not voted yet)\n *\n * @default `0`\n */\n voters: number\n\n /**\n * Whether this answer was chosen by the current user\n */\n chosen: boolean\n\n /**\n * Whether this answer is correct (for quizzes).\n * Not available before choosing an answer\n *\n * @default `false`\n */\n correct: boolean\n}\n\nexport class Poll {\n readonly type = 'poll' as const\n\n constructor(\n readonly raw: tl.TypePoll,\n readonly _peers: PeersIndex,\n readonly results?: tl.TypePollResults,\n ) {}\n\n /**\n * Unique identifier of the poll\n */\n get id(): tl.Long {\n return this.raw.id\n }\n\n /**\n * Poll question\n */\n get question(): string {\n return this.raw.question\n }\n\n /**\n * List of answers in this poll\n */\n get answers(): ReadonlyArray<PollAnswer> {\n const results = this.results?.results\n\n return this.raw.answers.map((ans, idx) => {\n if (results) {\n const res = results[idx]\n\n return {\n text: ans.text,\n data: ans.option,\n voters: res.voters,\n chosen: Boolean(res.chosen),\n correct: Boolean(res.correct),\n }\n }\n\n return {\n text: ans.text,\n data: ans.option,\n voters: 0,\n chosen: false,\n correct: false,\n }\n })\n }\n\n /**\n * Total number of voters in this poll, if available\n */\n get voters(): number {\n return this.results?.totalVoters ?? 0\n }\n\n /**\n * Whether this poll is closed, i.e. does not\n * accept votes anymore\n */\n get isClosed(): boolean {\n return this.raw.closed!\n }\n\n /**\n * Whether this poll is public, i.e. you\n * list of voters is publicly available\n */\n get isPublic(): boolean {\n return this.raw.publicVoters!\n }\n\n /**\n * Whether this is a quiz\n */\n get isQuiz(): boolean {\n return this.raw.quiz!\n }\n\n /**\n * Whether this poll accepts multiple answers\n */\n get isMultiple(): boolean {\n return this.raw.multipleChoice!\n }\n\n /**\n * Solution for the quiz, only available\n * in case you have already answered\n */\n get solution(): string | null {\n return this.results?.solution ?? null\n }\n\n /**\n * Format entities for {@link solution}, only available\n * in case you have already answered\n */\n get solutionEntities(): ReadonlyArray<MessageEntity> | null {\n if (!this.results) return null\n\n const res: MessageEntity[] = []\n\n if (this.results.solutionEntities?.length) {\n for (const ent of this.results.solutionEntities) {\n res.push(new MessageEntity(ent, this.results.solution))\n }\n }\n\n return res\n }\n\n /**\n * Input media TL object generated from this object,\n * to be used inside {@link InputMediaLike} and\n * {@link TelegramClient.sendMedia}\n *\n * A few notes:\n * - Using this will result in an\n * independent poll, which will not\n * be auto-updated with the current.\n * - If this is a quiz, a normal poll\n * will be returned since the client does not\n * know the correct answer.\n * - This always returns a non-closed poll,\n * even if the current poll was closed\n */\n get inputMedia(): tl.TypeInputMedia {\n return {\n _: 'inputMediaPoll',\n poll: {\n _: 'poll',\n closed: false,\n id: Long.ZERO,\n publicVoters: this.raw.publicVoters,\n multipleChoice: this.raw.multipleChoice,\n question: this.raw.question,\n answers: this.raw.answers,\n closePeriod: this.raw.closePeriod,\n closeDate: this.raw.closeDate,\n },\n }\n }\n}\n\nmemoizeGetters(Poll, ['answers', 'solutionEntities'])\nmakeInspectable(Poll, undefined, ['inputMedia'])\n"]}
1
+ {"version":3,"file":"poll.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/media/poll.ts"],"names":[],"mappings":"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","sourcesContent":["import Long from 'long'\n\nimport { tl } from '@mtcute/tl'\n\nimport { makeInspectable } from '../../utils/index.js'\nimport { memoizeGetters } from '../../utils/memoize.js'\nimport { MessageEntity } from '../messages/message-entity.js'\nimport { PeersIndex } from '../peers/peers-index.js'\n\nexport class PollAnswer {\n constructor(\n readonly raw: tl.TypePollAnswer,\n readonly result?: tl.TypePollAnswerVoters,\n ) {}\n /**\n * Answer text\n */\n get text(): string {\n return this.raw.text.text\n }\n\n /**\n * Format entities for {@link text}, currently may only contain custom emojis\n */\n get textEntities(): ReadonlyArray<MessageEntity> {\n return this.raw.text.entities.map((ent) => new MessageEntity(ent, this.raw.text.text))\n }\n\n /**\n * Answer data, to be passed to\n * {@link TelegramClient.sendVote}\n */\n get data(): Uint8Array {\n return this.raw.option\n }\n\n /**\n * Number of people who has chosen this result.\n * If not available (i.e. not voted yet)\n *\n * @default `0`\n */\n get voters(): number {\n return this.result?.voters ?? 0\n }\n\n /**\n * Whether this answer was chosen by the current user\n */\n get chosen(): boolean {\n return Boolean(this.result?.chosen)\n }\n\n /**\n * Whether this answer is correct (for quizzes).\n * Not available before choosing an answer\n *\n * @default `false`\n */\n get correct(): boolean {\n return Boolean(this.result?.correct)\n }\n}\n\nmemoizeGetters(PollAnswer, ['textEntities'])\nmakeInspectable(PollAnswer)\n\nexport class Poll {\n readonly type = 'poll' as const\n\n constructor(\n readonly raw: tl.TypePoll,\n readonly _peers: PeersIndex,\n readonly results?: tl.TypePollResults,\n ) {}\n\n /**\n * Unique identifier of the poll\n */\n get id(): tl.Long {\n return this.raw.id\n }\n\n /**\n * Poll question\n */\n get question(): string {\n return this.raw.question.text\n }\n\n /**\n * Format entities for {@link question} (currently may only contain custom emojis)\n */\n get questionEntities(): ReadonlyArray<MessageEntity> {\n return this.raw.question.entities.map((ent) => new MessageEntity(ent, this.raw.question.text))\n }\n\n /**\n * List of answers in this poll\n */\n get answers(): ReadonlyArray<PollAnswer> {\n const results = this.results?.results\n\n return this.raw.answers.map((ans, idx) => {\n if (results) {\n return new PollAnswer(ans, results[idx])\n }\n\n return new PollAnswer(ans)\n })\n }\n\n /**\n * Total number of voters in this poll, if available\n */\n get voters(): number {\n return this.results?.totalVoters ?? 0\n }\n\n /**\n * Whether this poll is closed, i.e. does not\n * accept votes anymore\n */\n get isClosed(): boolean {\n return this.raw.closed!\n }\n\n /**\n * Whether this poll is public, i.e. you\n * list of voters is publicly available\n */\n get isPublic(): boolean {\n return this.raw.publicVoters!\n }\n\n /**\n * Whether this is a quiz\n */\n get isQuiz(): boolean {\n return this.raw.quiz!\n }\n\n /**\n * Whether this poll accepts multiple answers\n */\n get isMultiple(): boolean {\n return this.raw.multipleChoice!\n }\n\n /**\n * Solution for the quiz, only available\n * in case you have already answered\n */\n get solution(): string | null {\n return this.results?.solution ?? null\n }\n\n /**\n * Format entities for {@link solution}, only available\n * in case you have already answered\n */\n get solutionEntities(): ReadonlyArray<MessageEntity> | null {\n if (!this.results) return null\n\n const res: MessageEntity[] = []\n\n if (this.results.solutionEntities?.length) {\n for (const ent of this.results.solutionEntities) {\n res.push(new MessageEntity(ent, this.results.solution))\n }\n }\n\n return res\n }\n\n /**\n * Input media TL object generated from this object,\n * to be used inside {@link InputMediaLike} and\n * {@link TelegramClient.sendMedia}\n *\n * A few notes:\n * - Using this will result in an\n * independent poll, which will not\n * be auto-updated with the current.\n * - If this is a quiz, a normal poll\n * will be returned since the client does not\n * know the correct answer.\n * - This always returns a non-closed poll,\n * even if the current poll was closed\n */\n get inputMedia(): tl.TypeInputMedia {\n return {\n _: 'inputMediaPoll',\n poll: {\n _: 'poll',\n closed: false,\n id: Long.ZERO,\n publicVoters: this.raw.publicVoters,\n multipleChoice: this.raw.multipleChoice,\n question: this.raw.question,\n answers: this.raw.answers,\n closePeriod: this.raw.closePeriod,\n closeDate: this.raw.closeDate,\n },\n }\n }\n}\n\nmemoizeGetters(Poll, ['answers', 'solutionEntities', 'questionEntities'])\nmakeInspectable(Poll, undefined, ['inputMedia'])\n"]}
@@ -169,18 +169,7 @@ class Dialog {
169
169
  * Chat that this dialog represents
170
170
  */
171
171
  get chat() {
172
- const peer = this.raw.peer;
173
- let chat;
174
- switch (peer._) {
175
- case 'peerChannel':
176
- case 'peerChat':
177
- chat = this._peers.chat(peer._ === 'peerChannel' ? peer.channelId : peer.chatId);
178
- break;
179
- default:
180
- chat = this._peers.user(peer.userId);
181
- break;
182
- }
183
- return new chat_js_1.Chat(chat);
172
+ return chat_js_1.Chat._parseFromPeer(this.raw.peer, this._peers);
184
173
  }
185
174
  /**
186
175
  * The latest message sent in this chat