@codebam/cf-workers-telegram-bot 5.1.0 → 5.4.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.
@@ -1,12 +1,12 @@
1
1
  /// <reference types="@cloudflare/workers-types" />
2
2
  import BotApi from "./bot_api";
3
- import { PartialConfig } from "./types";
3
+ import { Config } from "./types";
4
4
  export default class Handler {
5
- configs: PartialConfig[];
6
- constructor(configs: PartialConfig[]);
5
+ configs: Partial<Config>[];
6
+ constructor(configs: Partial<Config>[]);
7
7
  getResponse: (_request?: Request, _bot?: BotApi) => Promise<Response>;
8
8
  postResponse: (_request?: Request, _bot?: BotApi) => Promise<Response>;
9
9
  responses: Record<string, (_request?: Request, _bot?: BotApi) => Promise<Response>>;
10
- getAccessKeys: (configs: PartialConfig[]) => Promise<Record<string, any> | Record<string, never>>;
10
+ getAccessKeys: (configs: Partial<Config>[]) => Promise<Record<string, Config> | Record<string, never>>;
11
11
  handle: (request: Request) => Promise<Response>;
12
12
  }
@@ -24,9 +24,7 @@ export default class Handler {
24
24
  POST: this.postResponse,
25
25
  default: () => new Promise(() => new Response()),
26
26
  };
27
- getAccessKeys = async (configs
28
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
- ) => Promise.all(configs.map((bot_config) => sha256(bot_config.webhook?.token ?? "").then((hash) => [
27
+ getAccessKeys = async (configs) => Promise.all(configs.map((bot_config) => sha256(bot_config.webhook?.token ?? "").then((hash) => [
30
28
  hash,
31
29
  bot_config,
32
30
  ]))).then((result) => Object.fromEntries(result));
@@ -36,9 +34,9 @@ export default class Handler {
36
34
  if (access_keys[key]) {
37
35
  return new access_keys[key].api({
38
36
  ...new Config(),
37
+ ...access_keys[key],
39
38
  url: new URL(new URL(request.url).origin),
40
39
  handler: this,
41
- ...access_keys[key],
42
40
  });
43
41
  }
44
42
  return this.responses.default();
@@ -10,23 +10,14 @@ export type Commands = Record<string, Command>;
10
10
  export type Kv = Record<string, KVNamespace> | undefined;
11
11
  export declare class Config {
12
12
  bot_name: string;
13
- api: object;
13
+ api: any;
14
14
  webhook: Webhook;
15
15
  commands: Record<string, Command>;
16
16
  kv: Kv | undefined;
17
17
  url: URL;
18
18
  handler: Handler | undefined;
19
- constructor(config?: PartialConfig);
19
+ constructor(config?: Partial<Config>);
20
20
  }
21
- export type PartialConfig = {
22
- bot_name?: string;
23
- api?: object;
24
- webhook?: Webhook;
25
- commands?: Record<string, Command>;
26
- kv?: Kv | undefined;
27
- url?: URL;
28
- handler?: Handler;
29
- };
30
21
  export declare const localhost: URL;
31
22
  export declare class WebhookCommands {
32
23
  [key: string]: () => Promise<Response>;
@@ -2,6 +2,7 @@ import Webhook from "./webhook";
2
2
  export { Webhook };
3
3
  export class Config {
4
4
  bot_name;
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
6
  api;
6
7
  webhook;
7
8
  commands;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebam/cf-workers-telegram-bot",
3
- "version": "5.1.0",
3
+ "version": "5.4.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": "a36c722da3898a8fb1c13d9c60527b6355fcdfe1"
41
+ "gitHead": "57bc0ace0c6d210423af08b17dcd02693e12b8e5"
42
42
  }