@xbibzlibrary/telebibz 3.1.5 → 3.1.6

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/index.d.ts CHANGED
@@ -146,8 +146,8 @@ export class Composer {
146
146
  hears(match: string | RegExp, ...middleware: Handler[]): this;
147
147
  command(names: string | string[], ...middleware: Handler[]): this;
148
148
  callbackQuery(triggers: string | RegExp | Array<string | RegExp>, ...middleware: Handler[]): this;
149
- filter(predicate: (ctx: Context) => unknown, ...middleware: Handler[]): Composer;
150
- drop(predicate: (ctx: Context) => unknown, ...middleware: Handler[]): Composer;
149
+ filter(predicate: (ctx: Context) => unknown, ...middleware: Array<Handler | Composer>): Composer;
150
+ drop(predicate: (ctx: Context) => unknown, ...middleware: Array<Handler | Composer>): Composer;
151
151
  branch(predicate: (ctx: Context) => unknown, yes: any, no: any): this;
152
152
  route(router: string | ((ctx: Context) => unknown), routes: Record<string, any>): this;
153
153
  lazy(factory: (ctx: Context) => any): this;
@@ -162,11 +162,18 @@ export class TeleBibz {
162
162
  constructor(token: string, opts?: TeleBibzOptions);
163
163
  api: ApiClient;
164
164
  botInfo?: any;
165
- use(...middleware: Handler[]): this;
165
+ use(...middleware: Array<Handler | Composer>): this;
166
166
  cmd(names: string | string[], ...middleware: Handler[]): this;
167
167
  hears(match: string | RegExp, ...middleware: Handler[]): this;
168
168
  action(triggers: string | RegExp | Array<string | RegExp>, ...middleware: Handler[]): this;
169
169
  on(filter: string | string[], ...middleware: Handler[]): this;
170
+ inlineQuery(trigger: string | RegExp, ...middleware: Handler[]): this;
171
+ branch(predicate: (ctx: Context) => unknown, yes: Handler | Composer, no: Handler | Composer): this;
172
+ filter(predicate: (ctx: Context) => unknown, ...middleware: Array<Handler | Composer>): this;
173
+ drop(predicate: (ctx: Context) => unknown, ...middleware: Array<Handler | Composer>): this;
174
+ route(router: string | ((ctx: Context) => unknown), routes: Record<string, Handler | Composer>): this;
175
+ lazy(factory: (ctx: Context) => Handler | Handler[] | Composer | Promise<Handler | Handler[] | Composer>): this;
176
+ fork(...middleware: Array<Handler | Composer>): this;
170
177
  start(replies: string | Handler): this;
171
178
  wizard(id: string, def: WizardDef, bindCommand?: boolean): this;
172
179
  wizardStart(ctx: Context, id: string): Promise<unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xbibzlibrary/telebibz",
3
- "version": "3.1.5",
3
+ "version": "3.1.6",
4
4
  "description": "Telegram Bot API 10.3 framework: all 185 methods with typed payloads, rich messages, live photos, drafts, ephemeral messages, inline queries, sessions, webhooks, menus and wizards. Xbibz Technology ID",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -36,7 +36,11 @@
36
36
  },
37
37
  "scripts": {
38
38
  "test": "node test/all.test.js && node test/audit.test.js",
39
- "typecheck": "tsc --project tsconfig.types.json"
39
+ "typecheck": "tsc --project tsconfig.types.json",
40
+ "docs:dev": "vitepress dev docs --host 0.0.0.0",
41
+ "docs:gen-api": "node scripts/generate-api-methods.js",
42
+ "docs:build": "npm run docs:gen-api && vitepress build docs",
43
+ "docs:preview": "vitepress preview docs --host 0.0.0.0"
40
44
  },
41
45
  "files": [
42
46
  "index.js",
@@ -51,6 +55,20 @@
51
55
  "CHANGELOG.md"
52
56
  ],
53
57
  "devDependencies": {
54
- "typescript": "^7.0.2"
58
+ "@lucide/vue": "^1.50.0",
59
+ "@tailwindcss/vite": "^4.3.3",
60
+ "@vueuse/core": "^14.4.0",
61
+ "class-variance-authority": "^0.7.1",
62
+ "clsx": "^2.1.1",
63
+ "reka-ui": "^2.10.5",
64
+ "tailwind-merge": "^3.7.0",
65
+ "tailwindcss": "^4.3.3",
66
+ "tw-animate-css": "^1.4.0",
67
+ "typescript": "^7.0.2",
68
+ "vitepress": "^1.6.4"
69
+ },
70
+ "overrides": {
71
+ "vite": "^6.4.3",
72
+ "esbuild": "^0.25.0"
55
73
  }
56
74
  }
@@ -1,6 +1,16 @@
1
- import { TeleBibz, rich, type TelegramMethodName, type TelegramMethodPayload, TelegramTypes } from '..';
1
+ import { Composer, TeleBibz, rich, type TelegramMethodName, type TelegramMethodPayload, TelegramTypes } from '..';
2
2
 
3
3
  const bot = new TeleBibz('123456:TESTTOKEN', { silent: true });
4
+ const privateRoutes = new Composer();
5
+ privateRoutes.filter((ctx) => ctx.chat?.type === 'private').command('profile', (ctx) => ctx.reply('profile'));
6
+ bot.use(privateRoutes);
7
+ bot.filter((ctx) => ctx.chat?.type === 'private', (ctx) => ctx.reply('private filter'));
8
+ bot.drop((ctx) => ctx.from?.is_bot === true, (ctx) => ctx.reply('drop route'));
9
+ bot.branch((ctx) => Boolean(ctx.chat), (ctx) => ctx.reply('chat'), (ctx) => ctx.reply('no chat'));
10
+ bot.route((ctx) => ctx.chat?.type ?? 'unknown', { private: (ctx) => ctx.reply('private') });
11
+ bot.lazy(() => (ctx) => ctx.reply('lazy'));
12
+ bot.fork((ctx) => ctx.reply('fork'));
13
+ bot.inlineQuery('*', (ctx) => ctx.answerInlineQuery([]));
4
14
  const message = rich.blocks([
5
15
  rich.heading('Typed rich content', 2),
6
16
  rich.paragraph(['Status: ', rich.bold('ready')]),