@2byte/tgbot-framework 1.0.12 → 1.0.14

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.
Files changed (60) hide show
  1. package/README.md +300 -300
  2. package/bin/2byte-cli.ts +97 -97
  3. package/package.json +55 -55
  4. package/src/cli/CreateBotCommand.ts +181 -181
  5. package/src/cli/GenerateCommand.ts +195 -195
  6. package/src/cli/InitCommand.ts +107 -107
  7. package/src/cli/TgAccountManager.ts +50 -50
  8. package/src/console/migrate.ts +82 -82
  9. package/src/core/ApiService.ts +28 -20
  10. package/src/core/ApiServiceManager.ts +79 -63
  11. package/src/core/App.ts +1340 -1178
  12. package/src/core/BotArtisan.ts +79 -79
  13. package/src/core/BotMigration.ts +30 -30
  14. package/src/core/BotSeeder.ts +66 -66
  15. package/src/core/Model.ts +84 -84
  16. package/src/core/utils.ts +2 -2
  17. package/src/illumination/Artisan.ts +149 -149
  18. package/src/illumination/InlineKeyboard.ts +79 -79
  19. package/src/illumination/Message2Byte.ts +256 -256
  20. package/src/illumination/Message2ByteLiveProgressive.ts +278 -278
  21. package/src/illumination/Message2bytePool.ts +113 -113
  22. package/src/illumination/Migration.ts +186 -186
  23. package/src/illumination/RunSectionRoute.ts +109 -95
  24. package/src/illumination/Section.ts +429 -420
  25. package/src/illumination/SectionComponent.ts +64 -64
  26. package/src/illumination/Telegraf2byteContext.ts +32 -32
  27. package/src/index.ts +43 -42
  28. package/src/libs/TelegramAccountControl.ts +1140 -1140
  29. package/src/libs/TgSender.ts +53 -53
  30. package/src/models/Model.ts +67 -67
  31. package/src/models/Proxy.ts +217 -217
  32. package/src/models/TgAccount.ts +362 -362
  33. package/src/models/index.ts +2 -2
  34. package/src/types.ts +200 -191
  35. package/src/user/UserModel.ts +297 -297
  36. package/src/user/UserStore.ts +119 -119
  37. package/src/workflow/services/MassSendApiService.ts +94 -83
  38. package/templates/bot/.env.example +33 -33
  39. package/templates/bot/artisan.ts +8 -8
  40. package/templates/bot/bot.ts +82 -82
  41. package/templates/bot/database/dbConnector.ts +4 -4
  42. package/templates/bot/database/migrate.ts +9 -9
  43. package/templates/bot/database/migrations/001_create_users.sql +18 -18
  44. package/templates/bot/database/migrations/007_proxy.sql +27 -27
  45. package/templates/bot/database/migrations/008_tg_accounts.sql +32 -32
  46. package/templates/bot/database/seed.ts +14 -14
  47. package/templates/bot/docs/CLI_SERVICES.md +536 -536
  48. package/templates/bot/docs/INPUT_SYSTEM.md +211 -211
  49. package/templates/bot/docs/MASS_SEND_SERVICE.md +327 -327
  50. package/templates/bot/docs/SERVICE_EXAMPLES.md +384 -384
  51. package/templates/bot/docs/TASK_SYSTEM.md +156 -156
  52. package/templates/bot/models/Model.ts +8 -8
  53. package/templates/bot/models/index.ts +1 -1
  54. package/templates/bot/package.json +30 -30
  55. package/templates/bot/sectionList.ts +9 -9
  56. package/templates/bot/sections/ExampleInputSection.ts +85 -85
  57. package/templates/bot/sections/ExampleLiveTaskerSection.ts +60 -60
  58. package/templates/bot/sections/HomeSection.ts +63 -63
  59. package/templates/bot/tsconfig.json +16 -16
  60. package/templates/bot/workflow/services/ExampleService.ts +23 -23
@@ -1,95 +1,109 @@
1
- import { RunSectionRouteParams } from '../types';
2
-
3
- export class RunSectionRoute {
4
- private runParams: RunSectionRouteParams = {
5
- section: null,
6
- method: null,
7
- methodArgs: null,
8
- callbackParams: new URLSearchParams(),
9
- runAsCallbackQuery: false,
10
- actionPath: null,
11
- hearsKey: null,
12
- };
13
-
14
- constructor() {}
15
-
16
- section(sectionId: string): this {
17
- this.runParams.section = sectionId;
18
- return this;
19
- }
20
-
21
- method(name: string = 'index', isRunCallbackQuery: boolean = false): this {
22
- this.runParams.method = name;
23
- this.runParams.runAsCallbackQuery = isRunCallbackQuery;
24
- return this;
25
- }
26
-
27
- methodArgs(args: any[] | null): this {
28
- this.runParams.methodArgs = args;
29
- return this;
30
- }
31
-
32
- callbackParams(actionPath: string, params: string | Record<string, string>): this {
33
- this.runParams.callbackParams = new URLSearchParams(params);
34
- this.actionPath(actionPath);
35
- this.runParams.runAsCallbackQuery = true;
36
- return this;
37
- }
38
-
39
- actionPath(path: string): this {
40
- this.runParams.actionPath = path;
41
- this.runParams.runAsCallbackQuery = true;
42
- return this;
43
- }
44
-
45
- hearsKey(key: string): this {
46
- this.runParams.hearsKey = key;
47
- return this;
48
- }
49
-
50
- runAsCommand(flag: boolean = true): this {
51
- this.runParams.runAsCallbackQuery = !flag;
52
- return this;
53
- }
54
-
55
- runAsCallbackQuery(flag: boolean = true): this {
56
- this.runParams.runAsCallbackQuery = flag;
57
- return this;
58
- }
59
-
60
- getMethod(): string | null {
61
- return this.runParams.method;
62
- }
63
-
64
- getSection(): string | null {
65
- return this.runParams.section;
66
- }
67
-
68
- getSectionId(): string | null {
69
- return this.runParams.section;
70
- }
71
-
72
- getCommand(): string | null {
73
- return this.runParams.method;
74
- }
75
-
76
- getSubCommand(): string | null {
77
- return this.runParams.method;
78
- }
79
-
80
- getActionPath(): string | null {
81
- return this.runParams.actionPath;
82
- }
83
-
84
- getCallbackParams(): URLSearchParams {
85
- return this.runParams.callbackParams;
86
- }
87
-
88
- getHearsKey(): string | null {
89
- return this.runParams.hearsKey;
90
- }
91
-
92
- get runIsCallbackQuery(): boolean {
93
- return this.runParams.runAsCallbackQuery;
94
- }
95
- }
1
+ import type { RunSectionRouteParams, RunSectionRouteTrigger } from '../types';
2
+
3
+ export class RunSectionRoute {
4
+ private runParams: RunSectionRouteParams = {
5
+ section: null,
6
+ method: null,
7
+ methodArgs: null,
8
+ callbackParams: new URLSearchParams(),
9
+ runAsCallbackQuery: false,
10
+ actionPath: null,
11
+ hearsKey: null,
12
+ triggers: [],
13
+ };
14
+
15
+ constructor() {}
16
+
17
+ section(sectionId: string): this {
18
+ this.runParams.section = sectionId;
19
+ return this;
20
+ }
21
+
22
+ method(name: string = 'index', isRunCallbackQuery: boolean = false): this {
23
+ this.runParams.method = name;
24
+ this.runParams.runAsCallbackQuery = isRunCallbackQuery;
25
+ return this;
26
+ }
27
+
28
+ methodArgs(args: any[] | null): this {
29
+ this.runParams.methodArgs = args;
30
+ return this;
31
+ }
32
+
33
+ callbackParams(actionPath: string, params: string | Record<string, string>): this {
34
+ this.runParams.callbackParams = new URLSearchParams(params);
35
+ this.actionPath(actionPath);
36
+ this.runParams.runAsCallbackQuery = true;
37
+ return this;
38
+ }
39
+
40
+ actionPath(path: string): this {
41
+ this.runParams.actionPath = path;
42
+ this.runParams.runAsCallbackQuery = true;
43
+ return this;
44
+ }
45
+
46
+ hearsKey(key: string): this {
47
+ this.runParams.hearsKey = key;
48
+ return this;
49
+ }
50
+
51
+ runAsCommand(flag: boolean = true): this {
52
+ this.runParams.runAsCallbackQuery = !flag;
53
+ return this;
54
+ }
55
+
56
+ runAsCallbackQuery(flag: boolean = true): this {
57
+ this.runParams.runAsCallbackQuery = flag;
58
+ return this;
59
+ }
60
+
61
+ trigger(trigger: RunSectionRouteTrigger): this {
62
+ this.runParams.triggers.push(trigger);
63
+ return this;
64
+ }
65
+
66
+ hasTriggers(): boolean {
67
+ return this.runParams.triggers.length > 0;
68
+ }
69
+
70
+ getTriggers(): RunSectionRouteTrigger[] {
71
+ return this.runParams.triggers;
72
+ }
73
+
74
+ getMethod(): string | null {
75
+ return this.runParams.method;
76
+ }
77
+
78
+ getSection(): string | null {
79
+ return this.runParams.section;
80
+ }
81
+
82
+ getSectionId(): string | null {
83
+ return this.runParams.section;
84
+ }
85
+
86
+ getCommand(): string | null {
87
+ return this.runParams.method;
88
+ }
89
+
90
+ getSubCommand(): string | null {
91
+ return this.runParams.method;
92
+ }
93
+
94
+ getActionPath(): string | null {
95
+ return this.runParams.actionPath;
96
+ }
97
+
98
+ getCallbackParams(): URLSearchParams {
99
+ return this.runParams.callbackParams;
100
+ }
101
+
102
+ getHearsKey(): string | null {
103
+ return this.runParams.hearsKey;
104
+ }
105
+
106
+ get runIsCallbackQuery(): boolean {
107
+ return this.runParams.runAsCallbackQuery;
108
+ }
109
+ }