gramio 0.6.1 → 0.6.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
@@ -678,16 +678,11 @@ class Bot {
678
678
  if (!params?.suppress) throw err;
679
679
  return err;
680
680
  }
681
- this.runImmutableHooks(
682
- "onResponse",
683
- // TODO: fix type error
684
- // @ts-expect-error
685
- {
686
- method,
687
- params,
688
- response: data.result
689
- }
690
- );
681
+ this.runImmutableHooks("onResponse", {
682
+ method,
683
+ params,
684
+ response: data.result
685
+ });
691
686
  return data.result;
692
687
  };
693
688
  if (!this.hooks.onApiCall.length) return executeCall();
@@ -843,10 +838,11 @@ class Bot {
843
838
  if (typeof methodsOrHandler === "string" || Array.isArray(methodsOrHandler)) {
844
839
  if (!handler) throw new Error("TODO:");
845
840
  const methods = typeof methodsOrHandler === "string" ? [methodsOrHandler] : methodsOrHandler;
846
- this.hooks.preRequest.push(async (context) => {
847
- if (methods.includes(context.method)) return handler(context);
841
+ this.hooks.preRequest.push((async (context) => {
842
+ if (methods.includes(context.method))
843
+ return handler(context);
848
844
  return context;
849
- });
845
+ }));
850
846
  } else this.hooks.preRequest.push(methodsOrHandler);
851
847
  return this;
852
848
  }
@@ -854,10 +850,10 @@ class Bot {
854
850
  if (typeof methodsOrHandler === "string" || Array.isArray(methodsOrHandler)) {
855
851
  if (!handler) throw new Error("TODO:");
856
852
  const methods = typeof methodsOrHandler === "string" ? [methodsOrHandler] : methodsOrHandler;
857
- this.hooks.onResponse.push(async (context) => {
858
- if (methods.includes(context.method)) return handler(context);
859
- return context;
860
- });
853
+ this.hooks.onResponse.push((async (context) => {
854
+ if (methods.includes(context.method))
855
+ return handler(context);
856
+ }));
861
857
  } else this.hooks.onResponse.push(methodsOrHandler);
862
858
  return this;
863
859
  }
@@ -865,21 +861,25 @@ class Bot {
865
861
  if (typeof methodsOrHandler === "string" || Array.isArray(methodsOrHandler)) {
866
862
  if (!handler) throw new Error("TODO:");
867
863
  const methods = typeof methodsOrHandler === "string" ? [methodsOrHandler] : methodsOrHandler;
868
- this.hooks.onResponseError.push(async (context) => {
869
- if (methods.includes(context.method)) return handler(context);
870
- return context;
871
- });
872
- } else this.hooks.onResponseError.push(methodsOrHandler);
864
+ this.hooks.onResponseError.push((async (context, api) => {
865
+ if (methods.includes(context.method))
866
+ return handler(context, api);
867
+ }));
868
+ } else
869
+ this.hooks.onResponseError.push(
870
+ methodsOrHandler
871
+ );
873
872
  return this;
874
873
  }
875
874
  onApiCall(methodsOrHandler, handler) {
876
875
  if (typeof methodsOrHandler === "string" || Array.isArray(methodsOrHandler)) {
877
876
  if (!handler) throw new Error("TODO:");
878
877
  const methods = typeof methodsOrHandler === "string" ? [methodsOrHandler] : methodsOrHandler;
879
- this.hooks.onApiCall.push(async (context, next) => {
880
- if (methods.includes(context.method)) return handler(context, next);
878
+ this.hooks.onApiCall.push((async (context, next) => {
879
+ if (methods.includes(context.method))
880
+ return handler(context, next);
881
881
  return next();
882
- });
882
+ }));
883
883
  } else {
884
884
  this.hooks.onApiCall.push(methodsOrHandler);
885
885
  }
package/dist/index.js CHANGED
@@ -680,16 +680,11 @@ class Bot {
680
680
  if (!params?.suppress) throw err;
681
681
  return err;
682
682
  }
683
- this.runImmutableHooks(
684
- "onResponse",
685
- // TODO: fix type error
686
- // @ts-expect-error
687
- {
688
- method,
689
- params,
690
- response: data.result
691
- }
692
- );
683
+ this.runImmutableHooks("onResponse", {
684
+ method,
685
+ params,
686
+ response: data.result
687
+ });
693
688
  return data.result;
694
689
  };
695
690
  if (!this.hooks.onApiCall.length) return executeCall();
@@ -845,10 +840,11 @@ class Bot {
845
840
  if (typeof methodsOrHandler === "string" || Array.isArray(methodsOrHandler)) {
846
841
  if (!handler) throw new Error("TODO:");
847
842
  const methods = typeof methodsOrHandler === "string" ? [methodsOrHandler] : methodsOrHandler;
848
- this.hooks.preRequest.push(async (context) => {
849
- if (methods.includes(context.method)) return handler(context);
843
+ this.hooks.preRequest.push((async (context) => {
844
+ if (methods.includes(context.method))
845
+ return handler(context);
850
846
  return context;
851
- });
847
+ }));
852
848
  } else this.hooks.preRequest.push(methodsOrHandler);
853
849
  return this;
854
850
  }
@@ -856,10 +852,10 @@ class Bot {
856
852
  if (typeof methodsOrHandler === "string" || Array.isArray(methodsOrHandler)) {
857
853
  if (!handler) throw new Error("TODO:");
858
854
  const methods = typeof methodsOrHandler === "string" ? [methodsOrHandler] : methodsOrHandler;
859
- this.hooks.onResponse.push(async (context) => {
860
- if (methods.includes(context.method)) return handler(context);
861
- return context;
862
- });
855
+ this.hooks.onResponse.push((async (context) => {
856
+ if (methods.includes(context.method))
857
+ return handler(context);
858
+ }));
863
859
  } else this.hooks.onResponse.push(methodsOrHandler);
864
860
  return this;
865
861
  }
@@ -867,21 +863,25 @@ class Bot {
867
863
  if (typeof methodsOrHandler === "string" || Array.isArray(methodsOrHandler)) {
868
864
  if (!handler) throw new Error("TODO:");
869
865
  const methods = typeof methodsOrHandler === "string" ? [methodsOrHandler] : methodsOrHandler;
870
- this.hooks.onResponseError.push(async (context) => {
871
- if (methods.includes(context.method)) return handler(context);
872
- return context;
873
- });
874
- } else this.hooks.onResponseError.push(methodsOrHandler);
866
+ this.hooks.onResponseError.push((async (context, api) => {
867
+ if (methods.includes(context.method))
868
+ return handler(context, api);
869
+ }));
870
+ } else
871
+ this.hooks.onResponseError.push(
872
+ methodsOrHandler
873
+ );
875
874
  return this;
876
875
  }
877
876
  onApiCall(methodsOrHandler, handler) {
878
877
  if (typeof methodsOrHandler === "string" || Array.isArray(methodsOrHandler)) {
879
878
  if (!handler) throw new Error("TODO:");
880
879
  const methods = typeof methodsOrHandler === "string" ? [methodsOrHandler] : methodsOrHandler;
881
- this.hooks.onApiCall.push(async (context, next) => {
882
- if (methods.includes(context.method)) return handler(context, next);
880
+ this.hooks.onApiCall.push((async (context, next) => {
881
+ if (methods.includes(context.method))
882
+ return handler(context, next);
883
883
  return next();
884
- });
884
+ }));
885
885
  } else {
886
886
  this.hooks.onApiCall.push(methodsOrHandler);
887
887
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gramio",
3
3
  "type": "module",
4
- "version": "0.6.1",
4
+ "version": "0.6.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",
@@ -67,7 +67,7 @@
67
67
  "@gramio/callback-data": "^0.1.0",
68
68
  "@gramio/composer": "^0.3.3",
69
69
  "@gramio/contexts": "^0.4.0",
70
- "@gramio/files": "^0.3.0",
70
+ "@gramio/files": "^0.3.1",
71
71
  "@gramio/format": "^0.4.0",
72
72
  "@gramio/keyboards": "^1.3.0",
73
73
  "@gramio/types": "^9.4.2",