yaebal 0.0.2 → 0.0.3
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/README.md +18 -17
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
### yaebal
|
|
5
5
|
|
|
6
|
-
*the batteries-included telegram bot framework*
|
|
6
|
+
*the batteries-included telegram bot framework*
|
|
7
7
|
**one import** · **type-safe** · **runtime-agnostic**
|
|
8
8
|
|
|
9
9
|
[🔗 docs](https://yaebal.pages.dev) · [⭐ github](https://github.com/neverlane/yaebal) · [📦 npmx](https://npmx.dev/org/yaebal)
|
|
@@ -58,21 +58,21 @@ bot.on("callback_query:data", (ctx) => ctx.answer("ok")); // CallbackQueryContex
|
|
|
58
58
|
|
|
59
59
|
one `import { … } from "yaebal"` gives you, ready to use:
|
|
60
60
|
|
|
61
|
-
| from
|
|
62
|
-
|
|
63
|
-
| core
|
|
64
|
-
| contexts
|
|
65
|
-
| `@yaebal/keyboard
|
|
66
|
-
| `@yaebal/callback-data` | `callbackData`
|
|
67
|
-
| `@yaebal/fmt`
|
|
68
|
-
| `@yaebal/filters`
|
|
69
|
-
| `@yaebal/session`
|
|
70
|
-
| `@yaebal/i18n`
|
|
71
|
-
| `@yaebal/web`
|
|
61
|
+
| from | exports | what |
|
|
62
|
+
|:------------------------|:---------------------------------------------------------------|:---------------------------------------|
|
|
63
|
+
| core | `Bot`, `Composer`, `Context`, `media`, `Api` hooks | the engine, filter queries, transports |
|
|
64
|
+
| contexts | `createBot`, the per-update context classes | typed `ctx.react` / `ctx.editText` / … |
|
|
65
|
+
| `@yaebal/keyboard` | `InlineKeyboard`, `Keyboard` | fluent keyboard builders |
|
|
66
|
+
| `@yaebal/callback-data` | `callbackData` | typed `callback_data` pack / unpack |
|
|
67
|
+
| `@yaebal/fmt` | `html`, `md` (+ `*ToEntities`) | tagged templates with auto-escaping |
|
|
68
|
+
| `@yaebal/filters` | `filters`, `and`, `or`, `not` | composable, type-narrowing filters |
|
|
69
|
+
| `@yaebal/session` | `session` | per-chat state, pluggable storage |
|
|
70
|
+
| `@yaebal/i18n` | `i18n` | per-chat locale, `ctx.t` |
|
|
71
|
+
| `@yaebal/web` | `serve`, `webhook`, `setWebhook`, `deleteWebhook` | webhooks on edge/web runtimes |
|
|
72
72
|
|
|
73
73
|
## a quick tour
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
### keyboards + typed callback data
|
|
76
76
|
|
|
77
77
|
```ts
|
|
78
78
|
import { InlineKeyboard, callbackData } from "yaebal";
|
|
@@ -94,7 +94,7 @@ bot.on("callback_query:data", (ctx) => {
|
|
|
94
94
|
});
|
|
95
95
|
```
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
### per-chat sessions
|
|
98
98
|
|
|
99
99
|
```ts
|
|
100
100
|
import { session } from "yaebal";
|
|
@@ -103,7 +103,7 @@ bot.install(session({ initial: () => ({ count: 0 }) }));
|
|
|
103
103
|
bot.command("count", (ctx) => ctx.reply(`#${++ctx.session.count}`));
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
### i18n (internationalization)
|
|
107
107
|
|
|
108
108
|
```ts
|
|
109
109
|
import { i18n } from "yaebal";
|
|
@@ -115,7 +115,7 @@ bot.install(i18n({
|
|
|
115
115
|
bot.command("start", (ctx) => ctx.reply(ctx.t("hi")));
|
|
116
116
|
```
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
### media — no platform package
|
|
119
119
|
|
|
120
120
|
```ts
|
|
121
121
|
import { media } from "yaebal";
|
|
@@ -124,7 +124,7 @@ bot.command("pic", (ctx) => ctx.sendPhoto(media.path("./cat.jpg"))); // node/bun
|
|
|
124
124
|
// on edge, send media.url(...) / media.buffer(...) instead
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
### run on the edge (webhooks)
|
|
128
128
|
|
|
129
129
|
```ts
|
|
130
130
|
import { Bot, webhook } from "yaebal";
|
|
@@ -133,6 +133,7 @@ export default {
|
|
|
133
133
|
fetch(request: Request, env: { BOT_TOKEN: string; SECRET: string }) {
|
|
134
134
|
const bot = new Bot(env.BOT_TOKEN);
|
|
135
135
|
bot.command("start", (ctx) => ctx.reply("running on the edge ⚡"));
|
|
136
|
+
|
|
136
137
|
return webhook(bot, { secretToken: env.SECRET })(request);
|
|
137
138
|
},
|
|
138
139
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yaebal",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "yaebal — batteries-included Telegram Bot API framework: core + auto-generated contexts + the common plugins, one import.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"src"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"@yaebal/core": "0.0.2",
|
|
20
|
+
"@yaebal/contexts": "0.0.1",
|
|
21
|
+
"@yaebal/filters": "0.0.1",
|
|
19
22
|
"@yaebal/keyboard": "0.0.1",
|
|
23
|
+
"@yaebal/session": "0.0.1",
|
|
24
|
+
"@yaebal/i18n": "0.0.2",
|
|
20
25
|
"@yaebal/callback-data": "0.0.1",
|
|
21
26
|
"@yaebal/fmt": "0.0.1",
|
|
22
|
-
"@yaebal/session": "0.0.1",
|
|
23
|
-
"@yaebal/filters": "0.0.1",
|
|
24
|
-
"@yaebal/core": "0.0.1",
|
|
25
|
-
"@yaebal/contexts": "0.0.1",
|
|
26
|
-
"@yaebal/i18n": "0.0.1",
|
|
27
27
|
"@yaebal/web": "0.0.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|