gramio 0.2.0 → 0.2.2

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/index.cjs CHANGED
@@ -306,12 +306,18 @@ class Plugin {
306
306
  }
307
307
  return this;
308
308
  }
309
+ /**
310
+ * ! ** At the moment, it can only pick up types** */
311
+ extend(plugin) {
312
+ return this;
313
+ }
309
314
  }
310
315
  _init$1 = __decoratorStart$1();
311
316
  Plugin = __decorateElement$1(_init$1, 0, "Plugin", _Plugin_decorators, Plugin);
312
317
  __runInitializers$1(_init$1, 1, Plugin);
313
318
 
314
319
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
320
+
315
321
  class UpdateQueue {
316
322
  updateQueue = [];
317
323
  pendingUpdates = /* @__PURE__ */ new Set();
@@ -398,7 +404,7 @@ class Updates {
398
404
  }
399
405
  }
400
406
  /** @deprecated use bot.start instead @internal */
401
- async startPolling(params = {}) {
407
+ startPolling(params = {}) {
402
408
  if (this.isStarted) throw new Error("[UPDATES] Polling already started!");
403
409
  this.isStarted = true;
404
410
  this.startFetchLoop(params);
@@ -468,11 +474,12 @@ _Bot_decorators = [inspectable.Inspectable({
468
474
  serialize: () => ({})
469
475
  })];
470
476
  class Bot {
477
+ /** @deprecated use `~` instead*/
471
478
  _ = {
472
- /** @internal. Remap generic */
479
+ /** @deprecated @internal. Remap generic */
473
480
  derives: {}
474
481
  };
475
- /** @internal. Remap generic */
482
+ /** @deprecated use `~.derives` instead @internal. Remap generic */
476
483
  __Derives;
477
484
  "~" = this._;
478
485
  filters = {
@@ -566,7 +573,7 @@ class Bot {
566
573
  }
567
574
  async _callApi(method, params = {}) {
568
575
  const debug$api$method = debug$api.extend(method);
569
- const url = `${this.options.api.baseURL}${this.options.token}/${method}`;
576
+ const url = `${this.options.api.baseURL}${this.options.token}/${this.options.api.useTest ? "test/" : ""}${method}`;
570
577
  const reqOptions = {
571
578
  method: "POST",
572
579
  ...this.options.api.fetchOptions,
@@ -1097,8 +1104,9 @@ class Bot {
1097
1104
  if (!webhook) {
1098
1105
  await this.api.deleteWebhook({
1099
1106
  drop_pending_updates: dropPendingUpdates
1107
+ // suppress: true,
1100
1108
  });
1101
- await this.updates.startPolling({
1109
+ this.updates.startPolling({
1102
1110
  allowed_updates: allowedUpdates
1103
1111
  });
1104
1112
  this.runImmutableHooks("onStart", {
@@ -1114,6 +1122,7 @@ class Bot {
1114
1122
  ...webhook,
1115
1123
  drop_pending_updates: dropPendingUpdates,
1116
1124
  allowed_updates: allowedUpdates
1125
+ // suppress: true,
1117
1126
  });
1118
1127
  this.runImmutableHooks("onStart", {
1119
1128
  plugins: this.dependencies,
package/dist/index.d.cts CHANGED
@@ -307,6 +307,9 @@ declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extends Deriv
307
307
  */
308
308
  onError<T extends UpdateName>(updateName: MaybeArray<T>, handler: Hooks.OnError<Errors, ContextType<Bot, T> & Derives["global"] & Derives[T]>): this;
309
309
  onError(handler: Hooks.OnError<Errors, Context<AnyBot> & Derives["global"]>): this;
310
+ /**
311
+ * ! ** At the moment, it can only pick up types** */
312
+ extend<NewPlugin extends AnyPlugin>(plugin: MaybePromise<NewPlugin>): Plugin<Errors & NewPlugin["_"]["Errors"], Derives & NewPlugin["_"]["Derives"]>;
310
313
  }
311
314
 
312
315
  /** Bot options that you can provide to {@link Bot} constructor */
@@ -576,7 +579,7 @@ declare class Updates {
576
579
  constructor(bot: AnyBot, onError: CaughtMiddlewareHandler<Context<any>>);
577
580
  handleUpdate(data: TelegramUpdate): Promise<unknown>;
578
581
  /** @deprecated use bot.start instead @internal */
579
- startPolling(params?: APIMethodParams<"getUpdates">): Promise<void>;
582
+ startPolling(params?: APIMethodParams<"getUpdates">): void;
580
583
  startFetchLoop(params?: APIMethodParams<"getUpdates">): Promise<void>;
581
584
  stopPolling(): void;
582
585
  }
@@ -595,14 +598,15 @@ declare class Updates {
595
598
  * ```
596
599
  */
597
600
  declare class Bot<Errors extends ErrorDefinitions = {}, Derives extends DeriveDefinitions = DeriveDefinitions> {
601
+ /** @deprecated use `~` instead*/
598
602
  _: {
599
- /** @internal. Remap generic */
603
+ /** @deprecated @internal. Remap generic */
600
604
  derives: Derives;
601
605
  };
602
- /** @internal. Remap generic */
606
+ /** @deprecated use `~.derives` instead @internal. Remap generic */
603
607
  __Derives: Derives;
604
608
  "~": {
605
- /** @internal. Remap generic */
609
+ /** @deprecated @internal. Remap generic */
606
610
  derives: Derives;
607
611
  };
608
612
  private filters;
@@ -1064,4 +1068,4 @@ declare function webhookHandler<Framework extends keyof typeof frameworks>(bot:
1064
1068
  response: () => any;
1065
1069
  } ? (...args: Parameters<(typeof frameworks)[Framework]>) => ReturnType<ReturnType<(typeof frameworks)[Framework]>["response"]> : (...args: Parameters<(typeof frameworks)[Framework]>) => void;
1066
1070
 
1067
- export { type AnyBot, type AnyPlugin, Bot, type BotOptions, Composer, type DeriveDefinitions, type ErrorDefinitions, ErrorKind, type FilterDefinitions, type Handler, Hooks, type MaybePromise, type MaybeSuppressedParams, Plugin, type Suppress, type SuppressedAPIMethodParams, type SuppressedAPIMethodReturn, type SuppressedAPIMethods, TelegramError, Updates, type WebhookHandlers, webhookHandler };
1071
+ export { type AnyBot, type AnyPlugin, Bot, type BotOptions, Composer, type DeriveDefinitions, type ErrorDefinitions, ErrorKind, type FilterDefinitions, type Handler, Hooks, type MaybePromise, type MaybeSuppressedParams, type MaybeSuppressedReturn, Plugin, type Suppress, type SuppressedAPIMethodParams, type SuppressedAPIMethodReturn, type SuppressedAPIMethods, TelegramError, Updates, type WebhookHandlers, webhookHandler };
package/dist/index.d.ts CHANGED
@@ -307,6 +307,9 @@ declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extends Deriv
307
307
  */
308
308
  onError<T extends UpdateName>(updateName: MaybeArray<T>, handler: Hooks.OnError<Errors, ContextType<Bot, T> & Derives["global"] & Derives[T]>): this;
309
309
  onError(handler: Hooks.OnError<Errors, Context<AnyBot> & Derives["global"]>): this;
310
+ /**
311
+ * ! ** At the moment, it can only pick up types** */
312
+ extend<NewPlugin extends AnyPlugin>(plugin: MaybePromise<NewPlugin>): Plugin<Errors & NewPlugin["_"]["Errors"], Derives & NewPlugin["_"]["Derives"]>;
310
313
  }
311
314
 
312
315
  /** Bot options that you can provide to {@link Bot} constructor */
@@ -576,7 +579,7 @@ declare class Updates {
576
579
  constructor(bot: AnyBot, onError: CaughtMiddlewareHandler<Context<any>>);
577
580
  handleUpdate(data: TelegramUpdate): Promise<unknown>;
578
581
  /** @deprecated use bot.start instead @internal */
579
- startPolling(params?: APIMethodParams<"getUpdates">): Promise<void>;
582
+ startPolling(params?: APIMethodParams<"getUpdates">): void;
580
583
  startFetchLoop(params?: APIMethodParams<"getUpdates">): Promise<void>;
581
584
  stopPolling(): void;
582
585
  }
@@ -595,14 +598,15 @@ declare class Updates {
595
598
  * ```
596
599
  */
597
600
  declare class Bot<Errors extends ErrorDefinitions = {}, Derives extends DeriveDefinitions = DeriveDefinitions> {
601
+ /** @deprecated use `~` instead*/
598
602
  _: {
599
- /** @internal. Remap generic */
603
+ /** @deprecated @internal. Remap generic */
600
604
  derives: Derives;
601
605
  };
602
- /** @internal. Remap generic */
606
+ /** @deprecated use `~.derives` instead @internal. Remap generic */
603
607
  __Derives: Derives;
604
608
  "~": {
605
- /** @internal. Remap generic */
609
+ /** @deprecated @internal. Remap generic */
606
610
  derives: Derives;
607
611
  };
608
612
  private filters;
@@ -1064,4 +1068,4 @@ declare function webhookHandler<Framework extends keyof typeof frameworks>(bot:
1064
1068
  response: () => any;
1065
1069
  } ? (...args: Parameters<(typeof frameworks)[Framework]>) => ReturnType<ReturnType<(typeof frameworks)[Framework]>["response"]> : (...args: Parameters<(typeof frameworks)[Framework]>) => void;
1066
1070
 
1067
- export { type AnyBot, type AnyPlugin, Bot, type BotOptions, Composer, type DeriveDefinitions, type ErrorDefinitions, ErrorKind, type FilterDefinitions, type Handler, Hooks, type MaybePromise, type MaybeSuppressedParams, Plugin, type Suppress, type SuppressedAPIMethodParams, type SuppressedAPIMethodReturn, type SuppressedAPIMethods, TelegramError, Updates, type WebhookHandlers, webhookHandler };
1071
+ export { type AnyBot, type AnyPlugin, Bot, type BotOptions, Composer, type DeriveDefinitions, type ErrorDefinitions, ErrorKind, type FilterDefinitions, type Handler, Hooks, type MaybePromise, type MaybeSuppressedParams, type MaybeSuppressedReturn, Plugin, type Suppress, type SuppressedAPIMethodParams, type SuppressedAPIMethodReturn, type SuppressedAPIMethods, TelegramError, Updates, type WebhookHandlers, webhookHandler };
package/dist/index.js CHANGED
@@ -308,12 +308,18 @@ class Plugin {
308
308
  }
309
309
  return this;
310
310
  }
311
+ /**
312
+ * ! ** At the moment, it can only pick up types** */
313
+ extend(plugin) {
314
+ return this;
315
+ }
311
316
  }
312
317
  _init$1 = __decoratorStart$1();
313
318
  Plugin = __decorateElement$1(_init$1, 0, "Plugin", _Plugin_decorators, Plugin);
314
319
  __runInitializers$1(_init$1, 1, Plugin);
315
320
 
316
321
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
322
+
317
323
  class UpdateQueue {
318
324
  updateQueue = [];
319
325
  pendingUpdates = /* @__PURE__ */ new Set();
@@ -400,7 +406,7 @@ class Updates {
400
406
  }
401
407
  }
402
408
  /** @deprecated use bot.start instead @internal */
403
- async startPolling(params = {}) {
409
+ startPolling(params = {}) {
404
410
  if (this.isStarted) throw new Error("[UPDATES] Polling already started!");
405
411
  this.isStarted = true;
406
412
  this.startFetchLoop(params);
@@ -470,11 +476,12 @@ _Bot_decorators = [Inspectable({
470
476
  serialize: () => ({})
471
477
  })];
472
478
  class Bot {
479
+ /** @deprecated use `~` instead*/
473
480
  _ = {
474
- /** @internal. Remap generic */
481
+ /** @deprecated @internal. Remap generic */
475
482
  derives: {}
476
483
  };
477
- /** @internal. Remap generic */
484
+ /** @deprecated use `~.derives` instead @internal. Remap generic */
478
485
  __Derives;
479
486
  "~" = this._;
480
487
  filters = {
@@ -568,7 +575,7 @@ class Bot {
568
575
  }
569
576
  async _callApi(method, params = {}) {
570
577
  const debug$api$method = debug$api.extend(method);
571
- const url = `${this.options.api.baseURL}${this.options.token}/${method}`;
578
+ const url = `${this.options.api.baseURL}${this.options.token}/${this.options.api.useTest ? "test/" : ""}${method}`;
572
579
  const reqOptions = {
573
580
  method: "POST",
574
581
  ...this.options.api.fetchOptions,
@@ -1099,8 +1106,9 @@ class Bot {
1099
1106
  if (!webhook) {
1100
1107
  await this.api.deleteWebhook({
1101
1108
  drop_pending_updates: dropPendingUpdates
1109
+ // suppress: true,
1102
1110
  });
1103
- await this.updates.startPolling({
1111
+ this.updates.startPolling({
1104
1112
  allowed_updates: allowedUpdates
1105
1113
  });
1106
1114
  this.runImmutableHooks("onStart", {
@@ -1116,6 +1124,7 @@ class Bot {
1116
1124
  ...webhook,
1117
1125
  drop_pending_updates: dropPendingUpdates,
1118
1126
  allowed_updates: allowedUpdates
1127
+ // suppress: true,
1119
1128
  });
1120
1129
  this.runImmutableHooks("onStart", {
1121
1130
  plugins: this.dependencies,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gramio",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.2.2",
5
5
  "description": "Powerful, extensible and really type-safe Telegram Bot API framework",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",
@@ -43,7 +43,7 @@
43
43
  "@biomejs/biome": "1.9.4",
44
44
  "@types/bun": "^1.1.14",
45
45
  "@types/debug": "^4.1.12",
46
- "pkgroll": "^2.5.1",
46
+ "pkgroll": "^2.6.0",
47
47
  "typescript": "^5.7.2"
48
48
  },
49
49
  "dependencies": {
@@ -51,8 +51,8 @@
51
51
  "@gramio/contexts": "^0.1.2",
52
52
  "@gramio/files": "^0.1.2",
53
53
  "@gramio/format": "^0.1.5",
54
- "@gramio/keyboards": "^1.0.2",
55
- "@gramio/types": "^8.1.0",
54
+ "@gramio/keyboards": "^1.1.0",
55
+ "@gramio/types": "^8.2.0",
56
56
  "debug": "^4.4.0",
57
57
  "inspectable": "^3.0.2",
58
58
  "middleware-io": "^2.8.1"