gramio 0.0.21 → 0.0.22

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/dist/bot.d.ts CHANGED
@@ -82,6 +82,8 @@ export declare class Bot<Errors extends ErrorDefinitions = {}, Derives extends D
82
82
  command(command: string, handler: (context: ContextType<typeof this, "message"> & Derives["global"] & Derives["message"] & {
83
83
  args: string | null;
84
84
  }) => unknown, options?: Omit<SetMyCommandsParams, "commands"> & Omit<TelegramBotCommand, "command">): this;
85
+ /** Currently not isolated!!! */
86
+ group(grouped: (bot: typeof this) => Bot<any, any>): Bot<any, any>;
85
87
  start({ webhook, dropPendingUpdates, allowedUpdates, }?: {
86
88
  webhook?: Omit<APIMethodParams<"setWebhook">, "drop_pending_updates" | "allowed_updates">;
87
89
  dropPendingUpdates?: boolean;
package/dist/bot.js CHANGED
@@ -268,6 +268,16 @@ let Bot = (() => {
268
268
  else
269
269
  this.derive(updateName, derive);
270
270
  }
271
+ for (const value of plugin.preRequests) {
272
+ const [preRequest, updateName] = value;
273
+ if (!updateName)
274
+ this.preRequest(preRequest);
275
+ else
276
+ this.preRequest(updateName, preRequest);
277
+ }
278
+ for (const handler of plugin.groups) {
279
+ this.group(handler);
280
+ }
271
281
  this.dependencies.push(plugin.name);
272
282
  return this;
273
283
  }
@@ -310,6 +320,10 @@ let Bot = (() => {
310
320
  return next();
311
321
  });
312
322
  }
323
+ /** Currently not isolated!!! */
324
+ group(grouped) {
325
+ return grouped(this);
326
+ }
313
327
  async start({ webhook, dropPendingUpdates, allowedUpdates, } = {}) {
314
328
  await Promise.all(this.lazyloadPlugins.map(async (plugin) => this.extend(await plugin)));
315
329
  this.info = await this.api.getMe();
package/dist/plugin.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { BotLike, Context, ContextType, MaybeArray, UpdateName } from "@gramio/contexts";
2
2
  import type { APIMethods } from "@gramio/types";
3
3
  import type { DeriveDefinitions, ErrorDefinitions, Hooks } from "./types";
4
+ import type { Bot } from "./bot";
4
5
  export declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extends DeriveDefinitions = DeriveDefinitions> {
5
6
  Errors: Errors;
6
7
  Derives: Derives;
@@ -9,6 +10,7 @@ export declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extend
9
10
  Hooks.PreRequest<any>,
10
11
  MaybeArray<keyof APIMethods> | undefined
11
12
  ][];
13
+ groups: ((bot: Bot<any, any>) => Bot<any, any>)[];
12
14
  name: string;
13
15
  errorsDefinitions: Record<string, {
14
16
  new (...args: any): any;
@@ -18,6 +20,8 @@ export declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extend
18
20
  constructor(name: string, { dependencies }?: {
19
21
  dependencies?: string[];
20
22
  });
23
+ /** Currently not isolated!!! */
24
+ group(grouped: (bot: Bot<Errors, Derives>) => Bot<any, any>): this;
21
25
  /**
22
26
  * Register custom class-error in plugin
23
27
  **/
package/dist/plugin.js CHANGED
@@ -61,6 +61,7 @@ let Plugin = (() => {
61
61
  Derives;
62
62
  derives = [];
63
63
  preRequests = [];
64
+ groups = [];
64
65
  name;
65
66
  errorsDefinitions = {};
66
67
  dependencies = [];
@@ -69,6 +70,11 @@ let Plugin = (() => {
69
70
  if (dependencies)
70
71
  this.dependencies = dependencies;
71
72
  }
73
+ /** Currently not isolated!!! */
74
+ group(grouped) {
75
+ this.groups.push(grouped);
76
+ return this;
77
+ }
72
78
  /**
73
79
  * Register custom class-error in plugin
74
80
  **/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gramio",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "Powerful Telegram Bot API framework",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",