gramio 0.6.1 → 0.7.0
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/README.md +1 -1
- package/dist/index.cjs +25 -25
- package/dist/index.js +25 -25
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
[](https://core.telegram.org/bots/api)
|
|
6
6
|
[](https://www.npmjs.org/package/gramio)
|
|
7
7
|
[](https://www.npmjs.org/package/gramio)
|
|
8
8
|
[](https://jsr.io/@gramio/core)
|
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
|
-
|
|
683
|
-
|
|
684
|
-
|
|
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))
|
|
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))
|
|
859
|
-
|
|
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))
|
|
870
|
-
|
|
871
|
-
});
|
|
872
|
-
} else
|
|
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))
|
|
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
|
-
|
|
685
|
-
|
|
686
|
-
|
|
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))
|
|
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))
|
|
861
|
-
|
|
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))
|
|
872
|
-
|
|
873
|
-
});
|
|
874
|
-
} else
|
|
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))
|
|
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.
|
|
4
|
+
"version": "0.7.0",
|
|
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",
|
|
@@ -66,11 +66,11 @@
|
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@gramio/callback-data": "^0.1.0",
|
|
68
68
|
"@gramio/composer": "^0.3.3",
|
|
69
|
-
"@gramio/contexts": "^0.
|
|
70
|
-
"@gramio/files": "^0.3.
|
|
71
|
-
"@gramio/format": "^0.
|
|
72
|
-
"@gramio/keyboards": "^1.3.
|
|
73
|
-
"@gramio/types": "^9.
|
|
69
|
+
"@gramio/contexts": "^0.5.0",
|
|
70
|
+
"@gramio/files": "^0.3.2",
|
|
71
|
+
"@gramio/format": "^0.5.0",
|
|
72
|
+
"@gramio/keyboards": "^1.3.1",
|
|
73
|
+
"@gramio/types": "^9.5.0",
|
|
74
74
|
"debug": "^4.4.3"
|
|
75
75
|
},
|
|
76
76
|
"files": [
|