@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.
Files changed (44) hide show
  1. package/README.md +300 -300
  2. package/bin/2byte-cli.ts +97 -84
  3. package/package.json +6 -2
  4. package/src/cli/CreateBotCommand.ts +181 -181
  5. package/src/cli/GenerateCommand.ts +195 -111
  6. package/src/cli/InitCommand.ts +107 -107
  7. package/src/console/migrate.ts +82 -82
  8. package/src/core/ApiService.ts +21 -0
  9. package/src/core/ApiServiceManager.ts +63 -0
  10. package/src/core/App.ts +1113 -1042
  11. package/src/core/BotArtisan.ts +79 -79
  12. package/src/core/BotMigration.ts +30 -30
  13. package/src/core/BotSeeder.ts +66 -66
  14. package/src/core/Model.ts +84 -84
  15. package/src/core/utils.ts +2 -2
  16. package/src/illumination/Artisan.ts +149 -149
  17. package/src/illumination/InlineKeyboard.ts +61 -60
  18. package/src/illumination/Message2Byte.ts +255 -254
  19. package/src/illumination/Message2ByteLiveProgressive.ts +278 -278
  20. package/src/illumination/Message2bytePool.ts +107 -107
  21. package/src/illumination/Migration.ts +186 -186
  22. package/src/illumination/RunSectionRoute.ts +85 -85
  23. package/src/illumination/Section.ts +410 -410
  24. package/src/illumination/SectionComponent.ts +64 -64
  25. package/src/illumination/Telegraf2byteContext.ts +32 -32
  26. package/src/index.ts +35 -33
  27. package/src/libs/TelegramAccountControl.ts +738 -738
  28. package/src/types.ts +188 -186
  29. package/src/user/UserModel.ts +297 -288
  30. package/src/user/UserStore.ts +119 -119
  31. package/src/workflow/services/MassSendApiService.ts +80 -0
  32. package/templates/bot/.env.example +18 -17
  33. package/templates/bot/artisan.ts +8 -8
  34. package/templates/bot/bot.ts +79 -77
  35. package/templates/bot/database/dbConnector.ts +4 -4
  36. package/templates/bot/database/migrate.ts +9 -9
  37. package/templates/bot/database/migrations/001_create_users.sql +18 -18
  38. package/templates/bot/database/seed.ts +14 -14
  39. package/templates/bot/package.json +30 -30
  40. package/templates/bot/sectionList.ts +9 -7
  41. package/templates/bot/sections/ExampleInputSection.ts +85 -0
  42. package/templates/bot/sections/ExampleLiveTaskerSection.ts +60 -0
  43. package/templates/bot/sections/HomeSection.ts +63 -63
  44. package/templates/bot/workflow/services/ExampleServise.ts +24 -0
@@ -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,33 +1,35 @@
1
- // Core classes
2
- export { App } from './core/App';
3
- export { BotArtisan } from './core/BotArtisan';
4
- export { BotMigration } from './core/BotMigration';
5
- export { BotSeeder } from './core/BotSeeder';
6
-
7
- // Framework classes
8
- export { Section } from './illumination/Section';
9
- export { Artisan } from './illumination/Artisan';
10
- export { Migration } from './illumination/Migration';
11
- export { InlineKeyboard } from './illumination/InlineKeyboard';
12
- export { default as Message2Byte } from './illumination/Message2Byte';
13
- export { RunSectionRoute } from './illumination/RunSectionRoute';
14
- export { SectionComponent } from './illumination/SectionComponent';
15
- export type { Telegraf2byteContext } from './illumination/Telegraf2byteContext';
16
-
17
- // Console utilities
18
- export { setupMigrations } from './console/migrate';
19
-
20
- // Types
21
- export * from './types';
22
-
23
- // CLI Commands (for internal use)
24
- export { CreateBotCommand } from './cli/CreateBotCommand';
25
- export { InitCommand } from './cli/InitCommand';
26
- export { GenerateCommand } from './cli/GenerateCommand';
27
-
28
- // User exports
29
- export { UserModel } from './user/UserModel';
30
- export { UserStore } from './user/UserStore';
31
-
32
- // Type exports
33
- 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 { 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
+
30
+ // User exports
31
+ export { UserModel } from './user/UserModel';
32
+ export { UserStore } from './user/UserStore';
33
+
34
+ // Type exports
35
+ export * from './types';