@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,64 +1,64 @@
1
- import { TelegrafContextCustom } from './Telegraf2byteContext';
2
- import { Section } from './Section';
3
- import { ComponentOptions } from '../types';
4
-
5
- export class SectionComponent {
6
- static readonly TYPE_SYNC = 'sync';
7
- static readonly TYPE_PENDINGS = 'pendings';
8
- static readonly STATUS_PROCESSED = 'processed';
9
- static readonly STATUS_PENDING = 'pending';
10
-
11
- protected _ctx: TelegrafContextCustom;
12
- protected _app: any; // App instance
13
- protected _section: Section;
14
-
15
- protected _type: string = SectionComponent.TYPE_SYNC;
16
- protected _status: string = SectionComponent.STATUS_PROCESSED;
17
-
18
- protected _name: string = 'SectionComponent';
19
- protected _actions: Record<string, string> = {};
20
- protected _isCallbackQuery: boolean = true;
21
-
22
- constructor(options: ComponentOptions) {
23
- this._ctx = options.ctx;
24
- this._app = options.app;
25
- this._section = options.section;
26
- }
27
-
28
- static init(options: ComponentOptions): SectionComponent {
29
- return new this(options);
30
- }
31
-
32
- async default(): Promise<{ text: string, [key: string]: any }> {
33
- return { text: 'Section component' };
34
- }
35
-
36
- async run(): Promise<any> {
37
- // this._app.registerComponent(this);
38
-
39
- switch (this._type) {
40
- case SectionComponent.TYPE_PENDINGS:
41
- break;
42
-
43
- default:
44
- return this.default();
45
- }
46
- return this;
47
- }
48
-
49
- get name(): string {
50
- return this._name;
51
- }
52
-
53
- get actions(): Record<string, string> {
54
- return this._actions;
55
- }
56
-
57
- get type(): string {
58
- return this._type;
59
- }
60
-
61
- get status(): string {
62
- return this._status;
63
- }
64
- }
1
+ import { TelegrafContextCustom } from './Telegraf2byteContext';
2
+ import { Section } from './Section';
3
+ import { ComponentOptions } from '../types';
4
+
5
+ export class SectionComponent {
6
+ static readonly TYPE_SYNC = 'sync';
7
+ static readonly TYPE_PENDINGS = 'pendings';
8
+ static readonly STATUS_PROCESSED = 'processed';
9
+ static readonly STATUS_PENDING = 'pending';
10
+
11
+ protected _ctx: TelegrafContextCustom;
12
+ protected _app: any; // App instance
13
+ protected _section: Section;
14
+
15
+ protected _type: string = SectionComponent.TYPE_SYNC;
16
+ protected _status: string = SectionComponent.STATUS_PROCESSED;
17
+
18
+ protected _name: string = 'SectionComponent';
19
+ protected _actions: Record<string, string> = {};
20
+ protected _isCallbackQuery: boolean = true;
21
+
22
+ constructor(options: ComponentOptions) {
23
+ this._ctx = options.ctx;
24
+ this._app = options.app;
25
+ this._section = options.section;
26
+ }
27
+
28
+ static init(options: ComponentOptions): SectionComponent {
29
+ return new this(options);
30
+ }
31
+
32
+ async default(): Promise<{ text: string, [key: string]: any }> {
33
+ return { text: 'Section component' };
34
+ }
35
+
36
+ async run(): Promise<any> {
37
+ // this._app.registerComponent(this);
38
+
39
+ switch (this._type) {
40
+ case SectionComponent.TYPE_PENDINGS:
41
+ break;
42
+
43
+ default:
44
+ return this.default();
45
+ }
46
+ return this;
47
+ }
48
+
49
+ get name(): string {
50
+ return this._name;
51
+ }
52
+
53
+ get actions(): Record<string, string> {
54
+ return this._actions;
55
+ }
56
+
57
+ get type(): string {
58
+ return this._type;
59
+ }
60
+
61
+ get status(): string {
62
+ return this._status;
63
+ }
64
+ }
@@ -1,33 +1,33 @@
1
- import { Context } from 'telegraf';
2
- import { UserModel } from '../user/UserModel';
3
- import { UserStore } from '../user/UserStore';
4
- import { UserSession } from '../types';
5
-
6
- export interface ITelegraf2byteContextExtraMethods {
7
- deleteLastMessage(): Promise<void>;
8
- }
9
-
10
- export interface Telegraf2byteContext extends Context, ITelegraf2byteContextExtraMethods {
11
- user: UserModel;
12
- userStorage: UserStore;
13
- userSession: UserSession;
14
- // msgId?: number;
15
- }
16
-
17
- export const Telegraf2byteContextExtraMethods = {
18
- async deleteLastMessage(this: Telegraf2byteContext): Promise<void> {
19
- const lastMessageId = this.user.lastMessageId;
20
- if (lastMessageId) {
21
- try {
22
-
23
- console.log('Deleting last message with ID:', lastMessageId);
24
-
25
- await this.deleteMessage(lastMessageId);
26
-
27
- this.user.removeMessageId(lastMessageId);
28
- } catch (error) {
29
- console.error('Failed to delete last message:', error)
30
- };
31
- }
32
- },
1
+ import { Context } from 'telegraf';
2
+ import { UserModel } from '../user/UserModel';
3
+ import { UserStore } from '../user/UserStore';
4
+ import { UserSession } from '../types';
5
+
6
+ export interface ITelegraf2byteContextExtraMethods {
7
+ deleteLastMessage(): Promise<void>;
8
+ }
9
+
10
+ export interface Telegraf2byteContext extends Context, ITelegraf2byteContextExtraMethods {
11
+ user: UserModel;
12
+ userStorage: UserStore;
13
+ userSession: UserSession;
14
+ // msgId?: number;
15
+ }
16
+
17
+ export const Telegraf2byteContextExtraMethods = {
18
+ async deleteLastMessage(this: Telegraf2byteContext): Promise<void> {
19
+ const lastMessageId = this.user.lastMessageId;
20
+ if (lastMessageId) {
21
+ try {
22
+
23
+ console.log('Deleting last message with ID:', lastMessageId);
24
+
25
+ await this.deleteMessage(lastMessageId);
26
+
27
+ this.user.removeMessageId(lastMessageId);
28
+ } catch (error) {
29
+ console.error('Failed to delete last message:', error)
30
+ };
31
+ }
32
+ },
33
33
  };
package/src/index.ts CHANGED
@@ -1,42 +1,43 @@
1
- // Core classes
2
- export { App } from './core/App';
3
- export { ApiService } from './core/ApiService';
4
- export { ApiServiceManager } from './core/ApiServiceManager';
5
- export { BotArtisan } from './core/BotArtisan';
6
- export { BotMigration } from './core/BotMigration';
7
- export { BotSeeder } from './core/BotSeeder';
8
-
9
- // Framework classes
10
- export { Section } from './illumination/Section';
11
- export { Artisan } from './illumination/Artisan';
12
- export { Migration } from './illumination/Migration';
13
- export { InlineKeyboard } from './illumination/InlineKeyboard';
14
- export { default as Message2Byte } from './illumination/Message2Byte';
15
- export { RunSectionRoute } from './illumination/RunSectionRoute';
16
- export { SectionComponent } from './illumination/SectionComponent';
17
- export type { Telegraf2byteContext } from './illumination/Telegraf2byteContext';
18
-
19
- // Console utilities
20
- export { setupMigrations } from './console/migrate';
21
-
22
- // Types
23
- export * from './types';
24
-
25
- // CLI Commands (for internal use)
26
- export { CreateBotCommand } from './cli/CreateBotCommand';
27
- export { InitCommand } from './cli/InitCommand';
28
- export { GenerateCommand } from './cli/GenerateCommand';
29
- export { manualAdderTgAccount } from './cli/TgAccountManager';
30
-
31
- // Model exports
32
- export * from './models';
33
-
34
- // User exports
35
- export { UserModel } from './user/UserModel';
36
- export { UserStore } from './user/UserStore';
37
-
38
- export * from './libs/TelegramAccountControl';
39
- export { TgSender } from './libs/TgSender';
40
-
41
- // Type exports
42
- export * from './types';
1
+ // Core classes
2
+ export { App } from './core/App';
3
+ export { ApiService } from './core/ApiService';
4
+ export { ApiServiceManager } from './core/ApiServiceManager';
5
+ export { MassSendApiService } from './workflow/services/MassSendApiService';
6
+ export { BotArtisan } from './core/BotArtisan';
7
+ export { BotMigration } from './core/BotMigration';
8
+ export { BotSeeder } from './core/BotSeeder';
9
+
10
+ // Framework classes
11
+ export { Section } from './illumination/Section';
12
+ export { Artisan } from './illumination/Artisan';
13
+ export { Migration } from './illumination/Migration';
14
+ export { InlineKeyboard } from './illumination/InlineKeyboard';
15
+ export { default as Message2Byte } from './illumination/Message2Byte';
16
+ export { RunSectionRoute } from './illumination/RunSectionRoute';
17
+ export { SectionComponent } from './illumination/SectionComponent';
18
+ export type { Telegraf2byteContext } from './illumination/Telegraf2byteContext';
19
+
20
+ // Console utilities
21
+ export { setupMigrations } from './console/migrate';
22
+
23
+ // Types
24
+ export * from './types';
25
+
26
+ // CLI Commands (for internal use)
27
+ export { CreateBotCommand } from './cli/CreateBotCommand';
28
+ export { InitCommand } from './cli/InitCommand';
29
+ export { GenerateCommand } from './cli/GenerateCommand';
30
+ export { manualAdderTgAccount } from './cli/TgAccountManager';
31
+
32
+ // Model exports
33
+ export * from './models';
34
+
35
+ // User exports
36
+ export { UserModel } from './user/UserModel';
37
+ export { UserStore } from './user/UserStore';
38
+
39
+ export * from './libs/TelegramAccountControl';
40
+ export { TgSender } from './libs/TgSender';
41
+
42
+ // Type exports
43
+ export * from './types';