gramio 0.1.3 → 0.1.4

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
@@ -369,7 +369,9 @@ class Updates {
369
369
  }
370
370
  } catch (error) {
371
371
  console.error("Error received when fetching updates", error);
372
- await sleep(this.bot.options.api.retryGetUpdatesWait ?? 1e3);
372
+ if (error instanceof TelegramError && error.payload?.retry_after) {
373
+ await sleep(error.payload.retry_after * 1e3);
374
+ } else await sleep(this.bot.options.api.retryGetUpdatesWait ?? 1e3);
373
375
  }
374
376
  }
375
377
  }
@@ -821,6 +823,15 @@ class Bot {
821
823
  for (const handler of plugin._.groups) {
822
824
  this.group(handler);
823
825
  }
826
+ for (const value of plugin._.onErrors) {
827
+ this.onError(value);
828
+ }
829
+ for (const value of plugin._.onStarts) {
830
+ this.onStart(value);
831
+ }
832
+ for (const value of plugin._.onStops) {
833
+ this.onStop(value);
834
+ }
824
835
  this.dependencies.push(plugin._.name);
825
836
  return this;
826
837
  }
package/dist/index.js CHANGED
@@ -371,7 +371,9 @@ class Updates {
371
371
  }
372
372
  } catch (error) {
373
373
  console.error("Error received when fetching updates", error);
374
- await sleep(this.bot.options.api.retryGetUpdatesWait ?? 1e3);
374
+ if (error instanceof TelegramError && error.payload?.retry_after) {
375
+ await sleep(error.payload.retry_after * 1e3);
376
+ } else await sleep(this.bot.options.api.retryGetUpdatesWait ?? 1e3);
375
377
  }
376
378
  }
377
379
  }
@@ -823,6 +825,15 @@ class Bot {
823
825
  for (const handler of plugin._.groups) {
824
826
  this.group(handler);
825
827
  }
828
+ for (const value of plugin._.onErrors) {
829
+ this.onError(value);
830
+ }
831
+ for (const value of plugin._.onStarts) {
832
+ this.onStart(value);
833
+ }
834
+ for (const value of plugin._.onStops) {
835
+ this.onStop(value);
836
+ }
826
837
  this.dependencies.push(plugin._.name);
827
838
  return this;
828
839
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gramio",
3
3
  "type": "module",
4
- "version": "0.1.3",
4
+ "version": "0.1.4",
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",