@codebam/cf-workers-telegram-bot 4.10.0 → 4.11.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.
|
@@ -8,5 +8,6 @@ export default class Handler {
|
|
|
8
8
|
postResponse: (_request?: Request, _bot?: BotApi) => Promise<Response>;
|
|
9
9
|
responses: Record<string, (_request?: Request, _bot?: BotApi) => Promise<Response>>;
|
|
10
10
|
getAccessKeys: (configs: PartialConfig[]) => Promise<Record<string, any> | Record<string, never>>;
|
|
11
|
+
check_undefined: (x: any) => any;
|
|
11
12
|
handle: (request: Request) => Promise<Response>;
|
|
12
13
|
}
|
package/dist/main/src/handler.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import BotApi from "./bot_api";
|
|
1
2
|
import { sha256, log } from "./libs";
|
|
2
|
-
import { Config, localhost } from "./types";
|
|
3
|
+
import { Webhook, Config, localhost, } from "./types";
|
|
3
4
|
export default class Handler {
|
|
4
5
|
configs;
|
|
5
6
|
constructor(configs) {
|
|
@@ -30,9 +31,24 @@ export default class Handler {
|
|
|
30
31
|
hash,
|
|
31
32
|
bot_config,
|
|
32
33
|
]))).then((result) => Object.fromEntries(result));
|
|
34
|
+
// check
|
|
35
|
+
check_undefined = (x) => {
|
|
36
|
+
if (x === undefined) {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
return x;
|
|
40
|
+
};
|
|
33
41
|
// handles the request
|
|
34
42
|
handle = async (request) => this.getAccessKeys(this.configs).then((access_keys) => Object.keys(this.responses).includes(request.method)
|
|
35
|
-
? this.responses[request.method](request,
|
|
43
|
+
? this.responses[request.method](request, ((access_keys) => {
|
|
44
|
+
if (access_keys[new URL(request.url).pathname.substring(1)] ===
|
|
45
|
+
undefined) {
|
|
46
|
+
return () => {
|
|
47
|
+
return new BotApi({}, new Webhook(new URL("https://seanbehan.ca"), "", new URL("https://seanbehan.ca")), new Handler([]));
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return access_keys[new URL(request.url).pathname.substring(1)];
|
|
51
|
+
})(access_keys)({
|
|
36
52
|
...new Config(),
|
|
37
53
|
url: new URL(new URL(request.url).origin),
|
|
38
54
|
handler: this,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codebam/cf-workers-telegram-bot",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.11.0",
|
|
4
4
|
"description": "serverless telegram bot on cf workers",
|
|
5
5
|
"main": "./dist/main/src/main.js",
|
|
6
6
|
"module": "./dist/main/src/main.js",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"@cloudflare/workers-types": "^4.20230518.0",
|
|
33
33
|
"@typescript-eslint/eslint-plugin": "^5.60.1",
|
|
34
34
|
"@typescript-eslint/parser": "^5.60.1",
|
|
35
|
-
"eslint": "^8.
|
|
35
|
+
"eslint": "^8.44.0",
|
|
36
36
|
"eslint-config-prettier": "^8.8.0",
|
|
37
37
|
"lerna": "^7.1.1",
|
|
38
38
|
"prettier": "^2.8.8",
|
|
39
39
|
"typescript": "^5.1.6"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "359ffdca6d9b22b0f80d2cdd691471348feda8f0"
|
|
42
42
|
}
|