chz-telegram-bot 0.7.10 → 0.7.12

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/main.d.ts CHANGED
@@ -15,8 +15,8 @@ declare class BotOrchestrator {
15
15
  startBot(options: {
16
16
  /** Bot name, used in logging */
17
17
  name: string;
18
- /** Path to file containing Telegram Bot token. */
19
- tokenFilePath: string;
18
+ /** Function that provides the bot token. */
19
+ tokenProvider: () => Promise<string>;
20
20
  actions: {
21
21
  /** Collection of actions that will be executed as a response to message from used. Created using `CommandActionBuilder`.*/
22
22
  commands: CommandAction<IActionState>[];
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,cAAM,eAAe;IACjB,IAAI,EAAE,WAAW,EAAE,CAAM;IAEzB;;OAEG;IACG,QAAQ,CAAC,OAAO,EAAE;QACpB,gCAAgC;QAChC,IAAI,EAAE,MAAM,CAAC;QACb,kDAAkD;QAClD,aAAa,EAAE,MAAM,CAAC;QACtB,OAAO,EAAE;YACL,2HAA2H;YAC3H,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,EAAE,CAAC;YACxC,mGAAmG;YACnG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AO,EAAE;QACpB,gCAAgC;QAChC,IAAI,EAAE,MAAM,CAAC;QACb,4CAA4C;QAC5C,aAAa,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;QACrC,OAAO,EAAE;YACL,2HAA2H;YAC3H,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,EAAE,CAAC;YACxC,mGAAmG;YACnG,SAAS,EAAE,eAAe,CAAC,YAAY,CAAC,EAAE,CAAC;YAC3C,4DAA4D;YAC5D,aAAa,EAAE,iBAAiB,EAAE,CAAC;SACtC,CAAC;QACF,yGAAyG;QACzG,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC9B,2KAA2K;QAC3K,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,6DAA6D;QAC7D,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,QAAQ,CAAC,EAAE;YACP,qGAAqG;YACrG,aAAa,CAAC,EAAE,cAAc,CAAC;YAC/B,yGAAyG;YACzG,SAAS,CAAC,EAAE,UAAU,CAAC;YACvB,qKAAqK;YACrK,YAAY,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;SAC7D,CAAC;KACL;IAsBD;;OAEG;IACG,QAAQ;CAKjB;AAED,eAAO,MAAM,eAAe,iBAAwB,CAAC"}
package/dist/main.js CHANGED
@@ -1,4 +1,3 @@
1
- import { readFile } from 'fs/promises';
2
1
  import { BotInstance } from './entities/botInstance';
3
2
  class BotOrchestrator {
4
3
  bots = [];
@@ -6,7 +5,7 @@ class BotOrchestrator {
6
5
  * Starts bot
7
6
  */
8
7
  async startBot(options) {
9
- const token = await readFile(options.tokenFilePath, 'utf8');
8
+ const token = await options.tokenProvider();
10
9
  const bot = new BotInstance({
11
10
  name: options.name,
12
11
  actions: options.actions,
package/eslint.config.ts CHANGED
@@ -1,8 +1,14 @@
1
+ /// <reference types="node" />
1
2
  import eslint from '@eslint/js';
2
3
  import tseslint from 'typescript-eslint';
3
4
  import parser from '@typescript-eslint/parser';
5
+ import { defineConfig } from 'eslint/config';
6
+ import { fileURLToPath } from 'node:url';
7
+ import { dirname } from 'node:path';
4
8
 
5
- export default tseslint.config(
9
+ const __dirname = dirname(fileURLToPath(import.meta.url));
10
+
11
+ export default defineConfig(
6
12
  {
7
13
  ignores: ['dist/**', 'eslint.config.ts']
8
14
  },
package/package.json CHANGED
@@ -1,40 +1,41 @@
1
- {
2
- "name": "chz-telegram-bot",
3
- "description": "Opinionated TypeScript framework that provides a structured approach to building Telegram bots.",
4
- "author": {
5
- "name": "Alex Halanin",
6
- "url": "https://github.com/AlexSolari"
7
- },
8
- "license": "MIT",
9
- "keywords": [
10
- "telegram",
11
- "telegram bot"
12
- ],
13
- "repository": {
14
- "type": "git",
15
- "url": "https://github.com/AlexSolari/botFramework.git"
16
- },
17
- "version": "0.7.10",
18
- "type": "module",
19
- "dependencies": {
20
- "async-sema": "^3.1.1",
21
- "moment": "^2.29.4",
22
- "telegraf": "^4.16.3"
23
- },
24
- "main": "dist/index.js",
25
- "types": "dist/index.d.ts",
26
- "devDependencies": {
27
- "@eslint/js": "^9.29.0",
28
- "@types/bun": "^1.3.7",
29
- "@types/node": "^22.5.5",
30
- "eslint": "^9.29.0",
31
- "jiti": "^2.6.1",
32
- "typescript": "^5.9.0-beta",
33
- "typescript-eslint": "^8.34.1"
34
- },
35
- "scripts": {
36
- "build": "tsc -p tsconfig.build.json",
37
- "test": "bun test",
38
- "lint": "npx eslint && tsc --noEmit"
39
- }
40
- }
1
+ {
2
+ "name": "chz-telegram-bot",
3
+ "description": "Opinionated TypeScript framework that provides a structured approach to building Telegram bots.",
4
+ "author": {
5
+ "name": "Alex Halanin",
6
+ "url": "https://github.com/AlexSolari"
7
+ },
8
+ "license": "MIT",
9
+ "keywords": [
10
+ "telegram",
11
+ "telegram bot"
12
+ ],
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/AlexSolari/botFramework.git"
16
+ },
17
+ "version": "0.7.12",
18
+ "type": "module",
19
+ "dependencies": {
20
+ "async-sema": "^3.1.1",
21
+ "moment": "^2.30.1",
22
+ "telegraf": "^4.16.3"
23
+ },
24
+ "main": "dist/index.js",
25
+ "types": "dist/index.d.ts",
26
+ "devDependencies": {
27
+ "@eslint/js": "^9.39.4",
28
+ "@types/bun": "^1.3.11",
29
+ "@types/node": "^22.19.15",
30
+ "eslint": "^9.39.4",
31
+ "jiti": "^2.6.1",
32
+ "typescript": "^6.0.2",
33
+ "typescript-eslint": "^8.58.0"
34
+ },
35
+ "scripts": {
36
+ "build": "tsc -p tsconfig.build.json",
37
+ "test": "bun test",
38
+ "lint": "eslint src && tsc -p tsconfig.build.json --noEmit",
39
+ "prep": "bun run lint && bun run test && bun run build"
40
+ }
41
+ }
package/src/main.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { readFile } from 'fs/promises';
2
1
  import { IStorageClient } from './types/storage';
3
2
  import { CommandAction } from './entities/actions/commandAction';
4
3
  import { ScheduledAction } from './entities/actions/scheduledAction';
@@ -18,8 +17,8 @@ class BotOrchestrator {
18
17
  async startBot(options: {
19
18
  /** Bot name, used in logging */
20
19
  name: string;
21
- /** Path to file containing Telegram Bot token. */
22
- tokenFilePath: string;
20
+ /** Function that provides the bot token. */
21
+ tokenProvider: () => Promise<string>;
23
22
  actions: {
24
23
  /** Collection of actions that will be executed as a response to message from used. Created using `CommandActionBuilder`.*/
25
24
  commands: CommandAction<IActionState>[];
@@ -43,7 +42,7 @@ class BotOrchestrator {
43
42
  eventEmitter?: TypedEventEmitter<Record<string, unknown>>;
44
43
  };
45
44
  }) {
46
- const token = await readFile(options.tokenFilePath, 'utf8');
45
+ const token = await options.tokenProvider();
47
46
 
48
47
  const bot = new BotInstance({
49
48
  name: options.name,
@@ -58,6 +57,7 @@ class BotOrchestrator {
58
57
  });
59
58
 
60
59
  await bot.start(token, options.actions, options.scheduledPeriod);
60
+
61
61
  this.bots.push(bot);
62
62
 
63
63
  return bot;