@2byte/tgbot-framework 1.0.2 → 1.0.3
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 -84
- package/package.json +6 -2
- package/src/cli/CreateBotCommand.ts +181 -181
- package/src/cli/GenerateCommand.ts +195 -111
- package/src/cli/InitCommand.ts +107 -107
- package/src/console/migrate.ts +82 -82
- package/src/core/ApiService.ts +21 -0
- package/src/core/ApiServiceManager.ts +63 -0
- package/src/core/App.ts +1113 -1042
- 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 +61 -60
- package/src/illumination/Message2Byte.ts +255 -254
- package/src/illumination/Message2ByteLiveProgressive.ts +278 -278
- package/src/illumination/Message2bytePool.ts +107 -107
- package/src/illumination/Migration.ts +186 -186
- package/src/illumination/RunSectionRoute.ts +85 -85
- package/src/illumination/Section.ts +410 -410
- package/src/illumination/SectionComponent.ts +64 -64
- package/src/illumination/Telegraf2byteContext.ts +32 -32
- package/src/index.ts +35 -33
- package/src/libs/TelegramAccountControl.ts +738 -738
- package/src/types.ts +188 -186
- package/src/user/UserModel.ts +297 -288
- package/src/user/UserStore.ts +119 -119
- package/src/workflow/services/MassSendApiService.ts +80 -0
- package/templates/bot/.env.example +18 -17
- package/templates/bot/artisan.ts +8 -8
- package/templates/bot/bot.ts +79 -77
- 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/seed.ts +14 -14
- package/templates/bot/package.json +30 -30
- package/templates/bot/sectionList.ts +9 -7
- package/templates/bot/sections/ExampleInputSection.ts +85 -0
- package/templates/bot/sections/ExampleLiveTaskerSection.ts +60 -0
- package/templates/bot/sections/HomeSection.ts +63 -63
- package/templates/bot/workflow/services/ExampleServise.ts +24 -0
|
@@ -1,85 +1,85 @@
|
|
|
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
|
-
runAsCallcackQuery: 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.runAsCallcackQuery = 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.runAsCallcackQuery = true;
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
actionPath(path: string): this {
|
|
40
|
-
this.runParams.actionPath = path;
|
|
41
|
-
this.runParams.runAsCallcackQuery = true;
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
hearsKey(key: string): this {
|
|
46
|
-
this.runParams.hearsKey = key;
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
getMethod(): string | null {
|
|
51
|
-
return this.runParams.method;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
getSection(): string | null {
|
|
55
|
-
return this.runParams.section;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
getSectionId(): string | null {
|
|
59
|
-
return this.runParams.section;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
getCommand(): string | null {
|
|
63
|
-
return this.runParams.method;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
getSubCommand(): string | null {
|
|
67
|
-
return this.runParams.method;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
getActionPath(): string | null {
|
|
71
|
-
return this.runParams.actionPath;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
getCallbackParams(): URLSearchParams {
|
|
75
|
-
return this.runParams.callbackParams;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
getHearsKey(): string | null {
|
|
79
|
-
return this.runParams.hearsKey;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
get runIsCallbackQuery(): boolean {
|
|
83
|
-
return this.runParams.runAsCallcackQuery;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
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
|
+
runAsCallcackQuery: 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.runAsCallcackQuery = 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.runAsCallcackQuery = true;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
actionPath(path: string): this {
|
|
40
|
+
this.runParams.actionPath = path;
|
|
41
|
+
this.runParams.runAsCallcackQuery = true;
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
hearsKey(key: string): this {
|
|
46
|
+
this.runParams.hearsKey = key;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getMethod(): string | null {
|
|
51
|
+
return this.runParams.method;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
getSection(): string | null {
|
|
55
|
+
return this.runParams.section;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
getSectionId(): string | null {
|
|
59
|
+
return this.runParams.section;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
getCommand(): string | null {
|
|
63
|
+
return this.runParams.method;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
getSubCommand(): string | null {
|
|
67
|
+
return this.runParams.method;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
getActionPath(): string | null {
|
|
71
|
+
return this.runParams.actionPath;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
getCallbackParams(): URLSearchParams {
|
|
75
|
+
return this.runParams.callbackParams;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
getHearsKey(): string | null {
|
|
79
|
+
return this.runParams.hearsKey;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
get runIsCallbackQuery(): boolean {
|
|
83
|
+
return this.runParams.runAsCallcackQuery;
|
|
84
|
+
}
|
|
85
|
+
}
|