gramstax 0.0.3 → 0.0.5

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.
@@ -1,14 +1,14 @@
1
1
  import LoggingPretty, { LoggingPretty as LoggingPretty$1 } from 'logging-pretty';
2
+ import { Keyv } from 'keyv';
2
3
  import * as grammy_types from 'grammy/types';
3
4
  import { UserFromGetMe } from 'grammy/types';
4
- import { Keyv } from 'keyv';
5
5
  import { FSWatcher } from 'chokidar';
6
6
  import { Context, Keyboard, InlineKeyboard, Bot, BotError } from 'grammy';
7
7
 
8
8
  declare abstract class BaseGeneral {
9
- protected static log: LoggingPretty;
10
- protected static logError(error: any, func: string): void;
11
- protected logError(error: any, constructorName?: string, funcName?: string): void;
9
+ static log: LoggingPretty;
10
+ static logError(error: any, func: string): void;
11
+ logError(error: any, constructorName?: string, funcName?: string): void;
12
12
  }
13
13
 
14
14
  type IMore = Omit<Required<ConstructorParameters<typeof Keyv>>[0], `store` | `namespace` | `ttl`> & {
@@ -161,15 +161,21 @@ declare class TemplateManager {
161
161
  destroy(): Promise<void>;
162
162
  }
163
163
 
164
- declare class Ctx extends BaseGeneral {
165
- ct: Context;
166
- templateManager: TemplateManager;
167
- cacheSession: CacheExternal;
168
- cacheKeyboard: Map<any, any>;
169
- data: {
170
- name: string;
171
- callbackData: (...args: any) => string | any;
164
+ type IData = {
165
+ name: string;
166
+ callbackData: (...args: any) => string | any;
167
+ };
168
+ type ITemp = {
169
+ session: {
170
+ method?: string;
171
+ params?: any;
172
172
  };
173
+ [key: string]: any;
174
+ };
175
+ declare class Ctx extends BaseGeneral {
176
+ static template?: string;
177
+ static data: IData;
178
+ data: IData;
173
179
  get isPremium(): boolean;
174
180
  get isBot(): boolean;
175
181
  get userid(): number;
@@ -193,11 +199,20 @@ declare class Ctx extends BaseGeneral {
193
199
  get callbackDataParts(): any[];
194
200
  get languageCode(): any;
195
201
  set languageCode(v: any);
196
- session: {
197
- method?: string;
198
- params?: any;
199
- };
200
- constructor(ct: Context, templateManager: TemplateManager, cacheSession: CacheExternal, cacheKeyboard: Map<any, any>);
202
+ set session(v: any);
203
+ get session(): any;
204
+ ct: Context;
205
+ cacheSession: CacheExternal;
206
+ cacheKeyboard: Map<any, any>;
207
+ templateManager: TemplateManager;
208
+ temp: ITemp;
209
+ constructor(params: Ctx | {
210
+ ct: Context;
211
+ cacheSession: CacheExternal;
212
+ cacheKeyboard: Map<any, any>;
213
+ templateManager: TemplateManager;
214
+ temp: ITemp;
215
+ });
201
216
  broadcast(ids: any[], languageCode: any[], keyboard?: Keyboard | InlineKeyboard, data?: Record<string, any>, baseId?: string, options?: any): Promise<void>;
202
217
  reply(keyboard?: Keyboard | InlineKeyboard, data?: Record<string, any>, baseId?: string, options?: any): Promise<grammy_types.Message.TextMessage>;
203
218
  replyAction(type: Parameters<typeof this$1.ct.replyWithChatAction>[0]): Promise<true>;
@@ -215,14 +230,24 @@ declare class Ctx extends BaseGeneral {
215
230
  [moreRoot: string]: any;
216
231
  } | null>;
217
232
  sessionClear(): Promise<boolean | null>;
218
- }
219
-
220
- declare abstract class BasePage extends Ctx {
221
- static template?: string;
222
- static data: {
233
+ static buildData<C extends ((...args: any[]) => any) | undefined = undefined>(callback?: C): {
223
234
  name: string;
224
- callbackData: (...args: any) => string | any;
235
+ callbackData: ((this: {
236
+ name: string;
237
+ }, ...args: Parameters<Exclude<C, undefined>>) => ReturnType<Exclude<C, undefined>>) | ((this: {
238
+ name: string;
239
+ }) => string);
225
240
  };
241
+ buildInlineKeyboard(callback: (kb: InlineKeyboard, arr: any[]) => InlineKeyboard, params?: {
242
+ baseId?: any;
243
+ data?: Record<string, any>;
244
+ cache?: boolean;
245
+ }): InlineKeyboard;
246
+ buildKeyboard(callback: (kb: Keyboard, arr: any[]) => Keyboard, params?: {
247
+ baseId?: any;
248
+ data?: Record<string, any>;
249
+ cache?: boolean;
250
+ }): Keyboard;
226
251
  transition?(...args: any): Promise<void>;
227
252
  internal?(...args: any): Promise<void>;
228
253
  notify?(...args: any): Promise<void>;
@@ -272,28 +297,6 @@ declare abstract class BasePage extends Ctx {
272
297
  locationFree?(): Promise<void>;
273
298
  contactFree?(): Promise<void>;
274
299
  free?(): Promise<void>;
275
- ctx: Ctx;
276
- constructor(ctx: Ctx & {
277
- ctx?: Ctx;
278
- });
279
- static buildData<C extends ((...args: any[]) => any) | undefined = undefined>(callback?: C): {
280
- name: string;
281
- callbackData: ((this: {
282
- name: string;
283
- }, ...args: Parameters<Exclude<C, undefined>>) => ReturnType<Exclude<C, undefined>>) | ((this: {
284
- name: string;
285
- }) => string);
286
- };
287
- buildInlineKeyboard(callback: (kb: InlineKeyboard, arr: any[]) => InlineKeyboard, params?: {
288
- baseId?: any;
289
- data?: Record<string, any>;
290
- cache?: boolean;
291
- }): InlineKeyboard;
292
- buildKeyboard(callback: (kb: Keyboard, arr: any[]) => Keyboard, params?: {
293
- baseId?: any;
294
- data?: Record<string, any>;
295
- cache?: boolean;
296
- }): Keyboard;
297
300
  validateSessionCallback(method?: string, name?: string): boolean;
298
301
  validateSessionCallbackPayload(method?: string, name?: string): boolean;
299
302
  validateSessionText(method?: string, name?: string): boolean;
@@ -478,404 +481,13 @@ declare abstract class BasePage extends Ctx {
478
481
  buildSessionMethodContactFree(name?: string): string;
479
482
  }
480
483
 
481
- declare abstract class BaseGuard extends BasePage {
482
- pageData: {
483
- name: string;
484
- callbackData: (...args: any) => string | any;
485
- };
486
- constructor(page: {
487
- ctx: Ctx;
488
- data?: any;
489
- });
490
- }
491
-
492
- declare const Page = class extends BasePage {}
493
- type IPageBase = typeof Page
494
-
495
484
  declare class Gramstax {
496
485
  templateManager: TemplateManager;
497
486
  cacheKeyboard: Map<any, any>;
498
487
  cacheSession: CacheExternal;
499
- log: LoggingPretty$1 | undefined;
488
+ pages: ReturnType<typeof this.pageLoads>;
489
+ log: LoggingPretty$1 | undefined | null;
500
490
  bot: Bot;
501
- pages: {
502
- all: Record<string, IPageBase>;
503
- dynamic: string[];
504
- dynamicSpesific: {
505
- text: {
506
- name: string;
507
- func: string;
508
- }[];
509
- photo: {
510
- name: string;
511
- func: string;
512
- }[];
513
- video: {
514
- name: string;
515
- func: string;
516
- }[];
517
- audio: {
518
- name: string;
519
- func: string;
520
- }[];
521
- document: {
522
- name: string;
523
- func: string;
524
- }[];
525
- animation: {
526
- name: string;
527
- func: string;
528
- }[];
529
- voice: {
530
- name: string;
531
- func: string;
532
- }[];
533
- videoNote: {
534
- name: string;
535
- func: string;
536
- }[];
537
- sticker: {
538
- name: string;
539
- func: string;
540
- }[];
541
- location: {
542
- name: string;
543
- func: string;
544
- }[];
545
- contact: {
546
- name: string;
547
- func: string;
548
- }[];
549
- };
550
- static: {
551
- text: Record<string, {
552
- name: string;
553
- func: string;
554
- }>;
555
- callback: Record<string, {
556
- name: string;
557
- func: string;
558
- }>;
559
- textCommand: Record<string, {
560
- name: string;
561
- func: string;
562
- }>;
563
- photoCaption: Record<string, {
564
- name: string;
565
- func: string;
566
- }>;
567
- photoCaptionCommand: Record<string, {
568
- name: string;
569
- func: string;
570
- }>;
571
- videoCaption: Record<string, {
572
- name: string;
573
- func: string;
574
- }>;
575
- videoCaptionCommand: Record<string, {
576
- name: string;
577
- func: string;
578
- }>;
579
- audioCaption: Record<string, {
580
- name: string;
581
- func: string;
582
- }>;
583
- audioCaptionCommand: Record<string, {
584
- name: string;
585
- func: string;
586
- }>;
587
- documentCaption: Record<string, {
588
- name: string;
589
- func: string;
590
- }>;
591
- documentCaptionCommand: Record<string, {
592
- name: string;
593
- func: string;
594
- }>;
595
- animationCaption: Record<string, {
596
- name: string;
597
- func: string;
598
- }>;
599
- animationCaptionCommand: Record<string, {
600
- name: string;
601
- func: string;
602
- }>;
603
- voiceCaption: Record<string, {
604
- name: string;
605
- func: string;
606
- }>;
607
- voiceCaptionCommand: Record<string, {
608
- name: string;
609
- func: string;
610
- }>;
611
- videoNoteCaption: Record<string, {
612
- name: string;
613
- func: string;
614
- }>;
615
- videoNoteCaptionCommand: Record<string, {
616
- name: string;
617
- func: string;
618
- }>;
619
- };
620
- staticIntent: {
621
- callbackPayload: Record<string, {
622
- name: string;
623
- func: string;
624
- }>;
625
- textPayload: Record<string, {
626
- name: string;
627
- func: string;
628
- }>;
629
- textCommandPayload: Record<string, {
630
- name: string;
631
- func: string;
632
- }>;
633
- photoCaptionPayload: Record<string, {
634
- name: string;
635
- func: string;
636
- }>;
637
- photoCaptionCommandPayload: Record<string, {
638
- name: string;
639
- func: string;
640
- }>;
641
- videoCaptionPayload: Record<string, {
642
- name: string;
643
- func: string;
644
- }>;
645
- videoCaptionCommandPayload: Record<string, {
646
- name: string;
647
- func: string;
648
- }>;
649
- audioCaptionPayload: Record<string, {
650
- name: string;
651
- func: string;
652
- }>;
653
- audioCaptionCommandPayload: Record<string, {
654
- name: string;
655
- func: string;
656
- }>;
657
- documentCaptionPayload: Record<string, {
658
- name: string;
659
- func: string;
660
- }>;
661
- documentCaptionCommandPayload: Record<string, {
662
- name: string;
663
- func: string;
664
- }>;
665
- animationCaptionPayload: Record<string, {
666
- name: string;
667
- func: string;
668
- }>;
669
- animationCaptionCommandPayload: Record<string, {
670
- name: string;
671
- func: string;
672
- }>;
673
- voiceCaptionPayload: Record<string, {
674
- name: string;
675
- func: string;
676
- }>;
677
- voiceCaptionCommandPayload: Record<string, {
678
- name: string;
679
- func: string;
680
- }>;
681
- videoNoteCaptionPayload: Record<string, {
682
- name: string;
683
- func: string;
684
- }>;
685
- videoNoteCaptionCommandPayload: Record<string, {
686
- name: string;
687
- func: string;
688
- }>;
689
- };
690
- staticSession: {
691
- text: Record<string, {
692
- name: string;
693
- func: string;
694
- }>;
695
- callback: Record<string, {
696
- name: string;
697
- func: string;
698
- }>;
699
- textCommand: Record<string, {
700
- name: string;
701
- func: string;
702
- }>;
703
- photoCaption: Record<string, {
704
- name: string;
705
- func: string;
706
- }>;
707
- photoCaptionCommand: Record<string, {
708
- name: string;
709
- func: string;
710
- }>;
711
- videoCaption: Record<string, {
712
- name: string;
713
- func: string;
714
- }>;
715
- videoCaptionCommand: Record<string, {
716
- name: string;
717
- func: string;
718
- }>;
719
- audioCaption: Record<string, {
720
- name: string;
721
- func: string;
722
- }>;
723
- audioCaptionCommand: Record<string, {
724
- name: string;
725
- func: string;
726
- }>;
727
- documentCaption: Record<string, {
728
- name: string;
729
- func: string;
730
- }>;
731
- documentCaptionCommand: Record<string, {
732
- name: string;
733
- func: string;
734
- }>;
735
- animationCaption: Record<string, {
736
- name: string;
737
- func: string;
738
- }>;
739
- animationCaptionCommand: Record<string, {
740
- name: string;
741
- func: string;
742
- }>;
743
- voiceCaption: Record<string, {
744
- name: string;
745
- func: string;
746
- }>;
747
- voiceCaptionCommand: Record<string, {
748
- name: string;
749
- func: string;
750
- }>;
751
- videoNoteCaption: Record<string, {
752
- name: string;
753
- func: string;
754
- }>;
755
- videoNoteCaptionCommand: Record<string, {
756
- name: string;
757
- func: string;
758
- }>;
759
- callbackPayload: Record<string, {
760
- name: string;
761
- func: string;
762
- }>;
763
- textPayload: Record<string, {
764
- name: string;
765
- func: string;
766
- }>;
767
- textCommandPayload: Record<string, {
768
- name: string;
769
- func: string;
770
- }>;
771
- photoCaptionPayload: Record<string, {
772
- name: string;
773
- func: string;
774
- }>;
775
- photoCaptionCommandPayload: Record<string, {
776
- name: string;
777
- func: string;
778
- }>;
779
- videoCaptionPayload: Record<string, {
780
- name: string;
781
- func: string;
782
- }>;
783
- videoCaptionCommandPayload: Record<string, {
784
- name: string;
785
- func: string;
786
- }>;
787
- audioCaptionPayload: Record<string, {
788
- name: string;
789
- func: string;
790
- }>;
791
- audioCaptionCommandPayload: Record<string, {
792
- name: string;
793
- func: string;
794
- }>;
795
- documentCaptionPayload: Record<string, {
796
- name: string;
797
- func: string;
798
- }>;
799
- documentCaptionCommandPayload: Record<string, {
800
- name: string;
801
- func: string;
802
- }>;
803
- animationCaptionPayload: Record<string, {
804
- name: string;
805
- func: string;
806
- }>;
807
- animationCaptionCommandPayload: Record<string, {
808
- name: string;
809
- func: string;
810
- }>;
811
- voiceCaptionPayload: Record<string, {
812
- name: string;
813
- func: string;
814
- }>;
815
- voiceCaptionCommandPayload: Record<string, {
816
- name: string;
817
- func: string;
818
- }>;
819
- videoNoteCaptionPayload: Record<string, {
820
- name: string;
821
- func: string;
822
- }>;
823
- videoNoteCaptionCommandPayload: Record<string, {
824
- name: string;
825
- func: string;
826
- }>;
827
- textFree: Record<string, {
828
- name: string;
829
- func: string;
830
- }>;
831
- photoFree: Record<string, {
832
- name: string;
833
- func: string;
834
- }>;
835
- videoFree: Record<string, {
836
- name: string;
837
- func: string;
838
- }>;
839
- audioFree: Record<string, {
840
- name: string;
841
- func: string;
842
- }>;
843
- documentFree: Record<string, {
844
- name: string;
845
- func: string;
846
- }>;
847
- animationFree: Record<string, {
848
- name: string;
849
- func: string;
850
- }>;
851
- voiceFree: Record<string, {
852
- name: string;
853
- func: string;
854
- }>;
855
- videoNoteFree: Record<string, {
856
- name: string;
857
- func: string;
858
- }>;
859
- stickerFree: Record<string, {
860
- name: string;
861
- func: string;
862
- }>;
863
- locationFree: Record<string, {
864
- name: string;
865
- func: string;
866
- }>;
867
- contactFree: Record<string, {
868
- name: string;
869
- func: string;
870
- }>;
871
- };
872
- listFuncStatic: readonly ["callback", "text", "textCommand", "photoCaption", "photoCaptionCommand", "videoCaption", "videoCaptionCommand", "audioCaption", "audioCaptionCommand", "documentCaption", "documentCaptionCommand", "animationCaption", "animationCaptionCommand", "voiceCaption", "voiceCaptionCommand", "videoNoteCaption", "videoNoteCaptionCommand"];
873
- listFuncStaticIntent: readonly ["callbackPayload", "textPayload", "textCommandPayload", "photoCaptionPayload", "photoCaptionCommandPayload", "videoCaptionPayload", "videoCaptionCommandPayload", "audioCaptionPayload", "audioCaptionCommandPayload", "documentCaptionPayload", "documentCaptionCommandPayload", "animationCaptionPayload", "animationCaptionCommandPayload", "voiceCaptionPayload", "voiceCaptionCommandPayload", "videoNoteCaptionPayload", "videoNoteCaptionCommandPayload"];
874
- listFuncStaticSession: readonly ["callback", "text", "textCommand", "photoCaption", "photoCaptionCommand", "videoCaption", "videoCaptionCommand", "audioCaption", "audioCaptionCommand", "documentCaption", "documentCaptionCommand", "animationCaption", "animationCaptionCommand", "voiceCaption", "voiceCaptionCommand", "videoNoteCaption", "videoNoteCaptionCommand", "callbackPayload", "textPayload", "textCommandPayload", "photoCaptionPayload", "photoCaptionCommandPayload", "videoCaptionPayload", "videoCaptionCommandPayload", "audioCaptionPayload", "audioCaptionCommandPayload", "documentCaptionPayload", "documentCaptionCommandPayload", "animationCaptionPayload", "animationCaptionCommandPayload", "voiceCaptionPayload", "voiceCaptionCommandPayload", "videoNoteCaptionPayload", "videoNoteCaptionCommandPayload", "textFree", "photoFree", "videoFree", "audioFree", "documentFree", "animationFree", "voiceFree", "videoNoteFree", "stickerFree", "locationFree", "contactFree"];
875
- lenListFuncStatic: 17;
876
- lenListFuncStaticIntent: 17;
877
- lenListFuncStaticSession: 45;
878
- };
879
491
  constructor(params: {
880
492
  token: string;
881
493
  deploy: string;
@@ -889,11 +501,11 @@ declare class Gramstax {
889
501
  initCtx(ct: Context): Ctx;
890
502
  runPolling(): Promise<void>;
891
503
  runWebhook(baseUrl: string): Promise<void>;
892
- pageCompile(Page: IPageBase, redacted?: boolean): void;
893
- pageBuildData(Page: IPageBase, filePath: string): void;
894
- pageSorts(Page: IPageBase, pages: typeof this.pages): void;
504
+ pageCompile(Page: typeof Ctx, redacted?: boolean): void;
505
+ pageBuildData(Page: typeof Ctx, filePath: string): void;
506
+ pageSorts(Page: typeof Ctx, pages: typeof this.pages): void;
895
507
  pageLoads(): {
896
- all: Record<string, IPageBase>;
508
+ all: Record<string, typeof Ctx>;
897
509
  dynamic: string[];
898
510
  dynamicSpesific: {
899
511
  text: {
@@ -1289,4 +901,4 @@ declare class Gramstax {
1289
901
  onMessageContact(ct: Context): Promise<void>;
1290
902
  }
1291
903
 
1292
- export { BaseGeneral, BaseGuard, BasePage, CacheExternal, Ctx, Gramstax, TemplateEngine, TemplateManager };
904
+ export { BaseGeneral, CacheExternal, Ctx, Gramstax, TemplateEngine, TemplateManager };