@2byte/tgbot-framework 1.0.11 → 1.0.13
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/README.md +300 -300
- package/bin/2byte-cli.ts +97 -97
- package/package.json +55 -55
- package/src/cli/CreateBotCommand.ts +181 -181
- package/src/cli/GenerateCommand.ts +195 -195
- package/src/cli/InitCommand.ts +107 -107
- package/src/cli/TgAccountManager.ts +50 -50
- package/src/console/migrate.ts +82 -82
- package/src/core/ApiService.ts +20 -20
- package/src/core/ApiServiceManager.ts +63 -63
- package/src/core/App.ts +1242 -1178
- package/src/core/BotArtisan.ts +79 -79
- package/src/core/BotMigration.ts +30 -30
- package/src/core/BotSeeder.ts +66 -66
- package/src/core/Model.ts +84 -84
- package/src/core/utils.ts +2 -2
- package/src/illumination/Artisan.ts +149 -149
- package/src/illumination/InlineKeyboard.ts +79 -61
- package/src/illumination/Message2Byte.ts +256 -256
- package/src/illumination/Message2ByteLiveProgressive.ts +278 -278
- package/src/illumination/Message2bytePool.ts +113 -113
- package/src/illumination/Migration.ts +186 -186
- package/src/illumination/RunSectionRoute.ts +109 -95
- package/src/illumination/Section.ts +429 -420
- package/src/illumination/SectionComponent.ts +64 -64
- package/src/illumination/Telegraf2byteContext.ts +32 -32
- package/src/index.ts +42 -42
- package/src/libs/TelegramAccountControl.ts +1140 -1140
- package/src/libs/TgSender.ts +53 -53
- package/src/models/Model.ts +67 -67
- package/src/models/Proxy.ts +217 -217
- package/src/models/TgAccount.ts +362 -362
- package/src/models/index.ts +2 -2
- package/src/types.ts +198 -191
- package/src/user/UserModel.ts +297 -297
- package/src/user/UserStore.ts +119 -119
- package/src/workflow/services/MassSendApiService.ts +83 -83
- package/templates/bot/.env.example +33 -33
- package/templates/bot/artisan.ts +8 -8
- package/templates/bot/bot.ts +82 -82
- package/templates/bot/database/dbConnector.ts +4 -4
- package/templates/bot/database/migrate.ts +9 -9
- package/templates/bot/database/migrations/001_create_users.sql +18 -18
- package/templates/bot/database/migrations/007_proxy.sql +27 -27
- package/templates/bot/database/migrations/008_tg_accounts.sql +32 -32
- package/templates/bot/database/seed.ts +14 -14
- package/templates/bot/docs/CLI_SERVICES.md +536 -536
- package/templates/bot/docs/INPUT_SYSTEM.md +211 -211
- package/templates/bot/docs/MASS_SEND_SERVICE.md +327 -327
- package/templates/bot/docs/SERVICE_EXAMPLES.md +384 -384
- package/templates/bot/docs/TASK_SYSTEM.md +156 -156
- package/templates/bot/models/Model.ts +8 -8
- package/templates/bot/models/index.ts +1 -1
- package/templates/bot/package.json +30 -30
- package/templates/bot/sectionList.ts +9 -9
- package/templates/bot/sections/ExampleInputSection.ts +85 -85
- package/templates/bot/sections/ExampleLiveTaskerSection.ts +60 -60
- package/templates/bot/sections/HomeSection.ts +63 -63
- package/templates/bot/tsconfig.json +17 -0
- 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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.runParams.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.runParams.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
+
}
|