@xbibzlibrary/telebibz 0.4.5 → 3.1.1

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 (276) hide show
  1. package/CHANGELOG.md +53 -138
  2. package/LICENSE +1 -1
  3. package/NOTICE.md +9 -4
  4. package/README.id.md +542 -206
  5. package/README.md +539 -213
  6. package/examples/01-quickstart.js +13 -0
  7. package/examples/02-menu-tombol.js +22 -0
  8. package/examples/03-wizard.js +58 -0
  9. package/examples/04-broadcast.js +25 -0
  10. package/examples/05-kirim-file.js +19 -0
  11. package/examples/06-menu.js +35 -0
  12. package/examples/07-inline-query.js +18 -0
  13. package/index.d.ts +106 -0
  14. package/index.js +44 -0
  15. package/lib/api.js +154 -0
  16. package/lib/broadcast.js +35 -0
  17. package/lib/composer.js +174 -0
  18. package/lib/context.js +190 -0
  19. package/lib/errors.js +35 -0
  20. package/lib/file.js +41 -0
  21. package/lib/inline-query.js +28 -0
  22. package/lib/keyboard.js +83 -0
  23. package/lib/logger.js +38 -0
  24. package/lib/menus.js +90 -0
  25. package/lib/net.js +115 -0
  26. package/lib/ratelimit.js +61 -0
  27. package/lib/runner.js +45 -0
  28. package/lib/session.js +36 -0
  29. package/lib/telebibz.js +193 -0
  30. package/lib/wizard.js +247 -0
  31. package/package.json +35 -97
  32. package/test/all.test.js +439 -0
  33. package/CODE_OF_CONDUCT.md +0 -37
  34. package/CONTRIBUTING.md +0 -59
  35. package/CONTRIBUTION_RULES.md +0 -41
  36. package/GOVERNANCE.md +0 -47
  37. package/README.zh-CN.md +0 -306
  38. package/RELEASE_AUTOMATION.md +0 -78
  39. package/RELEASE_POLICY.md +0 -32
  40. package/SECURITY.md +0 -47
  41. package/SHOWCASE.md +0 -29
  42. package/SUPPORT.md +0 -30
  43. package/assets/readme-preview.html +0 -75
  44. package/assets/telebibz-logo.png +0 -0
  45. package/assets/telebibz-readme-preview.png +0 -0
  46. package/bin/telebibz.mjs +0 -3
  47. package/dist/generated/api.d.ts +0 -13
  48. package/dist/generated/api.d.ts.map +0 -1
  49. package/dist/generated/api.js +0 -192
  50. package/dist/generated/api.js.map +0 -1
  51. package/dist/src/api/client.d.ts +0 -62
  52. package/dist/src/api/client.d.ts.map +0 -1
  53. package/dist/src/api/client.js +0 -104
  54. package/dist/src/api/client.js.map +0 -1
  55. package/dist/src/api/errors.d.ts +0 -45
  56. package/dist/src/api/errors.d.ts.map +0 -1
  57. package/dist/src/api/errors.js +0 -65
  58. package/dist/src/api/errors.js.map +0 -1
  59. package/dist/src/api/index.d.ts +0 -6
  60. package/dist/src/api/index.d.ts.map +0 -1
  61. package/dist/src/api/index.js +0 -6
  62. package/dist/src/api/index.js.map +0 -1
  63. package/dist/src/api/telegram-types/LICENSE +0 -21
  64. package/dist/src/api/telegram-types/api.d.ts +0 -22
  65. package/dist/src/api/telegram-types/checklist.d.ts +0 -72
  66. package/dist/src/api/telegram-types/inline.d.ts +0 -692
  67. package/dist/src/api/telegram-types/langs.d.ts +0 -193
  68. package/dist/src/api/telegram-types/manage.d.ts +0 -1144
  69. package/dist/src/api/telegram-types/markup.d.ts +0 -268
  70. package/dist/src/api/telegram-types/message.d.ts +0 -1537
  71. package/dist/src/api/telegram-types/methods.d.ts +0 -2870
  72. package/dist/src/api/telegram-types/mod.d.ts +0 -14
  73. package/dist/src/api/telegram-types/passport.d.ts +0 -163
  74. package/dist/src/api/telegram-types/payment.d.ts +0 -570
  75. package/dist/src/api/telegram-types/rich.d.ts +0 -1010
  76. package/dist/src/api/telegram-types/settings.d.ts +0 -120
  77. package/dist/src/api/telegram-types/story.d.ts +0 -89
  78. package/dist/src/api/telegram-types/update.d.ts +0 -84
  79. package/dist/src/api/telegram.d.ts +0 -7
  80. package/dist/src/api/telegram.d.ts.map +0 -1
  81. package/dist/src/api/telegram.js +0 -2
  82. package/dist/src/api/telegram.js.map +0 -1
  83. package/dist/src/api/transport.d.ts +0 -68
  84. package/dist/src/api/transport.d.ts.map +0 -1
  85. package/dist/src/api/transport.js +0 -264
  86. package/dist/src/api/transport.js.map +0 -1
  87. package/dist/src/api/types.d.ts +0 -466
  88. package/dist/src/api/types.d.ts.map +0 -1
  89. package/dist/src/api/types.js +0 -2
  90. package/dist/src/api/types.js.map +0 -1
  91. package/dist/src/branding/terminal.d.ts +0 -77
  92. package/dist/src/branding/terminal.d.ts.map +0 -1
  93. package/dist/src/branding/terminal.js +0 -328
  94. package/dist/src/branding/terminal.js.map +0 -1
  95. package/dist/src/broadcast/broadcast.d.ts +0 -50
  96. package/dist/src/broadcast/broadcast.d.ts.map +0 -1
  97. package/dist/src/broadcast/broadcast.js +0 -56
  98. package/dist/src/broadcast/broadcast.js.map +0 -1
  99. package/dist/src/cache/cache.d.ts +0 -34
  100. package/dist/src/cache/cache.d.ts.map +0 -1
  101. package/dist/src/cache/cache.js +0 -41
  102. package/dist/src/cache/cache.js.map +0 -1
  103. package/dist/src/cli.d.ts +0 -2
  104. package/dist/src/cli.d.ts.map +0 -1
  105. package/dist/src/cli.js +0 -84
  106. package/dist/src/cli.js.map +0 -1
  107. package/dist/src/context/context.d.ts +0 -124
  108. package/dist/src/context/context.d.ts.map +0 -1
  109. package/dist/src/context/context.js +0 -302
  110. package/dist/src/context/context.js.map +0 -1
  111. package/dist/src/core/bot.d.ts +0 -204
  112. package/dist/src/core/bot.d.ts.map +0 -1
  113. package/dist/src/core/bot.js +0 -506
  114. package/dist/src/core/bot.js.map +0 -1
  115. package/dist/src/core/events.d.ts +0 -75
  116. package/dist/src/core/events.d.ts.map +0 -1
  117. package/dist/src/core/events.js +0 -35
  118. package/dist/src/core/events.js.map +0 -1
  119. package/dist/src/core/webhook-reply.d.ts +0 -34
  120. package/dist/src/core/webhook-reply.d.ts.map +0 -1
  121. package/dist/src/core/webhook-reply.js +0 -37
  122. package/dist/src/core/webhook-reply.js.map +0 -1
  123. package/dist/src/index.d.ts +0 -24
  124. package/dist/src/index.d.ts.map +0 -1
  125. package/dist/src/index.js +0 -24
  126. package/dist/src/index.js.map +0 -1
  127. package/dist/src/keyboard/index.d.ts +0 -46
  128. package/dist/src/keyboard/index.d.ts.map +0 -1
  129. package/dist/src/keyboard/index.js +0 -55
  130. package/dist/src/keyboard/index.js.map +0 -1
  131. package/dist/src/middleware/compose.d.ts +0 -5
  132. package/dist/src/middleware/compose.d.ts.map +0 -1
  133. package/dist/src/middleware/compose.js +0 -17
  134. package/dist/src/middleware/compose.js.map +0 -1
  135. package/dist/src/observability/logger.d.ts +0 -78
  136. package/dist/src/observability/logger.d.ts.map +0 -1
  137. package/dist/src/observability/logger.js +0 -285
  138. package/dist/src/observability/logger.js.map +0 -1
  139. package/dist/src/plugins/plugin.d.ts +0 -38
  140. package/dist/src/plugins/plugin.d.ts.map +0 -1
  141. package/dist/src/plugins/plugin.js +0 -59
  142. package/dist/src/plugins/plugin.js.map +0 -1
  143. package/dist/src/queue/queue.d.ts +0 -77
  144. package/dist/src/queue/queue.d.ts.map +0 -1
  145. package/dist/src/queue/queue.js +0 -213
  146. package/dist/src/queue/queue.js.map +0 -1
  147. package/dist/src/router/router.d.ts +0 -61
  148. package/dist/src/router/router.d.ts.map +0 -1
  149. package/dist/src/router/router.js +0 -183
  150. package/dist/src/router/router.js.map +0 -1
  151. package/dist/src/state/conversation.d.ts +0 -56
  152. package/dist/src/state/conversation.d.ts.map +0 -1
  153. package/dist/src/state/conversation.js +0 -133
  154. package/dist/src/state/conversation.js.map +0 -1
  155. package/dist/src/state/forms.d.ts +0 -34
  156. package/dist/src/state/forms.d.ts.map +0 -1
  157. package/dist/src/state/forms.js +0 -44
  158. package/dist/src/state/forms.js.map +0 -1
  159. package/dist/src/state/menu.d.ts +0 -78
  160. package/dist/src/state/menu.d.ts.map +0 -1
  161. package/dist/src/state/menu.js +0 -127
  162. package/dist/src/state/menu.js.map +0 -1
  163. package/dist/src/storage/storage.d.ts +0 -146
  164. package/dist/src/storage/storage.d.ts.map +0 -1
  165. package/dist/src/storage/storage.js +0 -195
  166. package/dist/src/storage/storage.js.map +0 -1
  167. package/dist/src/telegram-features.d.ts +0 -33
  168. package/dist/src/telegram-features.d.ts.map +0 -1
  169. package/dist/src/telegram-features.js +0 -71
  170. package/dist/src/telegram-features.js.map +0 -1
  171. package/dist/src/testing.d.ts +0 -24
  172. package/dist/src/testing.d.ts.map +0 -1
  173. package/dist/src/testing.js +0 -38
  174. package/dist/src/testing.js.map +0 -1
  175. package/dist/src/utils/concurrency.d.ts +0 -25
  176. package/dist/src/utils/concurrency.d.ts.map +0 -1
  177. package/dist/src/utils/concurrency.js +0 -52
  178. package/dist/src/utils/concurrency.js.map +0 -1
  179. package/dist/src/utils/files.d.ts +0 -45
  180. package/dist/src/utils/files.d.ts.map +0 -1
  181. package/dist/src/utils/files.js +0 -53
  182. package/dist/src/utils/files.js.map +0 -1
  183. package/dist/src/utils/text.d.ts +0 -39
  184. package/dist/src/utils/text.d.ts.map +0 -1
  185. package/dist/src/utils/text.js +0 -56
  186. package/dist/src/utils/text.js.map +0 -1
  187. package/dist/src/webhook/handler.d.ts +0 -19
  188. package/dist/src/webhook/handler.d.ts.map +0 -1
  189. package/dist/src/webhook/handler.js +0 -141
  190. package/dist/src/webhook/handler.js.map +0 -1
  191. package/dist-cjs/generated/api.js +0 -194
  192. package/dist-cjs/package.json +0 -3
  193. package/dist-cjs/src/api/client.js +0 -107
  194. package/dist-cjs/src/api/errors.js +0 -74
  195. package/dist-cjs/src/api/index.js +0 -21
  196. package/dist-cjs/src/api/telegram-types/LICENSE +0 -21
  197. package/dist-cjs/src/api/telegram-types/api.d.ts +0 -22
  198. package/dist-cjs/src/api/telegram-types/checklist.d.ts +0 -72
  199. package/dist-cjs/src/api/telegram-types/inline.d.ts +0 -692
  200. package/dist-cjs/src/api/telegram-types/langs.d.ts +0 -193
  201. package/dist-cjs/src/api/telegram-types/manage.d.ts +0 -1144
  202. package/dist-cjs/src/api/telegram-types/markup.d.ts +0 -268
  203. package/dist-cjs/src/api/telegram-types/message.d.ts +0 -1537
  204. package/dist-cjs/src/api/telegram-types/methods.d.ts +0 -2870
  205. package/dist-cjs/src/api/telegram-types/mod.d.ts +0 -14
  206. package/dist-cjs/src/api/telegram-types/passport.d.ts +0 -163
  207. package/dist-cjs/src/api/telegram-types/payment.d.ts +0 -570
  208. package/dist-cjs/src/api/telegram-types/rich.d.ts +0 -1010
  209. package/dist-cjs/src/api/telegram-types/settings.d.ts +0 -120
  210. package/dist-cjs/src/api/telegram-types/story.d.ts +0 -89
  211. package/dist-cjs/src/api/telegram-types/update.d.ts +0 -84
  212. package/dist-cjs/src/api/telegram.js +0 -2
  213. package/dist-cjs/src/api/transport.js +0 -267
  214. package/dist-cjs/src/api/types.js +0 -2
  215. package/dist-cjs/src/branding/terminal.js +0 -338
  216. package/dist-cjs/src/broadcast/broadcast.js +0 -58
  217. package/dist-cjs/src/cache/cache.js +0 -45
  218. package/dist-cjs/src/cli.js +0 -86
  219. package/dist-cjs/src/context/context.js +0 -305
  220. package/dist-cjs/src/core/bot.js +0 -510
  221. package/dist-cjs/src/core/events.js +0 -38
  222. package/dist-cjs/src/core/webhook-reply.js +0 -42
  223. package/dist-cjs/src/index.js +0 -47
  224. package/dist-cjs/src/keyboard/index.js +0 -61
  225. package/dist-cjs/src/middleware/compose.js +0 -20
  226. package/dist-cjs/src/observability/logger.js +0 -293
  227. package/dist-cjs/src/plugins/plugin.js +0 -63
  228. package/dist-cjs/src/queue/queue.js +0 -219
  229. package/dist-cjs/src/router/router.js +0 -186
  230. package/dist-cjs/src/state/conversation.js +0 -139
  231. package/dist-cjs/src/state/forms.js +0 -47
  232. package/dist-cjs/src/state/menu.js +0 -133
  233. package/dist-cjs/src/storage/storage.js +0 -202
  234. package/dist-cjs/src/telegram-features.js +0 -76
  235. package/dist-cjs/src/testing.js +0 -45
  236. package/dist-cjs/src/utils/concurrency.js +0 -57
  237. package/dist-cjs/src/utils/files.js +0 -58
  238. package/dist-cjs/src/utils/text.js +0 -63
  239. package/dist-cjs/src/webhook/handler.js +0 -144
  240. package/docs/API.id.md +0 -1935
  241. package/docs/API.md +0 -1969
  242. package/docs/API.zh-CN.md +0 -1929
  243. package/docs/COOKBOOK.id.md +0 -321
  244. package/docs/COOKBOOK.md +0 -321
  245. package/docs/COOKBOOK.zh-CN.md +0 -321
  246. package/docs/ERRORS.id.md +0 -194
  247. package/docs/ERRORS.md +0 -194
  248. package/docs/ERRORS.zh-CN.md +0 -194
  249. package/docs/FILES.id.md +0 -243
  250. package/docs/FILES.md +0 -243
  251. package/docs/FILES.zh-CN.md +0 -243
  252. package/docs/GETTING_STARTED.id.md +0 -89
  253. package/docs/GETTING_STARTED.md +0 -89
  254. package/docs/GETTING_STARTED.zh-CN.md +0 -89
  255. package/docs/GITHUB_PACKAGES.id.md +0 -82
  256. package/docs/GITHUB_PACKAGES.md +0 -82
  257. package/docs/GITHUB_PACKAGES.zh-CN.md +0 -82
  258. package/docs/MIGRATION_TELEGRAF.id.md +0 -147
  259. package/docs/MIGRATION_TELEGRAF.md +0 -154
  260. package/docs/MIGRATION_TELEGRAF.zh-CN.md +0 -147
  261. package/docs/README.md +0 -67
  262. package/docs/STORAGE.id.md +0 -105
  263. package/docs/STORAGE.md +0 -105
  264. package/docs/STORAGE.zh-CN.md +0 -105
  265. package/docs/TESTING.id.md +0 -203
  266. package/docs/TESTING.md +0 -203
  267. package/docs/TESTING.zh-CN.md +0 -203
  268. package/docs/WEBHOOK.id.md +0 -212
  269. package/docs/WEBHOOK.md +0 -215
  270. package/docs/WEBHOOK.zh-CN.md +0 -212
  271. package/examples/README.md +0 -37
  272. package/examples/files.ts +0 -35
  273. package/examples/minimal.ts +0 -12
  274. package/examples/tsconfig.json +0 -9
  275. package/examples/webhook.ts +0 -42
  276. package/examples/wizard-registration.ts +0 -42
@@ -1,13 +0,0 @@
1
- /** Generated from the official Telegram Bot API documentation. Do not edit manually. */
2
- export declare const TELEGRAM_API_VERSION: "10.2";
3
- export declare const TELEGRAM_METHOD_NAMES: readonly ["addStickerToSet", "answerCallbackQuery", "answerChatJoinRequestQuery", "answerGuestQuery", "answerInlineQuery", "answerPreCheckoutQuery", "answerShippingQuery", "answerWebAppQuery", "approveChatJoinRequest", "approveSuggestedPost", "banChatMember", "banChatSenderChat", "close", "closeForumTopic", "closeGeneralForumTopic", "convertGiftToStars", "copyMessage", "copyMessages", "createChatInviteLink", "createChatSubscriptionInviteLink", "createForumTopic", "createInvoiceLink", "createNewStickerSet", "declineChatJoinRequest", "declineSuggestedPost", "deleteAllMessageReactions", "deleteBusinessMessages", "deleteChatPhoto", "deleteChatStickerSet", "deleteEphemeralMessage", "deleteForumTopic", "deleteMessage", "deleteMessageReaction", "deleteMessages", "deleteMyCommands", "deleteStickerFromSet", "deleteStickerSet", "deleteStory", "deleteWebhook", "editChatInviteLink", "editChatSubscriptionInviteLink", "editEphemeralMessageCaption", "editEphemeralMessageMedia", "editEphemeralMessageReplyMarkup", "editEphemeralMessageText", "editForumTopic", "editGeneralForumTopic", "editMessageCaption", "editMessageChecklist", "editMessageLiveLocation", "editMessageMedia", "editMessageReplyMarkup", "editMessageText", "editStory", "editUserStarSubscription", "exportChatInviteLink", "forwardMessage", "forwardMessages", "getAvailableGifts", "getBusinessAccountGifts", "getBusinessAccountStarBalance", "getBusinessConnection", "getChat", "getChatAdministrators", "getChatGifts", "getChatMember", "getChatMemberCount", "getChatMenuButton", "getCustomEmojiStickers", "getFile", "getForumTopicIconStickers", "getGameHighScores", "getManagedBotAccessSettings", "getManagedBotToken", "getMe", "getMyCommands", "getMyDefaultAdministratorRights", "getMyDescription", "getMyName", "getMyShortDescription", "getMyStarBalance", "getStarTransactions", "getStickerSet", "getUpdates", "getUserChatBoosts", "getUserGifts", "getUserPersonalChatMessages", "getUserProfileAudios", "getUserProfilePhotos", "getWebhookInfo", "giftPremiumSubscription", "hideGeneralForumTopic", "leaveChat", "logOut", "pinChatMessage", "postStory", "promoteChatMember", "readBusinessMessage", "refundStarPayment", "removeBusinessAccountProfilePhoto", "removeChatVerification", "removeMyProfilePhoto", "removeUserVerification", "reopenForumTopic", "reopenGeneralForumTopic", "replaceManagedBotToken", "replaceStickerInSet", "repostStory", "restrictChatMember", "revokeChatInviteLink", "savePreparedInlineMessage", "savePreparedKeyboardButton", "sendAnimation", "sendAudio", "sendChatAction", "sendChatJoinRequestWebApp", "sendChecklist", "sendContact", "sendDice", "sendDocument", "sendGame", "sendGift", "sendInvoice", "sendLivePhoto", "sendLocation", "sendMediaGroup", "sendMessage", "sendMessageDraft", "sendPaidMedia", "sendPhoto", "sendPoll", "sendRichMessage", "sendRichMessageDraft", "sendSticker", "sendVenue", "sendVideo", "sendVideoNote", "sendVoice", "setBusinessAccountBio", "setBusinessAccountGiftSettings", "setBusinessAccountName", "setBusinessAccountProfilePhoto", "setBusinessAccountUsername", "setChatAdministratorCustomTitle", "setChatDescription", "setChatMemberTag", "setChatMenuButton", "setChatPermissions", "setChatPhoto", "setChatStickerSet", "setChatTitle", "setCustomEmojiStickerSetThumbnail", "setGameScore", "setManagedBotAccessSettings", "setMessageReaction", "setMyCommands", "setMyDefaultAdministratorRights", "setMyDescription", "setMyName", "setMyProfilePhoto", "setMyShortDescription", "setPassportDataErrors", "setStickerEmojiList", "setStickerKeywords", "setStickerMaskPosition", "setStickerPositionInSet", "setStickerSetThumbnail", "setStickerSetTitle", "setUserEmojiStatus", "setWebhook", "stopMessageLiveLocation", "stopPoll", "transferBusinessAccountStars", "transferGift", "unbanChatMember", "unbanChatSenderChat", "unhideGeneralForumTopic", "unpinAllChatMessages", "unpinAllForumTopicMessages", "unpinAllGeneralForumTopicMessages", "unpinChatMessage", "upgradeGift", "uploadStickerFile", "verifyChat", "verifyUser"];
4
- export type TelegramMethodName = typeof TELEGRAM_METHOD_NAMES[number];
5
- export type GeneratedMethodSpec = {
6
- params: Record<string, unknown>;
7
- result: unknown;
8
- };
9
- export type GeneratedTelegramMethodMap = {
10
- [K in TelegramMethodName]: GeneratedMethodSpec;
11
- };
12
- export declare const GENERATED_METHODS: Readonly<Record<"addStickerToSet" | "answerCallbackQuery" | "answerChatJoinRequestQuery" | "answerGuestQuery" | "answerInlineQuery" | "answerPreCheckoutQuery" | "answerShippingQuery" | "answerWebAppQuery" | "approveChatJoinRequest" | "approveSuggestedPost" | "banChatMember" | "banChatSenderChat" | "close" | "closeForumTopic" | "closeGeneralForumTopic" | "convertGiftToStars" | "copyMessage" | "copyMessages" | "createChatInviteLink" | "createChatSubscriptionInviteLink" | "createForumTopic" | "createInvoiceLink" | "createNewStickerSet" | "declineChatJoinRequest" | "declineSuggestedPost" | "deleteAllMessageReactions" | "deleteBusinessMessages" | "deleteChatPhoto" | "deleteChatStickerSet" | "deleteEphemeralMessage" | "deleteForumTopic" | "deleteMessage" | "deleteMessageReaction" | "deleteMessages" | "deleteMyCommands" | "deleteStickerFromSet" | "deleteStickerSet" | "deleteStory" | "deleteWebhook" | "editChatInviteLink" | "editChatSubscriptionInviteLink" | "editEphemeralMessageCaption" | "editEphemeralMessageMedia" | "editEphemeralMessageReplyMarkup" | "editEphemeralMessageText" | "editForumTopic" | "editGeneralForumTopic" | "editMessageCaption" | "editMessageChecklist" | "editMessageLiveLocation" | "editMessageMedia" | "editMessageReplyMarkup" | "editMessageText" | "editStory" | "editUserStarSubscription" | "exportChatInviteLink" | "forwardMessage" | "forwardMessages" | "getAvailableGifts" | "getBusinessAccountGifts" | "getBusinessAccountStarBalance" | "getBusinessConnection" | "getChat" | "getChatAdministrators" | "getChatGifts" | "getChatMember" | "getChatMemberCount" | "getChatMenuButton" | "getCustomEmojiStickers" | "getFile" | "getForumTopicIconStickers" | "getGameHighScores" | "getManagedBotAccessSettings" | "getManagedBotToken" | "getMe" | "getMyCommands" | "getMyDefaultAdministratorRights" | "getMyDescription" | "getMyName" | "getMyShortDescription" | "getMyStarBalance" | "getStarTransactions" | "getStickerSet" | "getUpdates" | "getUserChatBoosts" | "getUserGifts" | "getUserPersonalChatMessages" | "getUserProfileAudios" | "getUserProfilePhotos" | "getWebhookInfo" | "giftPremiumSubscription" | "hideGeneralForumTopic" | "leaveChat" | "logOut" | "pinChatMessage" | "postStory" | "promoteChatMember" | "readBusinessMessage" | "refundStarPayment" | "removeBusinessAccountProfilePhoto" | "removeChatVerification" | "removeMyProfilePhoto" | "removeUserVerification" | "reopenForumTopic" | "reopenGeneralForumTopic" | "replaceManagedBotToken" | "replaceStickerInSet" | "repostStory" | "restrictChatMember" | "revokeChatInviteLink" | "savePreparedInlineMessage" | "savePreparedKeyboardButton" | "sendAnimation" | "sendAudio" | "sendChatAction" | "sendChatJoinRequestWebApp" | "sendChecklist" | "sendContact" | "sendDice" | "sendDocument" | "sendGame" | "sendGift" | "sendInvoice" | "sendLivePhoto" | "sendLocation" | "sendMediaGroup" | "sendMessage" | "sendMessageDraft" | "sendPaidMedia" | "sendPhoto" | "sendPoll" | "sendRichMessage" | "sendRichMessageDraft" | "sendSticker" | "sendVenue" | "sendVideo" | "sendVideoNote" | "sendVoice" | "setBusinessAccountBio" | "setBusinessAccountGiftSettings" | "setBusinessAccountName" | "setBusinessAccountProfilePhoto" | "setBusinessAccountUsername" | "setChatAdministratorCustomTitle" | "setChatDescription" | "setChatMemberTag" | "setChatMenuButton" | "setChatPermissions" | "setChatPhoto" | "setChatStickerSet" | "setChatTitle" | "setCustomEmojiStickerSetThumbnail" | "setGameScore" | "setManagedBotAccessSettings" | "setMessageReaction" | "setMyCommands" | "setMyDefaultAdministratorRights" | "setMyDescription" | "setMyName" | "setMyProfilePhoto" | "setMyShortDescription" | "setPassportDataErrors" | "setStickerEmojiList" | "setStickerKeywords" | "setStickerMaskPosition" | "setStickerPositionInSet" | "setStickerSetThumbnail" | "setStickerSetTitle" | "setUserEmojiStatus" | "setWebhook" | "stopMessageLiveLocation" | "stopPoll" | "transferBusinessAccountStars" | "transferGift" | "unbanChatMember" | "unbanChatSenderChat" | "unhideGeneralForumTopic" | "unpinAllChatMessages" | "unpinAllForumTopicMessages" | "unpinAllGeneralForumTopicMessages" | "unpinChatMessage" | "upgradeGift" | "uploadStickerFile" | "verifyChat" | "verifyUser", "addStickerToSet" | "answerCallbackQuery" | "answerChatJoinRequestQuery" | "answerGuestQuery" | "answerInlineQuery" | "answerPreCheckoutQuery" | "answerShippingQuery" | "answerWebAppQuery" | "approveChatJoinRequest" | "approveSuggestedPost" | "banChatMember" | "banChatSenderChat" | "close" | "closeForumTopic" | "closeGeneralForumTopic" | "convertGiftToStars" | "copyMessage" | "copyMessages" | "createChatInviteLink" | "createChatSubscriptionInviteLink" | "createForumTopic" | "createInvoiceLink" | "createNewStickerSet" | "declineChatJoinRequest" | "declineSuggestedPost" | "deleteAllMessageReactions" | "deleteBusinessMessages" | "deleteChatPhoto" | "deleteChatStickerSet" | "deleteEphemeralMessage" | "deleteForumTopic" | "deleteMessage" | "deleteMessageReaction" | "deleteMessages" | "deleteMyCommands" | "deleteStickerFromSet" | "deleteStickerSet" | "deleteStory" | "deleteWebhook" | "editChatInviteLink" | "editChatSubscriptionInviteLink" | "editEphemeralMessageCaption" | "editEphemeralMessageMedia" | "editEphemeralMessageReplyMarkup" | "editEphemeralMessageText" | "editForumTopic" | "editGeneralForumTopic" | "editMessageCaption" | "editMessageChecklist" | "editMessageLiveLocation" | "editMessageMedia" | "editMessageReplyMarkup" | "editMessageText" | "editStory" | "editUserStarSubscription" | "exportChatInviteLink" | "forwardMessage" | "forwardMessages" | "getAvailableGifts" | "getBusinessAccountGifts" | "getBusinessAccountStarBalance" | "getBusinessConnection" | "getChat" | "getChatAdministrators" | "getChatGifts" | "getChatMember" | "getChatMemberCount" | "getChatMenuButton" | "getCustomEmojiStickers" | "getFile" | "getForumTopicIconStickers" | "getGameHighScores" | "getManagedBotAccessSettings" | "getManagedBotToken" | "getMe" | "getMyCommands" | "getMyDefaultAdministratorRights" | "getMyDescription" | "getMyName" | "getMyShortDescription" | "getMyStarBalance" | "getStarTransactions" | "getStickerSet" | "getUpdates" | "getUserChatBoosts" | "getUserGifts" | "getUserPersonalChatMessages" | "getUserProfileAudios" | "getUserProfilePhotos" | "getWebhookInfo" | "giftPremiumSubscription" | "hideGeneralForumTopic" | "leaveChat" | "logOut" | "pinChatMessage" | "postStory" | "promoteChatMember" | "readBusinessMessage" | "refundStarPayment" | "removeBusinessAccountProfilePhoto" | "removeChatVerification" | "removeMyProfilePhoto" | "removeUserVerification" | "reopenForumTopic" | "reopenGeneralForumTopic" | "replaceManagedBotToken" | "replaceStickerInSet" | "repostStory" | "restrictChatMember" | "revokeChatInviteLink" | "savePreparedInlineMessage" | "savePreparedKeyboardButton" | "sendAnimation" | "sendAudio" | "sendChatAction" | "sendChatJoinRequestWebApp" | "sendChecklist" | "sendContact" | "sendDice" | "sendDocument" | "sendGame" | "sendGift" | "sendInvoice" | "sendLivePhoto" | "sendLocation" | "sendMediaGroup" | "sendMessage" | "sendMessageDraft" | "sendPaidMedia" | "sendPhoto" | "sendPoll" | "sendRichMessage" | "sendRichMessageDraft" | "sendSticker" | "sendVenue" | "sendVideo" | "sendVideoNote" | "sendVoice" | "setBusinessAccountBio" | "setBusinessAccountGiftSettings" | "setBusinessAccountName" | "setBusinessAccountProfilePhoto" | "setBusinessAccountUsername" | "setChatAdministratorCustomTitle" | "setChatDescription" | "setChatMemberTag" | "setChatMenuButton" | "setChatPermissions" | "setChatPhoto" | "setChatStickerSet" | "setChatTitle" | "setCustomEmojiStickerSetThumbnail" | "setGameScore" | "setManagedBotAccessSettings" | "setMessageReaction" | "setMyCommands" | "setMyDefaultAdministratorRights" | "setMyDescription" | "setMyName" | "setMyProfilePhoto" | "setMyShortDescription" | "setPassportDataErrors" | "setStickerEmojiList" | "setStickerKeywords" | "setStickerMaskPosition" | "setStickerPositionInSet" | "setStickerSetThumbnail" | "setStickerSetTitle" | "setUserEmojiStatus" | "setWebhook" | "stopMessageLiveLocation" | "stopPoll" | "transferBusinessAccountStars" | "transferGift" | "unbanChatMember" | "unbanChatSenderChat" | "unhideGeneralForumTopic" | "unpinAllChatMessages" | "unpinAllForumTopicMessages" | "unpinAllGeneralForumTopicMessages" | "unpinChatMessage" | "upgradeGift" | "uploadStickerFile" | "verifyChat" | "verifyUser">>;
13
- //# sourceMappingURL=api.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../generated/api.ts"],"names":[],"mappings":"AACA,wFAAwF;AACxF,eAAO,MAAM,oBAAoB,EAAG,MAAe,CAAC;AACpD,eAAO,MAAM,qBAAqB,y7HA0LxB,CAAC;AACX,MAAM,MAAM,kBAAkB,GAAG,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACtE,MAAM,MAAM,mBAAmB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC;AACvF,MAAM,MAAM,0BAA0B,GAAG;KAAG,CAAC,IAAI,kBAAkB,GAAG,mBAAmB;CAAE,CAAC;AAC5F,eAAO,MAAM,iBAAiB,8tQAAyI,CAAC"}
@@ -1,192 +0,0 @@
1
- /* eslint-disable */
2
- /** Generated from the official Telegram Bot API documentation. Do not edit manually. */
3
- export const TELEGRAM_API_VERSION = "10.2";
4
- export const TELEGRAM_METHOD_NAMES = [
5
- "addStickerToSet",
6
- "answerCallbackQuery",
7
- "answerChatJoinRequestQuery",
8
- "answerGuestQuery",
9
- "answerInlineQuery",
10
- "answerPreCheckoutQuery",
11
- "answerShippingQuery",
12
- "answerWebAppQuery",
13
- "approveChatJoinRequest",
14
- "approveSuggestedPost",
15
- "banChatMember",
16
- "banChatSenderChat",
17
- "close",
18
- "closeForumTopic",
19
- "closeGeneralForumTopic",
20
- "convertGiftToStars",
21
- "copyMessage",
22
- "copyMessages",
23
- "createChatInviteLink",
24
- "createChatSubscriptionInviteLink",
25
- "createForumTopic",
26
- "createInvoiceLink",
27
- "createNewStickerSet",
28
- "declineChatJoinRequest",
29
- "declineSuggestedPost",
30
- "deleteAllMessageReactions",
31
- "deleteBusinessMessages",
32
- "deleteChatPhoto",
33
- "deleteChatStickerSet",
34
- "deleteEphemeralMessage",
35
- "deleteForumTopic",
36
- "deleteMessage",
37
- "deleteMessageReaction",
38
- "deleteMessages",
39
- "deleteMyCommands",
40
- "deleteStickerFromSet",
41
- "deleteStickerSet",
42
- "deleteStory",
43
- "deleteWebhook",
44
- "editChatInviteLink",
45
- "editChatSubscriptionInviteLink",
46
- "editEphemeralMessageCaption",
47
- "editEphemeralMessageMedia",
48
- "editEphemeralMessageReplyMarkup",
49
- "editEphemeralMessageText",
50
- "editForumTopic",
51
- "editGeneralForumTopic",
52
- "editMessageCaption",
53
- "editMessageChecklist",
54
- "editMessageLiveLocation",
55
- "editMessageMedia",
56
- "editMessageReplyMarkup",
57
- "editMessageText",
58
- "editStory",
59
- "editUserStarSubscription",
60
- "exportChatInviteLink",
61
- "forwardMessage",
62
- "forwardMessages",
63
- "getAvailableGifts",
64
- "getBusinessAccountGifts",
65
- "getBusinessAccountStarBalance",
66
- "getBusinessConnection",
67
- "getChat",
68
- "getChatAdministrators",
69
- "getChatGifts",
70
- "getChatMember",
71
- "getChatMemberCount",
72
- "getChatMenuButton",
73
- "getCustomEmojiStickers",
74
- "getFile",
75
- "getForumTopicIconStickers",
76
- "getGameHighScores",
77
- "getManagedBotAccessSettings",
78
- "getManagedBotToken",
79
- "getMe",
80
- "getMyCommands",
81
- "getMyDefaultAdministratorRights",
82
- "getMyDescription",
83
- "getMyName",
84
- "getMyShortDescription",
85
- "getMyStarBalance",
86
- "getStarTransactions",
87
- "getStickerSet",
88
- "getUpdates",
89
- "getUserChatBoosts",
90
- "getUserGifts",
91
- "getUserPersonalChatMessages",
92
- "getUserProfileAudios",
93
- "getUserProfilePhotos",
94
- "getWebhookInfo",
95
- "giftPremiumSubscription",
96
- "hideGeneralForumTopic",
97
- "leaveChat",
98
- "logOut",
99
- "pinChatMessage",
100
- "postStory",
101
- "promoteChatMember",
102
- "readBusinessMessage",
103
- "refundStarPayment",
104
- "removeBusinessAccountProfilePhoto",
105
- "removeChatVerification",
106
- "removeMyProfilePhoto",
107
- "removeUserVerification",
108
- "reopenForumTopic",
109
- "reopenGeneralForumTopic",
110
- "replaceManagedBotToken",
111
- "replaceStickerInSet",
112
- "repostStory",
113
- "restrictChatMember",
114
- "revokeChatInviteLink",
115
- "savePreparedInlineMessage",
116
- "savePreparedKeyboardButton",
117
- "sendAnimation",
118
- "sendAudio",
119
- "sendChatAction",
120
- "sendChatJoinRequestWebApp",
121
- "sendChecklist",
122
- "sendContact",
123
- "sendDice",
124
- "sendDocument",
125
- "sendGame",
126
- "sendGift",
127
- "sendInvoice",
128
- "sendLivePhoto",
129
- "sendLocation",
130
- "sendMediaGroup",
131
- "sendMessage",
132
- "sendMessageDraft",
133
- "sendPaidMedia",
134
- "sendPhoto",
135
- "sendPoll",
136
- "sendRichMessage",
137
- "sendRichMessageDraft",
138
- "sendSticker",
139
- "sendVenue",
140
- "sendVideo",
141
- "sendVideoNote",
142
- "sendVoice",
143
- "setBusinessAccountBio",
144
- "setBusinessAccountGiftSettings",
145
- "setBusinessAccountName",
146
- "setBusinessAccountProfilePhoto",
147
- "setBusinessAccountUsername",
148
- "setChatAdministratorCustomTitle",
149
- "setChatDescription",
150
- "setChatMemberTag",
151
- "setChatMenuButton",
152
- "setChatPermissions",
153
- "setChatPhoto",
154
- "setChatStickerSet",
155
- "setChatTitle",
156
- "setCustomEmojiStickerSetThumbnail",
157
- "setGameScore",
158
- "setManagedBotAccessSettings",
159
- "setMessageReaction",
160
- "setMyCommands",
161
- "setMyDefaultAdministratorRights",
162
- "setMyDescription",
163
- "setMyName",
164
- "setMyProfilePhoto",
165
- "setMyShortDescription",
166
- "setPassportDataErrors",
167
- "setStickerEmojiList",
168
- "setStickerKeywords",
169
- "setStickerMaskPosition",
170
- "setStickerPositionInSet",
171
- "setStickerSetThumbnail",
172
- "setStickerSetTitle",
173
- "setUserEmojiStatus",
174
- "setWebhook",
175
- "stopMessageLiveLocation",
176
- "stopPoll",
177
- "transferBusinessAccountStars",
178
- "transferGift",
179
- "unbanChatMember",
180
- "unbanChatSenderChat",
181
- "unhideGeneralForumTopic",
182
- "unpinAllChatMessages",
183
- "unpinAllForumTopicMessages",
184
- "unpinAllGeneralForumTopicMessages",
185
- "unpinChatMessage",
186
- "upgradeGift",
187
- "uploadStickerFile",
188
- "verifyChat",
189
- "verifyUser"
190
- ];
191
- export const GENERATED_METHODS = Object.freeze(Object.fromEntries(TELEGRAM_METHOD_NAMES.map((name) => [name, name])));
192
- //# sourceMappingURL=api.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../generated/api.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,wFAAwF;AACxF,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAe,CAAC;AACpD,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,iBAAiB;IACjB,qBAAqB;IACrB,4BAA4B;IAC5B,kBAAkB;IAClB,mBAAmB;IACnB,wBAAwB;IACxB,qBAAqB;IACrB,mBAAmB;IACnB,wBAAwB;IACxB,sBAAsB;IACtB,eAAe;IACf,mBAAmB;IACnB,OAAO;IACP,iBAAiB;IACjB,wBAAwB;IACxB,oBAAoB;IACpB,aAAa;IACb,cAAc;IACd,sBAAsB;IACtB,kCAAkC;IAClC,kBAAkB;IAClB,mBAAmB;IACnB,qBAAqB;IACrB,wBAAwB;IACxB,sBAAsB;IACtB,2BAA2B;IAC3B,wBAAwB;IACxB,iBAAiB;IACjB,sBAAsB;IACtB,wBAAwB;IACxB,kBAAkB;IAClB,eAAe;IACf,uBAAuB;IACvB,gBAAgB;IAChB,kBAAkB;IAClB,sBAAsB;IACtB,kBAAkB;IAClB,aAAa;IACb,eAAe;IACf,oBAAoB;IACpB,gCAAgC;IAChC,6BAA6B;IAC7B,2BAA2B;IAC3B,iCAAiC;IACjC,0BAA0B;IAC1B,gBAAgB;IAChB,uBAAuB;IACvB,oBAAoB;IACpB,sBAAsB;IACtB,yBAAyB;IACzB,kBAAkB;IAClB,wBAAwB;IACxB,iBAAiB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AClB,mBAAmB;IACnB,oBAAoB;IACpB,cAAc;IACd,mBAAmB;IACnB,cAAc;IACd,mCAAmC;IACnC,cAAc;IACd,6BAA6B;IAC7B,oBAAoB;IACpB,eAAe;IACf,iCAAiC;IACjC,kBAAkB;IAClB,WAAW;IACX,mBAAmB;IACnB,uBAAuB;IACvB,uBAAuB;IACvB,qBAAqB;IACrB,oBAAoB;IACpB,wBAAwB;IACxB,yBAAyB;IACzB,wBAAwB;IACxB,oBAAoB;IACpB,oBAAoB;IACpB,YAAY;IACZ,yBAAyB;IACzB,UAAU;IACV,8BAA8B;IAC9B,cAAc;IACd,iBAAiB;IACjB,qBAAqB;IACrB,yBAAyB;IACzB,sBAAsB;IACtB,4BAA4B;IAC5B,mCAAmC;IACnC,kBAAkB;IAClB,aAAa;IACb,mBAAmB;IACnB,YAAY;IACZ,YAAY;CACJ,CAAC;AAIX,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAmD,CAAC,CAAC"}
@@ -1,62 +0,0 @@
1
- import { type TelegramMethodName } from "../../generated/api.js";
2
- import type { ApiCallArgs, ApiParams, ApiResult, TelegramResponse } from "./types.js";
3
- import type { Transport } from "./transport.js";
4
- export interface ApiHookContext {
5
- method: string;
6
- payload: unknown;
7
- startedAt: number;
8
- durationMs?: number;
9
- response?: TelegramResponse<unknown>;
10
- error?: unknown;
11
- }
12
- export interface ApiClientOptions {
13
- transport: Transport;
14
- hooks?: {
15
- onRequest?: (context: ApiHookContext) => void | Promise<void>;
16
- onResponse?: (context: ApiHookContext) => void | Promise<void>;
17
- onError?: (context: ApiHookContext) => void | Promise<void>;
18
- };
19
- }
20
- export type ApiMethods = {
21
- [M in TelegramMethodName]: (...args: ApiCallArgs<M>) => Promise<ApiResult<M>>;
22
- };
23
- /** A Telegram file downloaded through `getFile` + the transport download endpoint. */
24
- export interface DownloadedFile {
25
- /** Telegram `File` object as returned by `getFile`. */
26
- file: import("./types.js").File;
27
- /** Raw file bytes. Telegram currently caps downloads at 20 MB. */
28
- bytes: Uint8Array;
29
- /** The `file_path` used for the download; guaranteed for at least one hour. */
30
- filePath: string;
31
- /** Direct download URL (`https://api.telegram.org/file/bot<token>/<file_path>`). */
32
- url: string;
33
- /** Last path segment of `filePath`, e.g. `report.pdf`. */
34
- fileName: string;
35
- /** Byte length of `bytes`. */
36
- sizeBytes: number;
37
- /** Set when the caller asked Bot.downloadFile to persist the bytes to disk. */
38
- savedTo?: string;
39
- }
40
- export declare class ApiClient {
41
- readonly methods: ApiMethods;
42
- private readonly transport;
43
- private readonly hooks;
44
- constructor(options: ApiClientOptions);
45
- call<M extends TelegramMethodName>(method: M, ...args: ApiCallArgs<M>): Promise<ApiResult<M>>;
46
- request<M extends TelegramMethodName>(method: M, payload?: ApiParams<M>, signal?: AbortSignal, options?: {
47
- timeoutMs?: number;
48
- }): Promise<ApiResult<M>>;
49
- raw(method: string, payload?: Record<string, unknown>, signal?: AbortSignal): Promise<unknown>;
50
- /** Direct download URL for a `file_path` returned by `getFile`; undefined when the transport cannot download files. */
51
- fileUrl(filePath: string): string | undefined;
52
- /**
53
- * Resolves a `file_id` through `getFile` and downloads the bytes behind the
54
- * returned `file_path`. Throws a `TelegramError` (kind `validation`) when
55
- * Telegram returns no `file_path`, and a `TelegramNetworkError` when the
56
- * download itself fails.
57
- */
58
- downloadFile(fileId: string, options?: {
59
- signal?: AbortSignal;
60
- }): Promise<DownloadedFile>;
61
- }
62
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGxF,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,E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AAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,SAAS;IACpB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAyC;gBACnD,OAAO,EAAE,gBAAgB;IAa/B,IAAI,CAAC,CAAC,SAAS,kBAAkB,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC7F,OAAO,CAAC,CAAC,SAAS,kBAAkB,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAiCvJ,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IASpG,uHAAuH;IACvH,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI7C;;;;;OAKG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GAAG,OAAO,CAAC,cAAc,CAAC;CAkBpG"}
@@ -1,104 +0,0 @@
1
- import { TELEGRAM_METHOD_NAMES } from "../../generated/api.js";
2
- import { claimWebhookReply } from "../core/webhook-reply.js";
3
- import { TelegramError, telegramErrorFromResponse } from "./errors.js";
4
- export class ApiClient {
5
- methods;
6
- transport;
7
- hooks;
8
- constructor(options) {
9
- this.transport = options.transport;
10
- this.hooks = options.hooks ?? {};
11
- const knownMethods = new Set(TELEGRAM_METHOD_NAMES);
12
- this.methods = new Proxy({}, {
13
- get: (_target, property) => {
14
- if (typeof property !== "string")
15
- return undefined;
16
- if (property === "then")
17
- return undefined;
18
- if (!knownMethods.has(property))
19
- throw new TypeError(`Unknown Telegram API method: ${property}`);
20
- return (payload) => this.request(property, payload);
21
- },
22
- });
23
- }
24
- async call(method, ...args) { return this.request(method, args[0]); }
25
- async request(method, payload, signal, options) {
26
- // Webhook reply mode: the first call while handling a webhook update is
27
- // answered through the webhook HTTP response instead of the transport.
28
- const webhookReply = claimWebhookReply(method, payload);
29
- if (webhookReply) {
30
- const context = { method, payload, startedAt: Date.now() };
31
- await this.hooks.onRequest?.(context);
32
- context.durationMs = Date.now() - context.startedAt;
33
- context.response = webhookReply.data;
34
- await this.hooks.onResponse?.(context);
35
- return webhookReply.data.result;
36
- }
37
- const context = { method, payload, startedAt: Date.now() };
38
- await this.hooks.onRequest?.(context);
39
- try {
40
- const request = { method };
41
- if (payload !== undefined)
42
- request.payload = payload;
43
- if (signal !== undefined)
44
- request.signal = signal;
45
- if (options?.timeoutMs !== undefined)
46
- request.timeoutMs = options.timeoutMs;
47
- const response = await this.transport.request(request);
48
- context.durationMs = Date.now() - context.startedAt;
49
- context.response = response.data;
50
- await this.hooks.onResponse?.(context);
51
- if (!response.data.ok || response.data.result === undefined)
52
- throw telegramErrorFromResponse(response.data, { method, payload, status: response.status });
53
- return response.data.result;
54
- }
55
- catch (error) {
56
- context.durationMs = Date.now() - context.startedAt;
57
- context.error = error;
58
- await this.hooks.onError?.(context);
59
- if (error instanceof TelegramError)
60
- throw error;
61
- throw error;
62
- }
63
- }
64
- async raw(method, payload, signal) {
65
- const request = { method };
66
- if (payload !== undefined)
67
- request.payload = payload;
68
- if (signal !== undefined)
69
- request.signal = signal;
70
- const response = await this.transport.request(request);
71
- if (!response.data.ok)
72
- throw telegramErrorFromResponse(response.data, { method, payload, status: response.status });
73
- return response.data.result;
74
- }
75
- /** Direct download URL for a `file_path` returned by `getFile`; undefined when the transport cannot download files. */
76
- fileUrl(filePath) {
77
- return this.transport.fileUrl?.(filePath);
78
- }
79
- /**
80
- * Resolves a `file_id` through `getFile` and downloads the bytes behind the
81
- * returned `file_path`. Throws a `TelegramError` (kind `validation`) when
82
- * Telegram returns no `file_path`, and a `TelegramNetworkError` when the
83
- * download itself fails.
84
- */
85
- async downloadFile(fileId, options = {}) {
86
- const file = await this.methods.getFile({ file_id: fileId });
87
- if (!file.file_path) {
88
- throw new TelegramError("Telegram returned no file_path for this file; request a fresh one with getFile", { method: "getFile", payload: { file_id: fileId }, kind: "validation" });
89
- }
90
- if (!this.transport.download || !this.transport.fileUrl) {
91
- throw new TelegramError("The configured transport does not support file downloads", { method: "getFile", payload: { file_id: fileId }, kind: "validation" });
92
- }
93
- const bytes = await this.transport.download(file.file_path, options.signal);
94
- return {
95
- file,
96
- bytes,
97
- filePath: file.file_path,
98
- url: this.transport.fileUrl(file.file_path),
99
- fileName: file.file_path.split("/").pop() ?? file.file_path,
100
- sizeBytes: bytes.byteLength,
101
- };
102
- }
103
- }
104
- //# sourceMappingURL=client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAA2B,MAAM,wBAAwB,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AA0BvE,MAAM,OAAO,SAAS;IACX,OAAO,CAAa;IACZ,SAAS,CAAY;IACrB,KAAK,CAAyC;IAC/D,YAAY,OAAyB;QACnC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC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IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,MAAM,IAAI,aAAa,CAAC,gFAAgF,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;QACrL,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;YACxD,MAAM,IAAI,aAAa,CAAC,0DAA0D,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;QAC/J,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAC5E,OAAO;YACL,IAAI;YACJ,KAAK;YACL,QAAQ,EAAE,IAAI,CAAC,SAAS;YACxB,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;YAC3C,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS;YAC3D,SAAS,EAAE,KAAK,CAAC,UAAU;SAC5B,CAAC;IACJ,CAAC;CACF"}
@@ -1,45 +0,0 @@
1
- import type { ResponseParameters, TelegramResponse } from "./types.js";
2
- export type TelegramErrorKind = "retryable" | "rate-limit" | "authentication" | "validation" | "network" | "server" | "unknown";
3
- export declare class TelegramError extends Error {
4
- readonly name: string;
5
- readonly kind: TelegramErrorKind;
6
- readonly errorCode: number | undefined;
7
- readonly parameters: ResponseParameters | undefined;
8
- readonly method: string;
9
- readonly payload: unknown;
10
- readonly status: number | undefined;
11
- constructor(message: string, options: {
12
- method: string;
13
- payload: unknown;
14
- errorCode?: number;
15
- parameters?: ResponseParameters;
16
- status?: number;
17
- kind?: TelegramErrorKind;
18
- cause?: unknown;
19
- });
20
- get retryAfter(): number | undefined;
21
- get migrateToChatId(): number | undefined;
22
- }
23
- export declare class TelegramRateLimitError extends TelegramError {
24
- readonly name: string;
25
- constructor(message: string, options: ConstructorParameters<typeof TelegramError>[1]);
26
- }
27
- export declare class TelegramAuthError extends TelegramError {
28
- readonly name: string;
29
- constructor(message: string, options: ConstructorParameters<typeof TelegramError>[1]);
30
- }
31
- export declare class TelegramValidationError extends TelegramError {
32
- readonly name: string;
33
- constructor(message: string, options: ConstructorParameters<typeof TelegramError>[1]);
34
- }
35
- export declare class TelegramNetworkError extends TelegramError {
36
- readonly name: string;
37
- constructor(message: string, options: ConstructorParameters<typeof TelegramError>[1]);
38
- }
39
- export declare function classifyTelegramError(errorCode?: number, status?: number): TelegramErrorKind;
40
- export declare function telegramErrorFromResponse<T>(response: TelegramResponse<T>, context: {
41
- method: string;
42
- payload: unknown;
43
- status?: number;
44
- }): TelegramError;
45
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/api/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEvE,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,YAAY,GAAG,gBAAgB,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEhI,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAkB,IAAI,EAAE,MAAM,CAAmB;IACjD,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACpD,QAAQ,CA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gB,qBAAqB,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAM5F;AAED,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAUzJ"}
@@ -1,65 +0,0 @@
1
- export class TelegramError extends Error {
2
- name = "TelegramError";
3
- kind;
4
- errorCode;
5
- parameters;
6
- method;
7
- payload;
8
- status;
9
- constructor(message, options) {
10
- super(message, { cause: options.cause });
11
- this.method = options.method;
12
- this.payload = options.payload;
13
- this.errorCode = options.errorCode;
14
- this.parameters = options.parameters;
15
- this.status = options.status;
16
- this.kind = options.kind ?? classifyTelegramError(options.errorCode, options.status);
17
- }
18
- get retryAfter() { return this.parameters?.retry_after; }
19
- get migrateToChatId() { return this.parameters?.migrate_to_chat_id; }
20
- }
21
- export class TelegramRateLimitError extends TelegramError {
22
- name = "TelegramRateLimitError";
23
- constructor(message, options) { super(message, { ...options, kind: "rate-limit" }); }
24
- }
25
- export class TelegramAuthError extends TelegramError {
26
- name = "TelegramAuthError";
27
- constructor(message, options) { super(message, { ...options, kind: "authentication" }); }
28
- }
29
- export class TelegramValidationError extends TelegramError {
30
- name = "TelegramValidationError";
31
- constructor(message, options) { super(message, { ...options, kind: "validation" }); }
32
- }
33
- export class TelegramNetworkError extends TelegramError {
34
- name = "TelegramNetworkError";
35
- constructor(message, options) { super(message, { ...options, kind: "network" }); }
36
- }
37
- export function classifyTelegramError(errorCode, status) {
38
- if (errorCode === 429)
39
- return "rate-limit";
40
- if (errorCode === 401 || status === 401 || status === 403)
41
- return "authentication";
42
- if (errorCode !== undefined && errorCode >= 400 && errorCode < 500)
43
- return "validation";
44
- if (status !== undefined && status >= 500)
45
- return "server";
46
- return "unknown";
47
- }
48
- export function telegramErrorFromResponse(response, context) {
49
- const message = response.description ?? `Telegram API request failed for ${context.method}`;
50
- const options = { method: context.method, payload: context.payload };
51
- if (response.error_code !== undefined)
52
- options.errorCode = response.error_code;
53
- if (response.parameters !== undefined)
54
- options.parameters = response.parameters;
55
- if (context.status !== undefined)
56
- options.status = context.status;
57
- if (response.error_code === 429)
58
- return new TelegramRateLimitError(message, options);
59
- if (response.error_code === 401 || context.status === 401 || context.status === 403)
60
- return new TelegramAuthError(message, options);
61
- if (response.error_code !== undefined && response.error_code >= 400 && response.error_code < 500)
62
- return new TelegramValidationError(message, options);
63
- return new TelegramError(message, options);
64
- }
65
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/api/errors.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,aAAc,SAAQ,KAAK;IACpB,IAAI,GAAW,eAAe,CAAC;IACxC,IAAI,CAAoB;IACxB,SAAS,CAAqB;IAC9B,UAAU,CAAiC;IAC3C,MAAM,CAAS;IACf,OAAO,CAAU;IACjB,MAAM,CAAqB;IAEpC,YAAY,OAAe,EAAE,OAA8J;QACzL,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,qBAAqB,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACvF,CAA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vJ,OAAO,IAAI,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC"}
@@ -1,6 +0,0 @@
1
- export * from "./client.js";
2
- export * from "./errors.js";
3
- export * from "./transport.js";
4
- export * from "./types.js";
5
- export * from "./telegram.js";
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
@@ -1,6 +0,0 @@
1
- export * from "./client.js";
2
- export * from "./errors.js";
3
- export * from "./transport.js";
4
- export * from "./types.js";
5
- export * from "./telegram.js";
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2021-2024 KnorpelSenf
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,22 +0,0 @@
1
- export interface ApiError {
2
- ok: false;
3
- error_code: number;
4
- description: string;
5
- parameters?: ResponseParameters;
6
- }
7
- export interface ApiSuccess<T> {
8
- ok: true;
9
- result: T;
10
- }
11
- /** The response contains an object, which always has a Boolean field 'ok' and may have an optional String field 'description' with a human-readable description of the result. If 'ok' equals True, the request was successful and the result of the query can be found in the 'result' field. In case of an unsuccessful request, 'ok' equals False and the error is explained in the 'description'. An Integer 'error_code' field is also returned, but its contents are subject to change in the future. Some errors may also have an optional field 'parameters' of the type ResponseParameters, which can help to automatically handle the error.
12
-
13
- - All methods in the Bot API are case-insensitive.
14
- - All queries must be made using UTF-8. */
15
- export type ApiResponse<T> = ApiError | ApiSuccess<T>;
16
- /** Describes why a request was unsuccessful. */
17
- export interface ResponseParameters {
18
- /** The group has been migrated to a supergroup with the specified identifier. */
19
- migrate_to_chat_id?: number;
20
- /** In case of exceeding flood control, the number of seconds left to wait before the request can be repeated */
21
- retry_after?: number;
22
- }