@xbibzlibrary/telebibz 0.4.4 → 3.0.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 (258) hide show
  1. package/CHANGELOG.md +35 -138
  2. package/LICENSE +1 -1
  3. package/NOTICE.md +9 -4
  4. package/README.md +173 -242
  5. package/examples/01-quickstart.js +13 -0
  6. package/examples/02-menu-tombol.js +22 -0
  7. package/examples/03-wizard.js +29 -0
  8. package/examples/04-broadcast.js +25 -0
  9. package/examples/05-kirim-file.js +19 -0
  10. package/examples/06-menu.js +35 -0
  11. package/examples/07-inline-query.js +18 -0
  12. package/index.d.ts +81 -0
  13. package/index.js +42 -0
  14. package/lib/api.js +154 -0
  15. package/lib/broadcast.js +35 -0
  16. package/lib/composer.js +174 -0
  17. package/lib/context.js +190 -0
  18. package/lib/errors.js +35 -0
  19. package/lib/file.js +41 -0
  20. package/lib/inline-query.js +28 -0
  21. package/lib/keyboard.js +83 -0
  22. package/lib/logger.js +38 -0
  23. package/lib/menus.js +90 -0
  24. package/lib/net.js +115 -0
  25. package/lib/ratelimit.js +61 -0
  26. package/lib/runner.js +45 -0
  27. package/lib/session.js +36 -0
  28. package/lib/telebibz.js +190 -0
  29. package/lib/wizard.js +81 -0
  30. package/package.json +35 -97
  31. package/test/all.test.js +334 -0
  32. package/CODE_OF_CONDUCT.md +0 -37
  33. package/CONTRIBUTING.md +0 -59
  34. package/CONTRIBUTION_RULES.md +0 -41
  35. package/GOVERNANCE.md +0 -47
  36. package/README.id.md +0 -292
  37. package/README.zh-CN.md +0 -292
  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/GETTING_STARTED.id.md +0 -85
  244. package/docs/GETTING_STARTED.md +0 -85
  245. package/docs/GETTING_STARTED.zh-CN.md +0 -85
  246. package/docs/GITHUB_PACKAGES.id.md +0 -82
  247. package/docs/GITHUB_PACKAGES.md +0 -82
  248. package/docs/GITHUB_PACKAGES.zh-CN.md +0 -82
  249. package/docs/README.md +0 -48
  250. package/docs/STORAGE.id.md +0 -105
  251. package/docs/STORAGE.md +0 -105
  252. package/docs/STORAGE.zh-CN.md +0 -105
  253. package/examples/README.md +0 -37
  254. package/examples/files.ts +0 -35
  255. package/examples/minimal.ts +0 -12
  256. package/examples/tsconfig.json +0 -9
  257. package/examples/webhook.ts +0 -42
  258. package/examples/wizard-registration.ts +0 -42
@@ -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;QACjC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAS,qBAAqB,CAAC,CAAC;QAC5D,IAAI,CAAC,OAAO,GAAG,IAAI,KAAK,CAAC,EAAE,EAAE;YAC3B,GAAG,EAAE,CAAC,OAAO,EAAE,QAAyB,EAAE,EAAE;gBAC1C,IAAI,OAAO,QAAQ,KAAK,QAAQ;oBAAE,OAAO,SAAS,CAAC;gBACnD,IAAI,QAAQ,KAAK,MAAM;oBAAE,OAAO,SAAS,CAAC;gBAC1C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC;oBAAE,MAAM,IAAI,SAAS,CAAC,gCAAgC,QAAQ,EAAE,CAAC,CAAC;gBACjG,OAAO,CAAC,OAAiB,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAA8B,EAAE,OAAgB,CAAC,CAAC;YAC/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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,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,kBAAkB,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,iBAAiB,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;IAU3L,IAAI,UAAU,IAAI,MAAM,GAAG,SAAS,CAAyC;IAC7E,IAAI,eAAe,IAAI,MAAM,GAAG,SAAS,CAAgD;CAC1F;AAED,qBAAa,sBAAuB,SAAQ,aAAa;IACvD,SAAkB,IAAI,EAAE,MAAM,CAA4B;gBAC9C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC;CACrF;AACD,qBAAa,iBAAkB,SAAQ,aAAa;IAClD,SAAkB,IAAI,EAAE,MAAM,CAAuB;gBACzC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC;CACrF;AACD,qBAAa,uBAAwB,SAAQ,aAAa;IACxD,SAAkB,IAAI,EAAE,MAAM,CAA6B;gBAC/C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC;CACrF;AACD,qBAAa,oBAAqB,SAAQ,aAAa;IACrD,SAAkB,IAAI,EAAE,MAAM,CAA0B;gBAC5C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC;CACrF;AAED,wBAAgB,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,M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AS,GAAG,QAAQ,CAAC,UAAU,CAAC;IAC/E,IAAI,QAAQ,CAAC,UAAU,KAAK,SAAS;QAAE,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;IAChF,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAClE,IAAI,QAAQ,CAAC,UAAU,KAAK,GAAG;QAAE,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACrF,IAAI,QAAQ,CAAC,UAAU,KAAK,GAAG,IAAI,OAAO,CAAC,MAAM,KAAK,GAAG,IAAI,OAAO,CAAC,MAAM,KAAK,GAAG;QAAE,OAAO,IAAI,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACpI,IAAI,QAAQ,CAAC,UAAU,KAAK,SAAS,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,IAAI,QAAQ,CAAC,UAAU,GAAG,GAAG;QAAE,OAAO,IAAI,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACvJ,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
- }
@@ -1,72 +0,0 @@
1
- import type { Chat, User } from "./manage.js";
2
- import type { Message, MessageEntity, ParseMode } from "./message.js";
3
- /** Describes a task in a checklist. */
4
- export interface ChecklistTask {
5
- /** Unique identifier of the task */
6
- id: number;
7
- /** Text of the task */
8
- text: string;
9
- /** Special entities that appear in the task text */
10
- text_entities?: MessageEntity[];
11
- /** User that completed the task; omitted if the task wasn't completed by a user */
12
- completed_by_user?: User;
13
- /** Chat that completed the task; omitted if the task wasn't completed by a chat */
14
- completed_by_chat?: Chat;
15
- /** Point in time (Unix timestamp) when the task was completed; 0 if the task wasn't completed */
16
- completion_date?: number;
17
- }
18
- /** Describes a checklist. */
19
- export interface Checklist {
20
- /** Title of the checklist */
21
- title: string;
22
- /** Special entities that appear in the checklist title */
23
- title_entities?: MessageEntity[];
24
- /** List of tasks in the checklist */
25
- tasks: ChecklistTask[];
26
- /** True, if users other than the creator of the list can add tasks to the list */
27
- others_can_add_tasks?: true;
28
- /** True, if users other than the creator of the list can mark tasks as done or not done */
29
- others_can_mark_tasks_as_done?: true;
30
- }
31
- /** Describes a task to add to a checklist. */
32
- export interface InputChecklistTask {
33
- /** Unique identifier of the task; must be positive and unique among all task identifiers currently present in the checklist */
34
- id: number;
35
- /** Text of the task; 1-100 characters after entities parsing */
36
- text: string;
37
- /** Mode for parsing entities in the text. See formatting options for more details. */
38
- parse_mode?: ParseMode;
39
- /** List of special entities that appear in the text, which can be specified instead of parse_mode. Currently, only bold, italic, underline, strikethrough, spoiler, custom_emoji, and date_time entities are allowed. */
40
- text_entities?: MessageEntity[];
41
- }
42
- /** Describes a checklist to create. */
43
- export interface InputChecklist {
44
- /** Title of the checklist; 1-255 characters after entities parsing */
45
- title: string;
46
- /** Mode for parsing entities in the title. See formatting options for more details. */
47
- parse_mode?: ParseMode;
48
- /** List of special entities that appear in the title, which can be specified instead of parse_mode. Currently, only bold, italic, underline, strikethrough, spoiler, custom_emoji, and date_time entities are allowed. */
49
- title_entities?: MessageEntity[];
50
- /** List of 1-30 tasks in the checklist */
51
- tasks: InputChecklistTask[];
52
- /** Pass True if other users can add tasks to the checklist */
53
- others_can_add_tasks?: boolean;
54
- /** Pass True if other users can mark tasks as done or not done in the checklist */
55
- others_can_mark_tasks_as_done?: true;
56
- }
57
- /** Describes a service message about checklist tasks marked as done or not done. */
58
- export interface ChecklistTasksDone {
59
- /** Message containing the checklist whose tasks were marked as done or not done. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply. */
60
- checklist_message?: Message;
61
- /** Identifiers of the tasks that were marked as done */
62
- marked_as_done_task_ids?: number[];
63
- /** Identifiers of the tasks that were marked as not done */
64
- marked_as_not_done_task_ids?: number[];
65
- }
66
- /** Describes a service message about tasks added to a checklist. */
67
- export interface ChecklistTasksAdded {
68
- /** Message containing the checklist to which the tasks were added. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply. */
69
- checklist_message?: Message;
70
- /** List of tasks added to the checklist */
71
- tasks: ChecklistTask[];
72
- }