@xbibzlibrary/telebibz 0.1.18 → 0.2.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.
- package/CHANGELOG.md +28 -8
- package/CONTRIBUTING.md +8 -3
- package/README.id.md +50 -10
- package/README.md +50 -12
- package/README.zh-CN.md +50 -10
- package/RELEASE_AUTOMATION.md +17 -5
- package/SHOWCASE.md +29 -0
- package/bin/telebibz.mjs +1 -1
- package/dist/src/api/client.d.ts +3 -1
- package/dist/src/api/client.d.ts.map +1 -1
- package/dist/src/api/client.js +3 -1
- package/dist/src/api/client.js.map +1 -1
- package/dist/src/api/transport.d.ts +3 -1
- package/dist/src/api/transport.d.ts.map +1 -1
- package/dist/src/api/transport.js +3 -2
- package/dist/src/api/transport.js.map +1 -1
- package/dist/src/branding/terminal.d.ts +62 -0
- package/dist/src/branding/terminal.d.ts.map +1 -1
- package/dist/src/branding/terminal.js +258 -0
- package/dist/src/branding/terminal.js.map +1 -1
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +7 -3
- package/dist/src/cli.js.map +1 -1
- package/dist/src/context/context.d.ts +24 -1
- package/dist/src/context/context.d.ts.map +1 -1
- package/dist/src/context/context.js +102 -8
- package/dist/src/context/context.js.map +1 -1
- package/dist/src/core/bot.d.ts +18 -1
- package/dist/src/core/bot.d.ts.map +1 -1
- package/dist/src/core/bot.js +106 -23
- package/dist/src/core/bot.js.map +1 -1
- package/dist/src/keyboard/index.d.ts +12 -0
- package/dist/src/keyboard/index.d.ts.map +1 -1
- package/dist/src/keyboard/index.js +13 -1
- package/dist/src/keyboard/index.js.map +1 -1
- package/dist/src/observability/logger.d.ts +28 -1
- package/dist/src/observability/logger.d.ts.map +1 -1
- package/dist/src/observability/logger.js +110 -0
- package/dist/src/observability/logger.js.map +1 -1
- package/dist/src/plugins/plugin.d.ts +2 -0
- package/dist/src/plugins/plugin.d.ts.map +1 -1
- package/dist/src/plugins/plugin.js +11 -4
- package/dist/src/plugins/plugin.js.map +1 -1
- package/dist/src/router/router.d.ts +19 -0
- package/dist/src/router/router.d.ts.map +1 -1
- package/dist/src/router/router.js +125 -23
- package/dist/src/router/router.js.map +1 -1
- package/dist/src/state/forms.d.ts +0 -1
- package/dist/src/state/forms.d.ts.map +1 -1
- package/dist/src/state/forms.js +27 -24
- package/dist/src/state/forms.js.map +1 -1
- package/dist/src/storage/storage.d.ts +10 -0
- package/dist/src/storage/storage.d.ts.map +1 -1
- package/dist/src/storage/storage.js +20 -2
- package/dist/src/storage/storage.js.map +1 -1
- package/dist/src/utils/text.d.ts +22 -0
- package/dist/src/utils/text.d.ts.map +1 -1
- package/dist/src/utils/text.js +0 -0
- package/dist/src/utils/text.js.map +1 -1
- package/dist/src/webhook/handler.d.ts +3 -0
- package/dist/src/webhook/handler.d.ts.map +1 -1
- package/dist/src/webhook/handler.js +85 -0
- package/dist/src/webhook/handler.js.map +1 -1
- package/dist-cjs/src/api/client.js +3 -1
- package/dist-cjs/src/api/transport.js +3 -2
- package/dist-cjs/src/branding/terminal.js +264 -1
- package/dist-cjs/src/cli.js +7 -3
- package/dist-cjs/src/context/context.js +102 -8
- package/dist-cjs/src/core/bot.js +104 -21
- package/dist-cjs/src/keyboard/index.js +13 -1
- package/dist-cjs/src/observability/logger.js +113 -1
- package/dist-cjs/src/plugins/plugin.js +11 -4
- package/dist-cjs/src/router/router.js +126 -24
- package/dist-cjs/src/state/forms.js +27 -24
- package/dist-cjs/src/storage/storage.js +20 -2
- package/dist-cjs/src/utils/text.js +0 -0
- package/dist-cjs/src/webhook/handler.js +86 -0
- package/docs/API.id.md +57 -3
- package/docs/API.md +59 -3
- package/docs/API.zh-CN.md +56 -2
- package/docs/GETTING_STARTED.id.md +85 -0
- package/docs/GETTING_STARTED.md +85 -0
- package/docs/GETTING_STARTED.zh-CN.md +85 -0
- package/docs/README.md +12 -4
- package/examples/README.md +37 -0
- package/examples/minimal.ts +12 -0
- package/examples/tsconfig.json +9 -0
- package/examples/webhook.ts +42 -0
- package/examples/wizard-registration.ts +42 -0
- package/package.json +22 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,20 +1,40 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.2.0 — 2026-08-29
|
|
4
|
+
|
|
5
|
+
### Breaking
|
|
6
|
+
|
|
7
|
+
- Node.js 22 is now the minimum supported runtime (`engines.node: ">=22"`); CI tests Node 22 and 24. The TypeScript target moves to ES2023.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `bot.on(filter, handler)` update-type filters with payload narrowing: `bot.on("message:photo")`, `bot.on("callback_query:data")`, or an array like `["message:text", "callback_query:data"]`. Invalid filters throw at registration time.
|
|
12
|
+
- `bot.hears(trigger, handler)` for exact text or `RegExp` message matching.
|
|
13
|
+
- `bot.catch(handler)` error boundary: handler failures are logged, emitted as `update:error`/`bot:error`, and routed to the handler instead of rejecting `handleUpdate()`; webhooks answer `200` and polling continues.
|
|
14
|
+
- Extended context senders with automatic quote-reply: `replyWithAnimation`, `replyWithVideoNote`, `replyWithSticker`, `replyWithMediaGroup`, `replyWithLocation`, `replyWithVenue`, `replyWithContact`, `replyWithPoll`, and `replyWithDice`.
|
|
15
|
+
- Animated terminal startup experience (on by default, `branding: false` to disable): typing effect for `Installing Dependencies......`, a glass progress bar with a sweeping highlight, and the animated rainbow ASCII banner `Tele Bibz` (figlet `Speed` font) that flows until the bot connects and then freezes with `✓ Connected as @<username>`.
|
|
16
|
+
- Human-readable incoming update logs: `[ => ] Message From {id} {nickname} {dd/mm/yyyy} {hh:mm:ss}` plus an indented content line. Regular message/command text is truncated to 50 characters; callback button data is shown in full. Errors print in red with the full stack. Non-interactive stdout falls back to plain output; `logger.format: "json"` emits structured `update.received` entries instead.
|
|
17
|
+
- Branding helpers exported for applications: `runStartupSequence()`, `startTeleBibzBanner()`, `printTeleBibzBanner()`, `paintRainbow()`, `printStatusLine()`, plus `Logger.incoming()` and `describeIncomingUpdate()`.
|
|
18
|
+
- `TransportRequest.timeoutMs` for per-request timeouts, honored by `FetchTransport` and `ApiClient.request()`.
|
|
19
|
+
- Storage-backed conversations, full five-field cron parsing, scheduler error hooks, permission-aware menus, `MenuController`, Web App init-data validation, PaymentsClient, and vendored Telegram declarations.
|
|
4
20
|
|
|
5
21
|
### Fixed
|
|
6
22
|
|
|
7
|
-
-
|
|
23
|
+
- Restored a green build: `npm run typecheck`, `lint`, `test:types`, `test:examples`, and `build` failed under TypeScript 5.9 with `exactOptionalPropertyTypes` (`Context.me` assignment, `RoutableContext.me` index-signature constraint, and an invalid `webhookCallback` cast).
|
|
24
|
+
- The published `telebibz` CLI binary crashed with `MODULE_NOT_FOUND` because `bin/telebibz.mjs` imported `../dist/cli.js`; the build emits `dist/src/cli.js`. `release:check` now verifies every bin import resolves inside the tarball.
|
|
25
|
+
- Long polling no longer races its own transport timeout: `getUpdates` now uses a per-request timeout of the polling timeout plus a 10-second buffer instead of the flat 30s transport default, which aborted healthy connections the moment Telegram responded.
|
|
26
|
+
- `bot.stop()` now aborts the in-flight long-poll request (the polling `AbortSignal` is passed through to the transport), so shutdown no longer blocks for up to the full polling timeout.
|
|
27
|
+
- `JsonFileStorage` now persists `expiresAt` metadata, so values written with a TTL no longer silently become permanent after a restart.
|
|
28
|
+
- `webhookCallback` now actually supports Koa-style contexts (`status`/`body`), reads secret-token headers from fetch `Request` header maps, and parses bodies from web-standard `Request` objects instead of misreading their `ReadableStream` `body` as a pre-parsed update.
|
|
29
|
+
- Passing `reply_parameters` in `extra` no longer discards the automatic quote `message_id`; user options now merge with it across all `reply`/`replyWith*` senders.
|
|
30
|
+
- Plugins install exactly once; `bot.restart()` no longer double-registers plugin middleware and routes.
|
|
31
|
+
- Callback-query contexts resolve `message` and `chat` from `callback_query.message`, so `ctx.reply()`, `ctx.edit()`, and `ctx.delete()` work for button callbacks.
|
|
8
32
|
- Router matching is first-match by default; explicit `matchMode: "all"` preserves deliberate fan-out without accidental double replies.
|
|
9
33
|
- Polling isolates handler failures per update, continues the remainder of a batch, emits `update:error`, and uses abortable reconnect backoff.
|
|
10
|
-
- Regex matchers reset `lastIndex` before reuse.
|
|
11
34
|
|
|
12
|
-
###
|
|
35
|
+
### Removed
|
|
13
36
|
|
|
14
|
-
-
|
|
15
|
-
- Storage-backed conversations, full five-field cron parsing, scheduler error hooks, permission-aware menus, `MenuController`, Web App init-data validation, PaymentsClient, and vendored Telegram declarations.
|
|
16
|
-
- Callback-update test fixtures and expanded failure-path/regression coverage.
|
|
17
|
-
- Code of Conduct, Contributing Guide, Contribution Rules, Governance, Support Policy, expanded Security Policy, third-party Notice, CODEOWNERS, Dependabot configuration, and complete GitHub issue/PR templates.
|
|
37
|
+
- Development report files (`TELEBIBZ_FINAL_REPORT.md`, `TELEBIBZ_E2E_REPORT.md`, `NPM_RELEASE_REPORT.md`) and the feature-matrix row for an approval gate that was never part of the source tree.
|
|
18
38
|
|
|
19
39
|
## 0.1.2 — 2026-08-19
|
|
20
40
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -10,12 +10,13 @@ Check existing issues and pull requests before opening a new one. For a defect,
|
|
|
10
10
|
|
|
11
11
|
## Local setup
|
|
12
12
|
|
|
13
|
-
The project requires Node.js `>=
|
|
13
|
+
The project requires Node.js `>=22` and uses npm for release-compatible commands. Install dependencies and run the baseline checks:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
npm ci
|
|
17
17
|
npm run typecheck
|
|
18
18
|
npm run test:types
|
|
19
|
+
npm run test:examples
|
|
19
20
|
npm run lint
|
|
20
21
|
npm test
|
|
21
22
|
npm run build
|
|
@@ -31,9 +32,9 @@ Create a focused branch from `main`. Keep unrelated refactors out of a feature o
|
|
|
31
32
|
|
|
32
33
|
## Implementation expectations
|
|
33
34
|
|
|
34
|
-
Public behavior must be implemented in TypeScript with strict typing. Do not add fake responses, silent stubs, undocumented breaking behavior, or untested branches. Preserve ESM and CommonJS builds, zero runtime vendor dependencies in the core package, Node.js `>=
|
|
35
|
+
Public behavior must be implemented in TypeScript with strict typing. Do not add fake responses, silent stubs, undocumented breaking behavior, or untested branches. Preserve ESM and CommonJS builds, zero runtime vendor dependencies in the core package, Node.js `>=22` compatibility, and the existing package export map.
|
|
35
36
|
|
|
36
|
-
Changes to routing, context, lifecycle, transport, storage, queue, scheduler, approval, generated API declarations, or release automation require regression tests. Changes to a public function, class, method, option, error, event, or generated method require a corresponding API documentation update. Changes that affect package contents must pass `release:check` and `npm pack --dry-run`.
|
|
37
|
+
Changes to routing, context, lifecycle, transport, storage, queue, scheduler, approval, generated API declarations, or release automation require regression tests. Changes to a public function, class, method, option, error, event, or generated method require a corresponding API documentation update. Changes to examples require `npm run test:examples` and must use placeholders instead of credentials. Changes that affect package contents must pass `release:check` and `npm pack --dry-run`.
|
|
37
38
|
|
|
38
39
|
## Pull request process
|
|
39
40
|
|
|
@@ -49,6 +50,10 @@ English is the default README language. Keep `README.id.md`, `README.zh-CN.md`,
|
|
|
49
50
|
|
|
50
51
|
Normal pushes to `main` can trigger the protected auto-publish workflow. The workflow runs quality gates, computes an unused patch version, publishes the package, commits the version, creates a tag, and creates a GitHub Release. See [RELEASE_AUTOMATION.md](RELEASE_AUTOMATION.md) for the required `NPM_TOKEN` secret and private-source provenance constraint. Contributors must not publish directly to npm unless explicitly authorized by the maintainers.
|
|
51
52
|
|
|
53
|
+
## Showcase submissions
|
|
54
|
+
|
|
55
|
+
Public projects using Telebibz may be submitted through a pull request to [SHOWCASE.md](SHOWCASE.md). Include only public links and a short description. Never include bot tokens, private endpoints, personal data, or confidential source code.
|
|
56
|
+
|
|
52
57
|
## Questions
|
|
53
58
|
|
|
54
59
|
Use the question/support template for usage questions and consult the [English API reference](docs/API.md) first. Keep support requests free of credentials and private user data.
|
package/README.id.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
+
[](https://github.com/XbibzOfficial777/telebibz/actions/workflows/ci.yml)
|
|
6
|
+
[](https://www.npmjs.com/package/@xbibzlibrary/telebibz)
|
|
7
|
+
[](https://www.npmjs.com/package/@xbibzlibrary/telebibz)
|
|
8
|
+
[](https://www.npmjs.com/package/@xbibzlibrary/telebibz)
|
|
9
|
+
|
|
5
10
|
**`@xbibzlibrary/telebibz`** adalah SDK dan framework Telegram Bot untuk Node.js dan TypeScript. Paket ini menyediakan API client, polling, router, middleware, context, keyboard builder, state/session, webhook handler, queue, scheduler, cache, plugin lifecycle, CLI, dan utilitas pengujian.
|
|
6
11
|
|
|
7
12
|
[English](README.md) · **Bahasa Indonesia** · [简体中文](README.zh-CN.md)
|
|
@@ -10,6 +15,10 @@ Referensi API lengkap: [English](docs/API.md) · **Indonesia** · [中文](docs/
|
|
|
10
15
|
|
|
11
16
|
Panduan GitHub Packages: [English](docs/GITHUB_PACKAGES.md) · [Bahasa Indonesia](docs/GITHUB_PACKAGES.id.md) · [简体中文](docs/GITHUB_PACKAGES.zh-CN.md)
|
|
12
17
|
|
|
18
|
+
Panduan mulai: [English](docs/GETTING_STARTED.md) · [Bahasa Indonesia](docs/GETTING_STARTED.id.md) · [简体中文](docs/GETTING_STARTED.zh-CN.md)
|
|
19
|
+
|
|
20
|
+
Showcase komunitas: [SHOWCASE.md](SHOWCASE.md)
|
|
21
|
+
|
|
13
22
|

|
|
14
23
|
|
|
15
24
|
## Instalasi
|
|
@@ -18,7 +27,7 @@ Panduan GitHub Packages: [English](docs/GITHUB_PACKAGES.md) · [Bahasa Indonesia
|
|
|
18
27
|
npm install @xbibzlibrary/telebibz
|
|
19
28
|
```
|
|
20
29
|
|
|
21
|
-
Node.js **
|
|
30
|
+
Node.js **22 atau lebih baru** diperlukan.
|
|
22
31
|
|
|
23
32
|
## Bot sederhana
|
|
24
33
|
|
|
@@ -27,14 +36,25 @@ import { Bot } from "@xbibzlibrary/telebibz";
|
|
|
27
36
|
|
|
28
37
|
const bot = new Bot(process.env.TELEGRAM_BOT_TOKEN!);
|
|
29
38
|
|
|
30
|
-
bot.command("start", (ctx) => ctx.reply("Bot aktif."));
|
|
31
|
-
bot.onText("ping", (ctx) => ctx.reply("pong"));
|
|
39
|
+
bot.command("start", async (ctx) => { await ctx.reply("Bot aktif."); });
|
|
40
|
+
bot.onText("ping", async (ctx) => { await ctx.reply("pong"); });
|
|
32
41
|
|
|
33
42
|
await bot.start();
|
|
34
43
|
```
|
|
35
44
|
|
|
36
45
|
`Bot.start()` menjalankan long polling. Untuk siklus hidup manual, gunakan `init()`, `launch({ mode: "polling" })`, `health()`, `stop()`, atau `restart()`.
|
|
37
46
|
|
|
47
|
+
## Starter resmi
|
|
48
|
+
|
|
49
|
+
Repository menyediakan starter yang bisa langsung dijalankan untuk bot minimal, registration wizard multi-langkah, dan webhook Node.js. Lihat [`examples/README.md`](examples/README.md), atau jalankan starter minimal setelah mengatur `TELEGRAM_BOT_TOKEN`:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
export TELEGRAM_BOT_TOKEN="<token-bot-kamu>"
|
|
53
|
+
npx tsx examples/minimal.ts
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Semua examples di-typecheck oleh CI melalui `npm run test:examples` dan tidak berisi credential asli.
|
|
57
|
+
|
|
38
58
|
## Router dan middleware
|
|
39
59
|
|
|
40
60
|
```ts
|
|
@@ -44,12 +64,16 @@ bot.use(async (ctx, next) => {
|
|
|
44
64
|
console.log(`processed in ${Date.now() - started}ms`);
|
|
45
65
|
});
|
|
46
66
|
|
|
47
|
-
bot.command("help", (ctx) => ctx.reply("Bantuan tersedia."));
|
|
48
|
-
bot.onRegex(/^order:(\\d+)$/, (ctx) => ctx.reply("Order diterima."));
|
|
49
|
-
bot.callback("profile:*", (ctx) => ctx.answerCallbackQuery("Dibuka."));
|
|
67
|
+
bot.command("help", async (ctx) => { await ctx.reply("Bantuan tersedia."); });
|
|
68
|
+
bot.onRegex(/^order:(\\d+)$/, async (ctx) => { await ctx.reply("Order diterima."); });
|
|
69
|
+
bot.callback("profile:*", async (ctx) => { await ctx.answerCallbackQuery("Dibuka."); });
|
|
70
|
+
bot.on("message:photo", async (ctx) => { await ctx.reply("Foto yang bagus."); });
|
|
71
|
+
bot.on(["message:text", "callback_query:data"], async (ctx) => { await ctx.reply("Diterima."); });
|
|
72
|
+
bot.hears("ping", async (ctx) => { await ctx.reply("pong"); });
|
|
73
|
+
bot.catch(async (error, ctx) => { await ctx.reply("Terjadi kesalahan."); });
|
|
50
74
|
```
|
|
51
75
|
|
|
52
|
-
Router mendukung command, text, regex, pola callback, predikat kustom, router bersarang, middleware per rute, dan prioritas rute.
|
|
76
|
+
Router mendukung command, text, regex, pola callback, filter tipe update (`on`), predikat kustom, router bersarang, middleware per rute, dan prioritas rute. `bot.catch()` mendaftarkan error boundary: kegagalan handler diarahkan ke sana alih-alih menolak update.
|
|
53
77
|
|
|
54
78
|
## Telegram API
|
|
55
79
|
|
|
@@ -83,7 +107,7 @@ Builder hanya menghasilkan payload keyboard native Telegram. UI HTML/CSS memerlu
|
|
|
83
107
|
|
|
84
108
|
## Startup dan log terminal
|
|
85
109
|
|
|
86
|
-
|
|
110
|
+
Logger mengeluarkan baris terminal yang ringkas dan mudah dibaca dengan level berwarna serta konteks terstruktur. Level log: `silent`, `error`, `warn`, `info`, `debug`, dan `trace`; nilai sensitif di-redact; error dicetak merah lengkap dengan stack. Gunakan `format: "json"` untuk log terstruktur, dan `includeUpdateContent: true` hanya bila teks pesan atau data callback memang diperlukan.
|
|
87
111
|
|
|
88
112
|
## Webhook
|
|
89
113
|
|
|
@@ -102,9 +126,24 @@ const handler = createWebhookHandler(bot, {
|
|
|
102
126
|
|
|
103
127
|
Paket menyediakan `MemoryStorage` dengan TTL dan pembaruan atomik, `JsonFileStorage`, `RedisStorage`, `SqlStorage`, `MongoStorage`, persistent application state storage, session bot, conversation dan form berbasis Storage, menu berbasis permission, pagination `MenuController`, `MemoryCache`, token-bucket limiter, task queue dengan retry/backoff/concurrency/delay/cancel, serta scheduler interval, one-shot, dan cron lima field lengkap. Adapter Redis, SQL, dan Mongo memakai driver kecil sehingga core package tetap tanpa runtime dependency vendor.
|
|
104
128
|
|
|
129
|
+
## Pengalaman terminal
|
|
130
|
+
|
|
131
|
+
Saat bot dinyalakan di terminal interaktif (`npm start`, `node index.js`, `telebibz start`), telebibz memainkan urutan startup: efek ketik `Installing Dependencies......`, glass progress bar dengan kilau menyapu, dan banner ASCII rainbow animasi **Tele Bibz** (font figlet `Speed`) yang terus mengalir sampai bot terhubung, lalu diam dengan `✓ Connected as @<username>`.
|
|
132
|
+
|
|
133
|
+
Setelah itu, setiap update yang masuk ditampilkan dalam baris log yang mudah dibaca, dan error otomatis berwarna merah lengkap dengan stack-nya:
|
|
134
|
+
|
|
135
|
+
```text
|
|
136
|
+
[ => ] Message From 123456789 John Doe 29/08/2026 15:04:05
|
|
137
|
+
↳ Text: /start
|
|
138
|
+
[ => ] Callback From 123456789 John Doe 29/08/2026 15:04:07
|
|
139
|
+
↳ Data: menu:open
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Teks pesan/command biasa dibatasi 50 karakter; data tombol callback ditampilkan penuh. Matikan dengan `branding: false` pada `Bot`, atau pakai `logger.format: "json"` untuk log terstruktur. Output non-interaktif (pipe, Docker, CI) otomatis fallback ke teks polos tanpa animasi.
|
|
143
|
+
|
|
105
144
|
## CLI
|
|
106
145
|
|
|
107
|
-
|
|
146
|
+
Command CLI seperti `telebibz doctor`, `init`, dan `webhook` diawali banner rainbow `Tele Bibz`. Animasi startup otomatis fallback ke output statis bersih saat stdout bukan TTY.
|
|
108
147
|
|
|
109
148
|
```bash
|
|
110
149
|
npx telebibz init my-bot
|
|
@@ -116,8 +155,9 @@ npx telebibz test
|
|
|
116
155
|
Branding terminal juga dapat dicetak dari aplikasi:
|
|
117
156
|
|
|
118
157
|
```ts
|
|
119
|
-
import { printTerminalBranding } from "@xbibzlibrary/telebibz";
|
|
158
|
+
import { printTeleBibzBanner, printTerminalBranding } from "@xbibzlibrary/telebibz";
|
|
120
159
|
|
|
160
|
+
printTeleBibzBanner({ subtitle: "Bot saya" });
|
|
121
161
|
printTerminalBranding();
|
|
122
162
|
```
|
|
123
163
|
|
package/README.md
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|

|
|
4
4
|
|
|
5
5
|
[](https://github.com/XbibzOfficial777/telebibz/actions/workflows/ci.yml)
|
|
6
|
+
[](https://www.npmjs.com/package/@xbibzlibrary/telebibz)
|
|
7
|
+
[](https://www.npmjs.com/package/@xbibzlibrary/telebibz)
|
|
8
|
+
[](https://www.npmjs.com/package/@xbibzlibrary/telebibz)
|
|
6
9
|
|
|
7
|
-
**`@xbibzlibrary/telebibz`** is a
|
|
10
|
+
**`@xbibzlibrary/telebibz`** is a Telegram Bot SDK and framework for Node.js and TypeScript. It provides a typed API client, polling, routing, middleware, context helpers, keyboard builders, state/session primitives, webhooks, queues, scheduling, caching, plugin lifecycle, colorful terminal logging, CLI tooling, and testing utilities.
|
|
8
11
|
|
|
9
12
|
## Documentation languages
|
|
10
13
|
|
|
@@ -14,6 +17,10 @@ Complete API references: [English](docs/API.md) · [Indonesia](docs/API.id.md)
|
|
|
14
17
|
|
|
15
18
|
GitHub Packages guide: [English](docs/GITHUB_PACKAGES.md) · [Bahasa Indonesia](docs/GITHUB_PACKAGES.id.md) · [简体中文](docs/GITHUB_PACKAGES.zh-CN.md)
|
|
16
19
|
|
|
20
|
+
Getting started: [English](docs/GETTING_STARTED.md) · [Bahasa Indonesia](docs/GETTING_STARTED.id.md) · [简体中文](docs/GETTING_STARTED.zh-CN.md)
|
|
21
|
+
|
|
22
|
+
Community showcase: [SHOWCASE.md](SHOWCASE.md)
|
|
23
|
+
|
|
17
24
|

|
|
18
25
|
|
|
19
26
|
## Installation
|
|
@@ -22,7 +29,7 @@ GitHub Packages guide: [English](docs/GITHUB_PACKAGES.md) · [Bahasa Indonesia](
|
|
|
22
29
|
npm install @xbibzlibrary/telebibz
|
|
23
30
|
```
|
|
24
31
|
|
|
25
|
-
Node.js **
|
|
32
|
+
Node.js **22 or newer** is required.
|
|
26
33
|
|
|
27
34
|
## Minimal bot
|
|
28
35
|
|
|
@@ -31,14 +38,25 @@ import { Bot } from "@xbibzlibrary/telebibz";
|
|
|
31
38
|
|
|
32
39
|
const bot = new Bot(process.env.TELEGRAM_BOT_TOKEN!);
|
|
33
40
|
|
|
34
|
-
bot.command("start", (ctx) => ctx.reply("Bot is active."));
|
|
35
|
-
bot.onText("ping", (ctx) => ctx.reply("pong"));
|
|
41
|
+
bot.command("start", async (ctx) => { await ctx.reply("Bot is active."); });
|
|
42
|
+
bot.onText("ping", async (ctx) => { await ctx.reply("pong"); });
|
|
36
43
|
|
|
37
44
|
await bot.start();
|
|
38
45
|
```
|
|
39
46
|
|
|
40
47
|
`Bot.start()` runs long polling. For manual lifecycle control, use `init()`, `launch({ mode: "polling" })`, `health()`, `stop()`, or `restart()`.
|
|
41
48
|
|
|
49
|
+
## Official starter examples
|
|
50
|
+
|
|
51
|
+
The repository includes runnable starters for a minimal bot, a multi-step registration wizard, and a Node.js webhook server. Browse [`examples/README.md`](examples/README.md), or run the minimal starter after setting `TELEGRAM_BOT_TOKEN`:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
export TELEGRAM_BOT_TOKEN="<your-bot-token>"
|
|
55
|
+
npx tsx examples/minimal.ts
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The examples are typechecked in CI with `npm run test:examples` and never contain real credentials.
|
|
59
|
+
|
|
42
60
|
## Router and middleware
|
|
43
61
|
|
|
44
62
|
```ts
|
|
@@ -48,12 +66,16 @@ bot.use(async (ctx, next) => {
|
|
|
48
66
|
console.log(`processed in ${Date.now() - started}ms`);
|
|
49
67
|
});
|
|
50
68
|
|
|
51
|
-
bot.command("help", (ctx) => ctx.reply("Help is available."));
|
|
52
|
-
bot.onRegex(/^order:(\\d+)$/, (ctx) => ctx.reply("Order received."));
|
|
53
|
-
bot.callback("profile:*", (ctx) => ctx.answerCallbackQuery("Opened."));
|
|
69
|
+
bot.command("help", async (ctx) => { await ctx.reply("Help is available."); });
|
|
70
|
+
bot.onRegex(/^order:(\\d+)$/, async (ctx) => { await ctx.reply("Order received."); });
|
|
71
|
+
bot.callback("profile:*", async (ctx) => { await ctx.answerCallbackQuery("Opened."); });
|
|
72
|
+
bot.on("message:photo", async (ctx) => { await ctx.reply("Nice photo."); });
|
|
73
|
+
bot.on(["message:text", "callback_query:data"], async (ctx) => { await ctx.reply("Got it."); });
|
|
74
|
+
bot.hears("ping", async (ctx) => { await ctx.reply("pong"); });
|
|
75
|
+
bot.catch(async (error, ctx) => { await ctx.reply("Something went wrong."); });
|
|
54
76
|
```
|
|
55
77
|
|
|
56
|
-
The router supports commands, exact text, regular expressions, callback patterns, custom predicates, nested routers, per-route middleware, and route priority.
|
|
78
|
+
The router supports commands, exact text, regular expressions, callback patterns, update-type filters (`on`), custom predicates, nested routers, per-route middleware, and route priority. `bot.catch()` registers an error boundary: handler failures are routed there instead of rejecting the update.
|
|
57
79
|
|
|
58
80
|
## Telegram API
|
|
59
81
|
|
|
@@ -85,7 +107,7 @@ Builders produce native Telegram keyboard payloads. HTML/CSS interfaces require
|
|
|
85
107
|
|
|
86
108
|
## Colorful runtime logging
|
|
87
109
|
|
|
88
|
-
|
|
110
|
+
The logger emits compact, readable terminal lines with colored levels and structured context. Log levels are `silent`, `error`, `warn`, `info`, `debug`, and `trace`; sensitive values are redacted; errors print in red with the full stack. Use `format: "json"` for machine ingestion and `includeUpdateContent: true` only when message text or callback data is explicitly required.
|
|
89
111
|
|
|
90
112
|
```ts
|
|
91
113
|
const bot = new Bot({
|
|
@@ -109,7 +131,7 @@ const wizard = new Wizard()
|
|
|
109
131
|
|
|
110
132
|
const bot = new Bot(process.env.TELEGRAM_BOT_TOKEN!);
|
|
111
133
|
bot.useWizard(wizard);
|
|
112
|
-
bot.command("start", (ctx) => wizard.run(ctx));
|
|
134
|
+
bot.command("start", async (ctx) => { await wizard.run(ctx); });
|
|
113
135
|
await bot.start();
|
|
114
136
|
```
|
|
115
137
|
|
|
@@ -132,9 +154,24 @@ const handler = createWebhookHandler(bot, {
|
|
|
132
154
|
|
|
133
155
|
The package provides `MemoryStorage` with TTL and serialized per-key updates, `JsonFileStorage`, `RedisStorage`, `SqlStorage`, `MongoStorage`, persistent application state storage, bot sessions, storage-backed conversations and forms, permission-aware menus, `MenuController` pagination, `MemoryCache`, a token-bucket limiter, a task queue with retry/backoff/concurrency/delay/cancel, and schedulers for intervals, one-shot tasks, and full five-field cron expressions. Redis, SQL, and Mongo adapters use small driver interfaces so the core package remains free of vendor runtime dependencies.
|
|
134
156
|
|
|
157
|
+
## Terminal experience
|
|
158
|
+
|
|
159
|
+
When the bot starts on an interactive terminal (`npm start`, `node index.js`, `telebibz start`), telebibz plays a startup sequence: a typing effect for `Installing Dependencies......`, a glass progress bar with a sweeping highlight, and the animated rainbow ASCII banner **Tele Bibz** (figlet `Speed` font) that keeps flowing until the bot connects, then freezes with `✓ Connected as @<username>`.
|
|
160
|
+
|
|
161
|
+
Afterwards, every incoming update is logged on a human-readable line, and errors are printed in red with the full stack:
|
|
162
|
+
|
|
163
|
+
```text
|
|
164
|
+
[ => ] Message From 123456789 John Doe 29/08/2026 15:04:05
|
|
165
|
+
↳ Text: /start
|
|
166
|
+
[ => ] Callback From 123456789 John Doe 29/08/2026 15:04:07
|
|
167
|
+
↳ Data: menu:open
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Message and command text is truncated to 50 characters; callback button data is shown in full. Pass `branding: false` to `Bot` to disable the sequence, or set `logger.format: "json"` for structured log ingestion. Non-interactive stdout (pipes, Docker, CI) automatically falls back to plain output without animations.
|
|
171
|
+
|
|
135
172
|
## CLI
|
|
136
173
|
|
|
137
|
-
|
|
174
|
+
CLI commands such as `telebibz doctor`, `init`, and `webhook` start with the rainbow `Tele Bibz` banner. Startup animation automatically falls back to clean static output when stdout is not a TTY.
|
|
138
175
|
|
|
139
176
|
```bash
|
|
140
177
|
npm start
|
|
@@ -147,8 +184,9 @@ npx telebibz test
|
|
|
147
184
|
Applications can print the same terminal branding explicitly:
|
|
148
185
|
|
|
149
186
|
```ts
|
|
150
|
-
import { printTerminalBranding } from "@xbibzlibrary/telebibz";
|
|
187
|
+
import { printTeleBibzBanner, printTerminalBranding } from "@xbibzlibrary/telebibz";
|
|
151
188
|
|
|
189
|
+
printTeleBibzBanner({ subtitle: "My bot" });
|
|
152
190
|
printTerminalBranding();
|
|
153
191
|
```
|
|
154
192
|
|
package/README.zh-CN.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
+
[](https://github.com/XbibzOfficial777/telebibz/actions/workflows/ci.yml)
|
|
6
|
+
[](https://www.npmjs.com/package/@xbibzlibrary/telebibz)
|
|
7
|
+
[](https://www.npmjs.com/package/@xbibzlibrary/telebibz)
|
|
8
|
+
[](https://www.npmjs.com/package/@xbibzlibrary/telebibz)
|
|
9
|
+
|
|
5
10
|
**`@xbibzlibrary/telebibz`** 是一个面向 Node.js 和 TypeScript 的 Telegram Bot SDK 和框架。该包提供 API 客户端、轮询、路由器、中间件、上下文、键盘构造器、状态/会话、Webhook 处理、队列、调度器、缓存、插件生命周期、CLI 以及测试工具。
|
|
6
11
|
|
|
7
12
|
[English](README.md) · [Bahasa Indonesia](README.id.md) · **简体中文**
|
|
@@ -10,6 +15,10 @@
|
|
|
10
15
|
|
|
11
16
|
GitHub Packages 指南:[English](docs/GITHUB_PACKAGES.md) · [Bahasa Indonesia](docs/GITHUB_PACKAGES.id.md) · [简体中文](docs/GITHUB_PACKAGES.zh-CN.md)
|
|
12
17
|
|
|
18
|
+
入门指南:[English](docs/GETTING_STARTED.md) · [Bahasa Indonesia](docs/GETTING_STARTED.id.md) · [简体中文](docs/GETTING_STARTED.zh-CN.md)
|
|
19
|
+
|
|
20
|
+
社区 showcase:[SHOWCASE.md](SHOWCASE.md)
|
|
21
|
+
|
|
13
22
|

|
|
14
23
|
|
|
15
24
|
## 安装
|
|
@@ -18,7 +27,7 @@ GitHub Packages 指南:[English](docs/GITHUB_PACKAGES.md) · [Bahasa Indonesia
|
|
|
18
27
|
npm install @xbibzlibrary/telebibz
|
|
19
28
|
```
|
|
20
29
|
|
|
21
|
-
需要 Node.js **
|
|
30
|
+
需要 Node.js **22 或更高版本**。
|
|
22
31
|
|
|
23
32
|
## 简单机器人
|
|
24
33
|
|
|
@@ -27,14 +36,25 @@ import { Bot } from "@xbibzlibrary/telebibz";
|
|
|
27
36
|
|
|
28
37
|
const bot = new Bot(process.env.TELEGRAM_BOT_TOKEN!);
|
|
29
38
|
|
|
30
|
-
bot.command("start", (ctx) => ctx.reply("Bot aktif."));
|
|
31
|
-
bot.onText("ping", (ctx) => ctx.reply("pong"));
|
|
39
|
+
bot.command("start", async (ctx) => { await ctx.reply("Bot aktif."); });
|
|
40
|
+
bot.onText("ping", async (ctx) => { await ctx.reply("pong"); });
|
|
32
41
|
|
|
33
42
|
await bot.start();
|
|
34
43
|
```
|
|
35
44
|
|
|
36
45
|
`Bot.start()` 会运行长轮询。要手动管理生命周期,请使用 `init()`, `launch({ mode: "polling" })`, `health()`, `stop()`, 或 `restart()`。
|
|
37
46
|
|
|
47
|
+
## 官方 starter examples
|
|
48
|
+
|
|
49
|
+
repository 提供可直接运行的 minimal bot、多步骤 registration wizard 和 Node.js webhook starter。请查看 [`examples/README.md`](examples/README.md),或设置 `TELEGRAM_BOT_TOKEN` 后运行 minimal starter:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
export TELEGRAM_BOT_TOKEN="<your-bot-token>"
|
|
53
|
+
npx tsx examples/minimal.ts
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
所有 examples 都会通过 `npm run test:examples` 在 CI 中进行类型检查,并且不包含真实 credential。
|
|
57
|
+
|
|
38
58
|
## 路由器与中间件
|
|
39
59
|
|
|
40
60
|
```ts
|
|
@@ -44,12 +64,16 @@ bot.use(async (ctx, next) => {
|
|
|
44
64
|
console.log(`processed in ${Date.now() - started}ms`);
|
|
45
65
|
});
|
|
46
66
|
|
|
47
|
-
bot.command("help", (ctx) => ctx.reply("Bantuan tersedia."));
|
|
48
|
-
bot.onRegex(/^order:(\\d+)$/, (ctx) => ctx.reply("Order diterima."));
|
|
49
|
-
bot.callback("profile:*", (ctx) => ctx.answerCallbackQuery("Dibuka."));
|
|
67
|
+
bot.command("help", async (ctx) => { await ctx.reply("Bantuan tersedia."); });
|
|
68
|
+
bot.onRegex(/^order:(\\d+)$/, async (ctx) => { await ctx.reply("Order diterima."); });
|
|
69
|
+
bot.callback("profile:*", async (ctx) => { await ctx.answerCallbackQuery("Dibuka."); });
|
|
70
|
+
bot.on("message:photo", async (ctx) => { await ctx.reply("照片不错。"); });
|
|
71
|
+
bot.on(["message:text", "callback_query:data"], async (ctx) => { await ctx.reply("收到。"); });
|
|
72
|
+
bot.hears("ping", async (ctx) => { await ctx.reply("pong"); });
|
|
73
|
+
bot.catch(async (error, ctx) => { await ctx.reply("出错了。"); });
|
|
50
74
|
```
|
|
51
75
|
|
|
52
|
-
|
|
76
|
+
路由器支持命令、文本、正则、回调模式、更新类型过滤器(`on`)、自定义谓词、嵌套路由器、每条路由的中间件,以及路由优先级。`bot.catch()` 注册错误边界:处理器失败会转发到那里,而不是拒绝整个 update。
|
|
53
77
|
|
|
54
78
|
## Telegram API
|
|
55
79
|
|
|
@@ -83,7 +107,7 @@ await ctx.reply("Pilih menu:", { reply_markup: keyboard });
|
|
|
83
107
|
|
|
84
108
|
## Startup and terminal logs
|
|
85
109
|
|
|
86
|
-
|
|
110
|
+
The logger emits compact, readable terminal lines with colored levels and structured context. Log levels are `silent`, `error`, `warn`, `info`, `debug`, and `trace`; sensitive values are redacted; errors print in red with the full stack. Use `format: "json"` for machine ingestion and `includeUpdateContent: true` only when message text or callback data is explicitly required.
|
|
87
111
|
|
|
88
112
|
## Webhook
|
|
89
113
|
|
|
@@ -102,9 +126,24 @@ const handler = createWebhookHandler(bot, {
|
|
|
102
126
|
|
|
103
127
|
该包提供带 TTL 和原子更新的 `MemoryStorage`、`JsonFileStorage`、`RedisStorage`、`SqlStorage`、`MongoStorage`、bot session、基于 Storage 的 conversation/form、基于 permission 的菜单、`MenuController` 分页、`MemoryCache`、令牌桶限流器、支持重试/退避/并发/延迟/取消的任务队列,以及间隔、一次性和完整五字段 cron 的调度器。Redis、SQL 和 Mongo 适配器使用小型 driver interface,因此 core package 不需要 vendor runtime dependency。
|
|
104
128
|
|
|
129
|
+
## 终端体验
|
|
130
|
+
|
|
131
|
+
当 bot 在交互式终端启动时(`npm start`、`node index.js`、`telebibz start`),telebibz 会播放启动序列:`Installing Dependencies......` 打字效果、带扫过高光的 glass 进度条,以及动画彩虹 ASCII 横幅 **Tele Bibz**(figlet `Speed` 字体)——彩虹持续流动直到 bot 连接成功,随后定格并显示 `✓ Connected as @<username>`。
|
|
132
|
+
|
|
133
|
+
之后,每一条进入的 update 都会以易读的格式输出,错误自动以红色打印并附带完整堆栈:
|
|
134
|
+
|
|
135
|
+
```text
|
|
136
|
+
[ => ] Message From 123456789 John Doe 29/08/2026 15:04:05
|
|
137
|
+
↳ Text: /start
|
|
138
|
+
[ => ] Callback From 123456789 John Doe 29/08/2026 15:04:07
|
|
139
|
+
↳ Data: menu:open
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
普通消息与命令文本截断为 50 个字符;回调按钮数据完整显示。向 `Bot` 传入 `branding: false` 可关闭启动序列,或设置 `logger.format: "json"` 获取结构化日志。非交互 stdout(管道、Docker、CI)会自动回退到无动画的纯文本输出。
|
|
143
|
+
|
|
105
144
|
## CLI
|
|
106
145
|
|
|
107
|
-
|
|
146
|
+
`telebibz doctor`、`init`、`webhook` 等 CLI command 以彩虹 `Tele Bibz` 横幅开始。当 stdout 不是 TTY 时,启动动画自动回退为干净的静态输出。
|
|
108
147
|
|
|
109
148
|
```bash
|
|
110
149
|
npx telebibz init my-bot
|
|
@@ -116,8 +155,9 @@ npx telebibz test
|
|
|
116
155
|
也可以在应用中打印相同的 terminal branding:
|
|
117
156
|
|
|
118
157
|
```ts
|
|
119
|
-
import { printTerminalBranding } from "@xbibzlibrary/telebibz";
|
|
158
|
+
import { printTeleBibzBanner, printTerminalBranding } from "@xbibzlibrary/telebibz";
|
|
120
159
|
|
|
160
|
+
printTeleBibzBanner({ subtitle: "My bot" });
|
|
121
161
|
printTerminalBranding();
|
|
122
162
|
```
|
|
123
163
|
|
package/RELEASE_AUTOMATION.md
CHANGED
|
@@ -8,17 +8,29 @@ Setiap push ke branch `main` menjalankan workflow `.github/workflows/auto-publis
|
|
|
8
8
|
|
|
9
9
|
| Tahap | Perilaku |
|
|
10
10
|
|---|---|
|
|
11
|
-
| Checkout | Mengambil seluruh history
|
|
11
|
+
| Checkout | Mengambil seluruh history beserta tag (`fetch-depth: 0` + `fetch-tags: true`) agar analisis commit dan pembuatan tag akurat. |
|
|
12
12
|
| Install | Menjalankan `npm ci --ignore-scripts`. |
|
|
13
|
-
| Version | Membaca versi
|
|
13
|
+
| Version | Membaca versi `package.json`, versi latest npm, dan commit sejak tag release terakhir, lalu memilih versi berikutnya (lihat aturan di bawah). |
|
|
14
14
|
| Verification | Menjalankan typecheck, type-level tests, lint, runtime tests, build ESM/CommonJS, security audit, dan release check. |
|
|
15
15
|
| Immutable guard | Menolak publish jika versi target sudah ada di npmjs. |
|
|
16
|
-
| Git sync | Commit otomatis `chore(release): vX.Y.Z [skip release]
|
|
16
|
+
| Git sync | Commit otomatis `chore(release): vX.Y.Z [skip release]` (dilewati bila `package.json` sudah berada di versi target), membuat annotated tag `vX.Y.Z`, lalu push commit dan tag ke GitHub. |
|
|
17
17
|
| npmjs publish | Menerbitkan package public menggunakan `NPM_TOKEN`; provenance dinonaktifkan karena npm menolak provenance dari source repository private. |
|
|
18
18
|
| GitHub Release | Membuat GitHub Release dengan generated notes. |
|
|
19
19
|
|
|
20
20
|
Push commit version otomatis tidak memicu release kedua karena mengandung `[skip release]`. Workflow menggunakan concurrency sehingga release berjalan satu per satu.
|
|
21
21
|
|
|
22
|
+
## Aturan penomoran versi
|
|
23
|
+
|
|
24
|
+
Versi berikutnya dihitung dari `max(package.json, npm latest)` dengan bump berdasarkan Conventional Commits sejak tag release terakhir:
|
|
25
|
+
|
|
26
|
+
| Commit sejak tag terakhir | 0.x | >=1.0.0 |
|
|
27
|
+
|---|---|---|
|
|
28
|
+
| `BREAKING CHANGE:` atau `feat!:` / `fix!:` | minor (`0.1.19` → `0.2.0`) | major (`1.2.3` → `2.0.0`) |
|
|
29
|
+
| `feat:` / `feat(scope):` | minor | minor |
|
|
30
|
+
| lainnya (`fix:`, `docs:`, `chore:`, …) | patch | patch |
|
|
31
|
+
|
|
32
|
+
Jika `package.json` sudah dideklarasikan lebih tinggi daripada versi npm (misalnya dipersiapkan manual untuk `0.2.0`), workflow memakai versi tersebut apa adanya. Hasil perhitungan tidak pernah boleh lebih rendah daripada versi npm yang sudah terbit; jika demikian, workflow gagal dengan pesan yang jelas.
|
|
33
|
+
|
|
22
34
|
## Secret dan permission yang wajib tersedia
|
|
23
35
|
|
|
24
36
|
Workflow membutuhkan `contents: write` untuk version bump, tag, dan GitHub Release. Buka repository GitHub, kemudian masuk ke **Settings → Secrets and variables → Actions** dan tambahkan repository atau environment secret berikut:
|
|
@@ -33,9 +45,9 @@ Jangan menyimpan token di repository, `.npmrc`, source code, issue, commit, atau
|
|
|
33
45
|
|
|
34
46
|
## Aturan penggunaan
|
|
35
47
|
|
|
36
|
-
Perubahan source biasa dapat dipush ke `main`; workflow
|
|
48
|
+
Perubahan source biasa dapat dipush ke `main`; workflow menghitung versi baru berdasarkan Conventional Commits (`feat:` → minor, `fix:`/lainnya → patch, `feat!:`/`BREAKING CHANGE:` → minor pada 0.x / major pada 1.x) setelah seluruh quality gates lulus. Karena versi npm immutable, workflow tidak pernah menimpa versi yang telah ada.
|
|
37
49
|
|
|
38
|
-
Untuk
|
|
50
|
+
Untuk rilis yang dipersiapkan secara eksplisit (misalnya `0.2.0` atau `1.0.0`), deklarasikan versi tersebut langsung di `package.json` sebelum push; workflow akan memakainya apa adanya selama lebih tinggi daripada versi npm yang sudah terbit.
|
|
39
51
|
|
|
40
52
|
Untuk perubahan dokumentasi atau perubahan internal yang tidak boleh menerbitkan npm, gunakan commit message yang memuat marker berikut:
|
|
41
53
|
|
package/SHOWCASE.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Telebibz showcase
|
|
2
|
+
|
|
3
|
+
This page highlights projects built with Telebibz. If you are using Telebibz in a public project, open a pull request adding a short entry using the format below. Do not include bot tokens, private URLs, personal data, or confidential source code.
|
|
4
|
+
|
|
5
|
+
## Projects
|
|
6
|
+
|
|
7
|
+
No community submissions yet. The first public project can be added here.
|
|
8
|
+
|
|
9
|
+
### Submission format
|
|
10
|
+
|
|
11
|
+
```markdown
|
|
12
|
+
### Project name
|
|
13
|
+
|
|
14
|
+
- **Link:** https://example.com
|
|
15
|
+
- **Description:** One sentence describing what the bot does.
|
|
16
|
+
- **Telebibz features:** Commands, wizard, webhook, keyboard, plugin, or other features used.
|
|
17
|
+
- **Maintainer:** @github-handle
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Why submit a project?
|
|
21
|
+
|
|
22
|
+
A showcase entry helps other developers discover practical patterns and gives maintainers feedback about which parts of the framework are useful in real applications. Entries are reviewed for relevance, security, and respectful presentation. A listing is not an endorsement, and maintainers may remove entries that become unavailable or unsafe.
|
|
23
|
+
|
|
24
|
+
## Related resources
|
|
25
|
+
|
|
26
|
+
- [Getting started](docs/GETTING_STARTED.md)
|
|
27
|
+
- [Runnable examples](examples/README.md)
|
|
28
|
+
- [Complete API reference](docs/API.md)
|
|
29
|
+
- [Contribution guide](CONTRIBUTING.md)
|
package/bin/telebibz.mjs
CHANGED
package/dist/src/api/client.d.ts
CHANGED
|
@@ -26,7 +26,9 @@ export declare class ApiClient {
|
|
|
26
26
|
private readonly hooks;
|
|
27
27
|
constructor(options: ApiClientOptions);
|
|
28
28
|
call<M extends TelegramMethodName>(method: M, ...args: ApiCallArgs<M>): Promise<ApiResult<M>>;
|
|
29
|
-
request<M extends TelegramMethodName>(method: M, payload?: ApiParams<M>, signal?: AbortSignal
|
|
29
|
+
request<M extends TelegramMethodName>(method: M, payload?: ApiParams<M>, signal?: AbortSignal, options?: {
|
|
30
|
+
timeoutMs?: number;
|
|
31
|
+
}): Promise<ApiResult<M>>;
|
|
30
32
|
raw(method: string, payload?: Record<string, unknown>, signal?: AbortSignal): Promise<unknown>;
|
|
31
33
|
}
|
|
32
34
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAExF,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,gBAAgB,CAAC;AAElE,MAAM,WAAW,cAAc;IAAG,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE;AACnK,MAAM,WAAW,gBAAgB;IAAG,SAAS,EAAE,SAAS,CAAC;IAAC,KAAK,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAAC,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAAC,OAAO,C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AAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAsBvJ,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;CAQrG"}
|
package/dist/src/api/client.js
CHANGED
|
@@ -21,7 +21,7 @@ export class ApiClient {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
async call(method, ...args) { return this.request(method, args[0]); }
|
|
24
|
-
async request(method, payload, signal) {
|
|
24
|
+
async request(method, payload, signal, options) {
|
|
25
25
|
const context = { method, payload, startedAt: Date.now() };
|
|
26
26
|
await this.hooks.onRequest?.(context);
|
|
27
27
|
try {
|
|
@@ -30,6 +30,8 @@ export class ApiClient {
|
|
|
30
30
|
request.payload = payload;
|
|
31
31
|
if (signal !== undefined)
|
|
32
32
|
request.signal = signal;
|
|
33
|
+
if (options?.timeoutMs !== undefined)
|
|
34
|
+
request.timeoutMs = options.timeoutMs;
|
|
33
35
|
const response = await this.transport.request(request);
|
|
34
36
|
context.durationMs = Date.now() - context.startedAt;
|
|
35
37
|
context.response = response.data;
|
|
@@ -1 +1 @@
|
|
|
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,aAAa,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAQvE,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,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