@codebam/cf-workers-telegram-bot 5.0.0 → 5.2.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.
@@ -6,7 +6,7 @@ export default class Handler {
6
6
  this.configs = configs;
7
7
  }
8
8
  getResponse = async (_request, _bot) => {
9
- this.getAccessKeys(this.configs).then((access_keys) => Object.keys(access_keys).forEach((key) => log(`${access_keys[key].bot_name} ${((request_url) => `${request_url.origin}${request_url.pathname}`)(new URL(_request?.url ?? localhost))}/${key}`)));
9
+ this.getAccessKeys(this.configs).then((access_keys) => Object.keys(access_keys).forEach((key) => log(`${access_keys[key].bot_name} ${((request_url) => `${request_url.origin}${request_url.pathname}`)(new URL(_request?.url ?? localhost))}${key}`)));
10
10
  if (_bot?.webhook.token) {
11
11
  return _bot.webhook.process(new URL(_request?.url ?? localhost));
12
12
  }
@@ -32,11 +32,16 @@ export default class Handler {
32
32
  ]))).then((result) => Object.fromEntries(result));
33
33
  // handles the request
34
34
  handle = async (request) => this.getAccessKeys(this.configs).then((access_keys) => Object.keys(this.responses).includes(request.method)
35
- ? this.responses[request.method](request, new access_keys[new URL(request.url).pathname.substring(1)].api({
36
- ...new Config(),
37
- url: new URL(new URL(request.url).origin),
38
- handler: this,
39
- ...access_keys[new URL(request.url).pathname.substring(1)],
40
- }))
35
+ ? this.responses[request.method](request, ((key) => {
36
+ if (access_keys[key]) {
37
+ return new access_keys[key].api({
38
+ ...new Config(),
39
+ url: new URL(new URL(request.url).origin),
40
+ handler: this,
41
+ ...access_keys[key],
42
+ });
43
+ }
44
+ return this.responses.default();
45
+ })(new URL(request.url).pathname.substring(1)))
41
46
  : this.responses.default());
42
47
  }
@@ -32,7 +32,7 @@ export default class TelegramApi extends BotApi {
32
32
  ? this.commands[command]?.(this, update, [...text_args, ...args])
33
33
  : log({
34
34
  error: `command '${command}' does not exist`,
35
- }))(
35
+ }) && this.updates.default)(
36
36
  // run the command
37
37
  this.getCommand(text_args)))(
38
38
  // get the command to run
@@ -51,5 +51,5 @@ export default {
51
51
  "/start": TelegramCommands.commandList,
52
52
  },
53
53
  },
54
- ]).handle(request).then(() => new Response()),
54
+ ]).handle(request),
55
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebam/cf-workers-telegram-bot",
3
- "version": "5.0.0",
3
+ "version": "5.2.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",
@@ -29,14 +29,14 @@
29
29
  "url": "https://github.com/codebam/cf-workers-telegram-bot.git"
30
30
  },
31
31
  "devDependencies": {
32
- "@cloudflare/workers-types": "^4.20230518.0",
33
- "@typescript-eslint/eslint-plugin": "^5.60.1",
34
- "@typescript-eslint/parser": "^5.60.1",
35
- "eslint": "^8.43.0",
36
- "eslint-config-prettier": "^8.8.0",
37
- "lerna": "^7.1.1",
38
- "prettier": "^2.8.8",
32
+ "@cloudflare/workers-types": "^4.20230807.0",
33
+ "@typescript-eslint/eslint-plugin": "^6.3.0",
34
+ "@typescript-eslint/parser": "^6.3.0",
35
+ "eslint": "^8.47.0",
36
+ "eslint-config-prettier": "^9.0.0",
37
+ "lerna": "^7.1.5",
38
+ "prettier": "^3.0.1",
39
39
  "typescript": "^5.1.6"
40
40
  },
41
- "gitHead": "31844c441558aebfb5308232d97eb53940d211f5"
41
+ "gitHead": "18c40115f1a31c1863f41ccbf8723f155947d739"
42
42
  }