@effect-ak/tg-bot-client 0.1.0 → 0.2.0

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 (82) hide show
  1. package/dist/cjs/bot/factory/_service.js +20 -0
  2. package/dist/cjs/bot/factory/client-config.js +29 -0
  3. package/dist/cjs/bot/factory/make-bot.js +20 -0
  4. package/dist/cjs/bot/message-handler/_service.js +12 -0
  5. package/dist/cjs/bot/message-handler/types.js +5 -0
  6. package/dist/cjs/bot/message-handler/utils.js +19 -0
  7. package/dist/cjs/bot/run.js +10 -0
  8. package/dist/cjs/bot/update-poller/_service.js +39 -0
  9. package/dist/cjs/bot/update-poller/errors.js +5 -0
  10. package/dist/cjs/bot/update-poller/fetch-updates.js +70 -0
  11. package/dist/cjs/bot/update-poller/poll-and-handle.js +50 -0
  12. package/dist/cjs/bot/update-poller/settings.js +23 -0
  13. package/dist/cjs/client/_client.js +17 -14
  14. package/dist/cjs/client/config.js +17 -0
  15. package/dist/cjs/client/errors.js +8 -9
  16. package/dist/cjs/client/execute-request/_service.js +20 -0
  17. package/dist/cjs/client/execute-request/execute.js +59 -0
  18. package/dist/cjs/client/{request.js → execute-request/payload.js} +2 -2
  19. package/dist/cjs/client/file/_service.js +22 -0
  20. package/dist/cjs/client/file/get-file.js +38 -0
  21. package/dist/cjs/client/guards.js +12 -0
  22. package/dist/cjs/index.js +41 -8
  23. package/dist/dts/bot/factory/_service.d.ts +37 -0
  24. package/dist/dts/bot/factory/client-config.d.ts +3 -0
  25. package/dist/dts/bot/factory/make-bot.d.ts +7 -0
  26. package/dist/dts/bot/message-handler/_service.d.ts +6 -0
  27. package/dist/dts/bot/message-handler/types.d.ts +16 -0
  28. package/dist/dts/bot/message-handler/utils.d.ts +6 -0
  29. package/dist/dts/bot/run.d.ts +7 -0
  30. package/dist/dts/bot/update-poller/_service.d.ts +21 -0
  31. package/dist/dts/bot/update-poller/errors.d.ts +1 -0
  32. package/dist/dts/bot/update-poller/fetch-updates.d.ts +17 -0
  33. package/dist/dts/bot/update-poller/poll-and-handle.d.ts +16 -0
  34. package/dist/dts/bot/update-poller/settings.d.ts +6 -0
  35. package/dist/dts/client/_client.d.ts +6 -17
  36. package/dist/dts/client/config.d.ts +8 -0
  37. package/dist/dts/client/errors.d.ts +6 -4
  38. package/dist/dts/client/execute-request/_service.d.ts +15 -0
  39. package/dist/dts/client/execute-request/execute.d.ts +5 -0
  40. package/dist/dts/client/file/_service.d.ts +16 -0
  41. package/dist/dts/client/file/get-file.d.ts +5 -0
  42. package/dist/dts/client/guards.d.ts +17 -0
  43. package/dist/dts/index.d.ts +4 -1
  44. package/dist/dts/specification/api.d.ts +14 -14
  45. package/dist/dts/specification/types.d.ts +77 -77
  46. package/dist/esm/bot/factory/_service.js +12 -0
  47. package/dist/esm/bot/factory/client-config.js +20 -0
  48. package/dist/esm/bot/factory/make-bot.js +9 -0
  49. package/dist/esm/bot/message-handler/_service.js +4 -0
  50. package/dist/esm/bot/message-handler/types.js +1 -0
  51. package/dist/esm/bot/message-handler/utils.js +12 -0
  52. package/dist/esm/bot/run.js +6 -0
  53. package/dist/esm/bot/update-poller/_service.js +31 -0
  54. package/dist/esm/bot/update-poller/errors.js +1 -0
  55. package/dist/esm/bot/update-poller/fetch-updates.js +49 -0
  56. package/dist/esm/bot/update-poller/poll-and-handle.js +37 -0
  57. package/dist/esm/bot/update-poller/settings.js +15 -0
  58. package/dist/esm/client/_client.js +15 -14
  59. package/dist/esm/client/config.js +8 -0
  60. package/dist/esm/client/errors.js +6 -9
  61. package/dist/esm/client/execute-request/_service.js +12 -0
  62. package/dist/esm/client/execute-request/execute.js +37 -0
  63. package/dist/esm/client/{request.js → execute-request/payload.js} +2 -4
  64. package/dist/esm/client/file/_service.js +14 -0
  65. package/dist/esm/client/file/get-file.js +24 -0
  66. package/dist/esm/client/guards.js +7 -0
  67. package/dist/esm/index.js +4 -3
  68. package/package.json +13 -8
  69. package/readme.md +75 -25
  70. package/dist/cjs/client/download-file.js +0 -44
  71. package/dist/cjs/client/execute-request.js +0 -69
  72. package/dist/cjs/client/response.js +0 -22
  73. package/dist/dts/client/download-file.d.ts +0 -13
  74. package/dist/dts/client/execute-request.d.ts +0 -13
  75. package/dist/dts/client/response.d.ts +0 -7
  76. package/dist/esm/client/download-file.js +0 -36
  77. package/dist/esm/client/execute-request.js +0 -62
  78. package/dist/esm/client/response.js +0 -15
  79. /package/dist/cjs/{client/const.js → const.js} +0 -0
  80. /package/dist/dts/client/{request.d.ts → execute-request/payload.d.ts} +0 -0
  81. /package/dist/dts/{client/const.d.ts → const.d.ts} +0 -0
  82. /package/dist/esm/{client/const.js → const.js} +0 -0
@@ -78,29 +78,29 @@ export interface BotCommand {
78
78
  }
79
79
  export type BotCommandScope = BotCommandScopeDefault | BotCommandScopeAllPrivateChats | BotCommandScopeAllGroupChats | BotCommandScopeAllChatAdministrators | BotCommandScopeChat | BotCommandScopeChatAdministrators | BotCommandScopeChatMember;
80
80
  export interface BotCommandScopeAllChatAdministrators {
81
- type: "<em>all_chat_administrators</em>";
81
+ type: "all_chat_administrators";
82
82
  }
83
83
  export interface BotCommandScopeAllGroupChats {
84
- type: "<em>all_group_chats</em>";
84
+ type: "all_group_chats";
85
85
  }
86
86
  export interface BotCommandScopeAllPrivateChats {
87
- type: "<em>all_private_chats</em>";
87
+ type: "all_private_chats";
88
88
  }
89
89
  export interface BotCommandScopeChat {
90
- type: "<em>chat</em>";
90
+ type: "chat";
91
91
  chat_id: number | string;
92
92
  }
93
93
  export interface BotCommandScopeChatAdministrators {
94
- type: "<em>chat_administrators</em>";
94
+ type: "chat_administrators";
95
95
  chat_id: number | string;
96
96
  }
97
97
  export interface BotCommandScopeChatMember {
98
- type: "<em>chat_member</em>";
98
+ type: "chat_member";
99
99
  chat_id: number | string;
100
100
  user_id: number;
101
101
  }
102
102
  export interface BotCommandScopeDefault {
103
- type: "<em>default</em>";
103
+ type: "default";
104
104
  }
105
105
  export interface BotDescription {
106
106
  description: string;
@@ -153,7 +153,7 @@ export interface CallbackQuery {
153
153
  }
154
154
  export interface Chat {
155
155
  id: number;
156
- type: string;
156
+ type: "private" | "group" | "supergroup" | "channel";
157
157
  title?: string;
158
158
  username?: string;
159
159
  first_name?: string;
@@ -217,7 +217,7 @@ export interface ChatBoostUpdated {
217
217
  }
218
218
  export interface ChatFullInfo {
219
219
  id: number;
220
- type: string;
220
+ type: "private" | "group" | "supergroup" | "channel";
221
221
  accent_color_id: number;
222
222
  max_reaction_count: number;
223
223
  title?: string;
@@ -572,12 +572,12 @@ export interface InlineQuery {
572
572
  from: User;
573
573
  query: string;
574
574
  offset: string;
575
- chat_type?: "known f" | "requests sent from official clients and most third-party clients";
575
+ chat_type?: string;
576
576
  location?: Location;
577
577
  }
578
578
  export type InlineQueryResult = InlineQueryResultCachedAudio | InlineQueryResultCachedDocument | InlineQueryResultCachedGif | InlineQueryResultCachedMpeg4Gif | InlineQueryResultCachedPhoto | InlineQueryResultCachedSticker | InlineQueryResultCachedVideo | InlineQueryResultCachedVoice | InlineQueryResultArticle | InlineQueryResultAudio | InlineQueryResultContact | InlineQueryResultGame | InlineQueryResultDocument | InlineQueryResultGif | InlineQueryResultLocation | InlineQueryResultMpeg4Gif | InlineQueryResultPhoto | InlineQueryResultVenue | InlineQueryResultVideo | InlineQueryResultVoice;
579
579
  export interface InlineQueryResultArticle {
580
- type: "<em>article</em>";
580
+ type: "article";
581
581
  id: string;
582
582
  title: string;
583
583
  input_message_content: InputMessageContent;
@@ -590,12 +590,12 @@ export interface InlineQueryResultArticle {
590
590
  thumbnail_height?: number;
591
591
  }
592
592
  export interface InlineQueryResultAudio {
593
- type: "<em>audio</em>";
593
+ type: "audio";
594
594
  id: string;
595
595
  audio_url: string;
596
596
  title: string;
597
597
  caption?: string;
598
- parse_mode?: string;
598
+ parse_mode?: "HTML" | "MarkdownV2";
599
599
  caption_entities?: MessageEntity[];
600
600
  performer?: string;
601
601
  audio_duration?: number;
@@ -603,97 +603,97 @@ export interface InlineQueryResultAudio {
603
603
  input_message_content?: InputMessageContent;
604
604
  }
605
605
  export interface InlineQueryResultCachedAudio {
606
- type: "<em>audio</em>";
606
+ type: "audio";
607
607
  id: string;
608
608
  audio_file_id: string;
609
609
  caption?: string;
610
- parse_mode?: string;
610
+ parse_mode?: "HTML" | "MarkdownV2";
611
611
  caption_entities?: MessageEntity[];
612
612
  reply_markup?: InlineKeyboardMarkup;
613
613
  input_message_content?: InputMessageContent;
614
614
  }
615
615
  export interface InlineQueryResultCachedDocument {
616
- type: "<em>document</em>";
616
+ type: "document";
617
617
  id: string;
618
618
  title: string;
619
619
  document_file_id: string;
620
620
  description?: string;
621
621
  caption?: string;
622
- parse_mode?: string;
622
+ parse_mode?: "HTML" | "MarkdownV2";
623
623
  caption_entities?: MessageEntity[];
624
624
  reply_markup?: InlineKeyboardMarkup;
625
625
  input_message_content?: InputMessageContent;
626
626
  }
627
627
  export interface InlineQueryResultCachedGif {
628
- type: "<em>gif</em>";
628
+ type: "gif";
629
629
  id: string;
630
630
  gif_file_id: string;
631
631
  title?: string;
632
632
  caption?: string;
633
- parse_mode?: string;
633
+ parse_mode?: "HTML" | "MarkdownV2";
634
634
  caption_entities?: MessageEntity[];
635
635
  show_caption_above_media?: boolean;
636
636
  reply_markup?: InlineKeyboardMarkup;
637
637
  input_message_content?: InputMessageContent;
638
638
  }
639
639
  export interface InlineQueryResultCachedMpeg4Gif {
640
- type: "<em>mpeg4_gif</em>";
640
+ type: "mpeg4_gif";
641
641
  id: string;
642
642
  mpeg4_file_id: string;
643
643
  title?: string;
644
644
  caption?: string;
645
- parse_mode?: string;
645
+ parse_mode?: "HTML" | "MarkdownV2";
646
646
  caption_entities?: MessageEntity[];
647
647
  show_caption_above_media?: boolean;
648
648
  reply_markup?: InlineKeyboardMarkup;
649
649
  input_message_content?: InputMessageContent;
650
650
  }
651
651
  export interface InlineQueryResultCachedPhoto {
652
- type: "<em>photo</em>";
652
+ type: "photo";
653
653
  id: string;
654
654
  photo_file_id: string;
655
655
  title?: string;
656
656
  description?: string;
657
657
  caption?: string;
658
- parse_mode?: string;
658
+ parse_mode?: "HTML" | "MarkdownV2";
659
659
  caption_entities?: MessageEntity[];
660
660
  show_caption_above_media?: boolean;
661
661
  reply_markup?: InlineKeyboardMarkup;
662
662
  input_message_content?: InputMessageContent;
663
663
  }
664
664
  export interface InlineQueryResultCachedSticker {
665
- type: "<em>sticker</em>";
665
+ type: "sticker";
666
666
  id: string;
667
667
  sticker_file_id: string;
668
668
  reply_markup?: InlineKeyboardMarkup;
669
669
  input_message_content?: InputMessageContent;
670
670
  }
671
671
  export interface InlineQueryResultCachedVideo {
672
- type: "<em>video</em>";
672
+ type: "video";
673
673
  id: string;
674
674
  video_file_id: string;
675
675
  title: string;
676
676
  description?: string;
677
677
  caption?: string;
678
- parse_mode?: string;
678
+ parse_mode?: "HTML" | "MarkdownV2";
679
679
  caption_entities?: MessageEntity[];
680
680
  show_caption_above_media?: boolean;
681
681
  reply_markup?: InlineKeyboardMarkup;
682
682
  input_message_content?: InputMessageContent;
683
683
  }
684
684
  export interface InlineQueryResultCachedVoice {
685
- type: "<em>voice</em>";
685
+ type: "voice";
686
686
  id: string;
687
687
  voice_file_id: string;
688
688
  title: string;
689
689
  caption?: string;
690
- parse_mode?: string;
690
+ parse_mode?: "HTML" | "MarkdownV2";
691
691
  caption_entities?: MessageEntity[];
692
692
  reply_markup?: InlineKeyboardMarkup;
693
693
  input_message_content?: InputMessageContent;
694
694
  }
695
695
  export interface InlineQueryResultContact {
696
- type: "<em>contact</em>";
696
+ type: "contact";
697
697
  id: string;
698
698
  phone_number: string;
699
699
  first_name: string;
@@ -706,13 +706,13 @@ export interface InlineQueryResultContact {
706
706
  thumbnail_height?: number;
707
707
  }
708
708
  export interface InlineQueryResultDocument {
709
- type: "<em>document</em>";
709
+ type: "document";
710
710
  id: string;
711
711
  title: string;
712
712
  document_url: string;
713
713
  mime_type: string;
714
714
  caption?: string;
715
- parse_mode?: string;
715
+ parse_mode?: "HTML" | "MarkdownV2";
716
716
  caption_entities?: MessageEntity[];
717
717
  description?: string;
718
718
  reply_markup?: InlineKeyboardMarkup;
@@ -722,13 +722,13 @@ export interface InlineQueryResultDocument {
722
722
  thumbnail_height?: number;
723
723
  }
724
724
  export interface InlineQueryResultGame {
725
- type: "<em>game</em>";
725
+ type: "game";
726
726
  id: string;
727
727
  game_short_name: string;
728
728
  reply_markup?: InlineKeyboardMarkup;
729
729
  }
730
730
  export interface InlineQueryResultGif {
731
- type: "<em>gif</em>";
731
+ type: "gif";
732
732
  id: string;
733
733
  gif_url: string;
734
734
  thumbnail_url: string;
@@ -738,14 +738,14 @@ export interface InlineQueryResultGif {
738
738
  thumbnail_mime_type?: "image/jpeg" | "image/gif" | "video/mp4";
739
739
  title?: string;
740
740
  caption?: string;
741
- parse_mode?: string;
741
+ parse_mode?: "HTML" | "MarkdownV2";
742
742
  caption_entities?: MessageEntity[];
743
743
  show_caption_above_media?: boolean;
744
744
  reply_markup?: InlineKeyboardMarkup;
745
745
  input_message_content?: InputMessageContent;
746
746
  }
747
747
  export interface InlineQueryResultLocation {
748
- type: "<em>location</em>";
748
+ type: "location";
749
749
  id: string;
750
750
  latitude: number;
751
751
  longitude: number;
@@ -761,7 +761,7 @@ export interface InlineQueryResultLocation {
761
761
  thumbnail_height?: number;
762
762
  }
763
763
  export interface InlineQueryResultMpeg4Gif {
764
- type: "<em>mpeg4_gif</em>";
764
+ type: "mpeg4_gif";
765
765
  id: string;
766
766
  mpeg4_url: string;
767
767
  thumbnail_url: string;
@@ -771,23 +771,23 @@ export interface InlineQueryResultMpeg4Gif {
771
771
  thumbnail_mime_type?: "image/jpeg" | "image/gif" | "video/mp4";
772
772
  title?: string;
773
773
  caption?: string;
774
- parse_mode?: string;
774
+ parse_mode?: "HTML" | "MarkdownV2";
775
775
  caption_entities?: MessageEntity[];
776
776
  show_caption_above_media?: boolean;
777
777
  reply_markup?: InlineKeyboardMarkup;
778
778
  input_message_content?: InputMessageContent;
779
779
  }
780
780
  export interface InlineQueryResultPhoto {
781
- type: "<em>photo</em>";
781
+ type: "photo";
782
782
  id: string;
783
- photo_url: "in <strong>JPEG</strong> format";
783
+ photo_url: string;
784
784
  thumbnail_url: string;
785
785
  photo_width?: number;
786
786
  photo_height?: number;
787
787
  title?: string;
788
788
  description?: string;
789
789
  caption?: string;
790
- parse_mode?: string;
790
+ parse_mode?: "HTML" | "MarkdownV2";
791
791
  caption_entities?: MessageEntity[];
792
792
  show_caption_above_media?: boolean;
793
793
  reply_markup?: InlineKeyboardMarkup;
@@ -799,7 +799,7 @@ export interface InlineQueryResultsButton {
799
799
  start_parameter?: string;
800
800
  }
801
801
  export interface InlineQueryResultVenue {
802
- type: "<em>venue</em>";
802
+ type: "venue";
803
803
  id: string;
804
804
  latitude: number;
805
805
  longitude: number;
@@ -816,14 +816,14 @@ export interface InlineQueryResultVenue {
816
816
  thumbnail_height?: number;
817
817
  }
818
818
  export interface InlineQueryResultVideo {
819
- type: "<em>video</em>";
819
+ type: "video";
820
820
  id: string;
821
821
  video_url: string;
822
822
  mime_type: string;
823
823
  thumbnail_url: string;
824
824
  title: string;
825
825
  caption?: string;
826
- parse_mode?: string;
826
+ parse_mode?: "HTML" | "MarkdownV2";
827
827
  caption_entities?: MessageEntity[];
828
828
  show_caption_above_media?: boolean;
829
829
  video_width?: number;
@@ -834,12 +834,12 @@ export interface InlineQueryResultVideo {
834
834
  input_message_content?: InputMessageContent;
835
835
  }
836
836
  export interface InlineQueryResultVoice {
837
- type: "<em>voice</em>";
837
+ type: "voice";
838
838
  id: string;
839
839
  voice_url: string;
840
840
  title: string;
841
841
  caption?: string;
842
- parse_mode?: string;
842
+ parse_mode?: "HTML" | "MarkdownV2";
843
843
  caption_entities?: MessageEntity[];
844
844
  voice_duration?: number;
845
845
  reply_markup?: InlineKeyboardMarkup;
@@ -887,11 +887,11 @@ export interface InputLocationMessageContent {
887
887
  }
888
888
  export type InputMedia = InputMediaAnimation | InputMediaDocument | InputMediaAudio | InputMediaPhoto | InputMediaVideo;
889
889
  export interface InputMediaAnimation {
890
- type: "<em>animation</em>";
890
+ type: "animation";
891
891
  media: string;
892
892
  thumbnail?: InputFile | string;
893
893
  caption?: string;
894
- parse_mode?: string;
894
+ parse_mode?: "HTML" | "MarkdownV2";
895
895
  caption_entities?: MessageEntity[];
896
896
  show_caption_above_media?: boolean;
897
897
  width?: number;
@@ -900,40 +900,40 @@ export interface InputMediaAnimation {
900
900
  has_spoiler?: boolean;
901
901
  }
902
902
  export interface InputMediaAudio {
903
- type: "<em>audio</em>";
903
+ type: "audio";
904
904
  media: string;
905
905
  thumbnail?: InputFile | string;
906
906
  caption?: string;
907
- parse_mode?: string;
907
+ parse_mode?: "HTML" | "MarkdownV2";
908
908
  caption_entities?: MessageEntity[];
909
909
  duration?: number;
910
910
  performer?: string;
911
911
  title?: string;
912
912
  }
913
913
  export interface InputMediaDocument {
914
- type: "<em>document</em>";
914
+ type: "document";
915
915
  media: string;
916
916
  thumbnail?: InputFile | string;
917
917
  caption?: string;
918
- parse_mode?: string;
918
+ parse_mode?: "HTML" | "MarkdownV2";
919
919
  caption_entities?: MessageEntity[];
920
920
  disable_content_type_detection?: boolean;
921
921
  }
922
922
  export interface InputMediaPhoto {
923
- type: "<em>photo</em>";
923
+ type: "photo";
924
924
  media: string;
925
925
  caption?: string;
926
- parse_mode?: string;
926
+ parse_mode?: "HTML" | "MarkdownV2";
927
927
  caption_entities?: MessageEntity[];
928
928
  show_caption_above_media?: boolean;
929
929
  has_spoiler?: boolean;
930
930
  }
931
931
  export interface InputMediaVideo {
932
- type: "<em>video</em>";
932
+ type: "video";
933
933
  media: string;
934
934
  thumbnail?: InputFile | string;
935
935
  caption?: string;
936
- parse_mode?: string;
936
+ parse_mode?: "HTML" | "MarkdownV2";
937
937
  caption_entities?: MessageEntity[];
938
938
  show_caption_above_media?: boolean;
939
939
  width?: number;
@@ -945,11 +945,11 @@ export interface InputMediaVideo {
945
945
  export type InputMessageContent = InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent;
946
946
  export type InputPaidMedia = InputPaidMediaPhoto | InputPaidMediaVideo;
947
947
  export interface InputPaidMediaPhoto {
948
- type: "<em>photo</em>";
948
+ type: "photo";
949
949
  media: string;
950
950
  }
951
951
  export interface InputPaidMediaVideo {
952
- type: "<em>video</em>";
952
+ type: "video";
953
953
  media: string;
954
954
  thumbnail?: InputFile | string;
955
955
  width?: number;
@@ -959,7 +959,7 @@ export interface InputPaidMediaVideo {
959
959
  }
960
960
  export interface InputPollOption {
961
961
  text: string;
962
- text_parse_mode?: string;
962
+ text_parse_mode?: "HTML" | "MarkdownV2";
963
963
  text_entities?: MessageEntity[];
964
964
  }
965
965
  export interface InputSticker {
@@ -971,7 +971,7 @@ export interface InputSticker {
971
971
  }
972
972
  export interface InputTextMessageContent {
973
973
  message_text: string;
974
- parse_mode?: string;
974
+ parse_mode?: "HTML" | "MarkdownV2";
975
975
  entities?: MessageEntity[];
976
976
  link_preview_options?: LinkPreviewOptions;
977
977
  }
@@ -1046,9 +1046,9 @@ export interface Location {
1046
1046
  proximity_alert_radius?: number;
1047
1047
  }
1048
1048
  export interface LoginUrl {
1049
- url: "/widgets/login#checking-authorization";
1049
+ url: string;
1050
1050
  forward_text?: string;
1051
- bot_username?: "the same as the domain linked with the bot";
1051
+ bot_username?: string;
1052
1052
  request_write_access?: boolean;
1053
1053
  }
1054
1054
  export interface MaskPosition {
@@ -1060,13 +1060,13 @@ export interface MaskPosition {
1060
1060
  export type MaybeInaccessibleMessage = Message | InaccessibleMessage;
1061
1061
  export type MenuButton = MenuButtonCommands | MenuButtonWebApp | MenuButtonDefault;
1062
1062
  export interface MenuButtonCommands {
1063
- type: "<em>commands</em>";
1063
+ type: "commands";
1064
1064
  }
1065
1065
  export interface MenuButtonDefault {
1066
- type: "<em>default</em>";
1066
+ type: "default";
1067
1067
  }
1068
1068
  export interface MenuButtonWebApp {
1069
- type: "<em>web_app</em>";
1069
+ type: "web_app";
1070
1070
  text: string;
1071
1071
  web_app: WebAppInfo;
1072
1072
  }
@@ -1161,7 +1161,7 @@ export interface MessageAutoDeleteTimerChanged {
1161
1161
  message_auto_delete_time: number;
1162
1162
  }
1163
1163
  export interface MessageEntity {
1164
- type: string;
1164
+ type: "mention" | "hashtag" | "cashtag" | "bot_command" | "url" | "email" | "phone_number" | "bold" | "italic" | "underline" | "strikethrough" | "spoiler" | "blockquote" | "expandable_blockquote" | "code" | "pre" | "text_link" | "text_mention" | "custom_emoji";
1165
1165
  offset: number;
1166
1166
  length: number;
1167
1167
  url?: string;
@@ -1246,56 +1246,56 @@ export interface PassportData {
1246
1246
  }
1247
1247
  export type PassportElementError = PassportElementErrorDataField | PassportElementErrorFrontSide | PassportElementErrorReverseSide | PassportElementErrorSelfie | PassportElementErrorFile | PassportElementErrorFiles | PassportElementErrorTranslationFile | PassportElementErrorTranslationFiles | PassportElementErrorUnspecified;
1248
1248
  export interface PassportElementErrorDataField {
1249
- source: "<em>data</em>";
1249
+ source: "data";
1250
1250
  type: "personal_details" | "passport" | "driver_license" | "identity_card" | "internal_passport" | "address";
1251
1251
  field_name: string;
1252
1252
  data_hash: string;
1253
1253
  message: string;
1254
1254
  }
1255
1255
  export interface PassportElementErrorFile {
1256
- source: "<em>file</em>";
1256
+ source: "file";
1257
1257
  type: "utility_bill" | "bank_statement" | "rental_agreement" | "passport_registration" | "temporary_registration";
1258
1258
  file_hash: string;
1259
1259
  message: string;
1260
1260
  }
1261
1261
  export interface PassportElementErrorFiles {
1262
- source: "<em>files</em>";
1262
+ source: "files";
1263
1263
  type: "utility_bill" | "bank_statement" | "rental_agreement" | "passport_registration" | "temporary_registration";
1264
1264
  file_hashes: string[];
1265
1265
  message: string;
1266
1266
  }
1267
1267
  export interface PassportElementErrorFrontSide {
1268
- source: "<em>front_side</em>";
1268
+ source: "front_side";
1269
1269
  type: "passport" | "driver_license" | "identity_card" | "internal_passport";
1270
1270
  file_hash: string;
1271
1271
  message: string;
1272
1272
  }
1273
1273
  export interface PassportElementErrorReverseSide {
1274
- source: "<em>reverse_side</em>";
1274
+ source: "reverse_side";
1275
1275
  type: "driver_license" | "identity_card";
1276
1276
  file_hash: string;
1277
1277
  message: string;
1278
1278
  }
1279
1279
  export interface PassportElementErrorSelfie {
1280
- source: "<em>selfie</em>";
1280
+ source: "selfie";
1281
1281
  type: "passport" | "driver_license" | "identity_card" | "internal_passport";
1282
1282
  file_hash: string;
1283
1283
  message: string;
1284
1284
  }
1285
1285
  export interface PassportElementErrorTranslationFile {
1286
- source: "<em>translation_file</em>";
1286
+ source: "translation_file";
1287
1287
  type: "passport" | "driver_license" | "identity_card" | "internal_passport" | "utility_bill" | "bank_statement" | "rental_agreement" | "passport_registration" | "temporary_registration";
1288
1288
  file_hash: string;
1289
1289
  message: string;
1290
1290
  }
1291
1291
  export interface PassportElementErrorTranslationFiles {
1292
- source: "<em>translation_files</em>";
1292
+ source: "translation_files";
1293
1293
  type: "passport" | "driver_license" | "identity_card" | "internal_passport" | "utility_bill" | "bank_statement" | "rental_agreement" | "passport_registration" | "temporary_registration";
1294
1294
  file_hashes: string[];
1295
1295
  message: string;
1296
1296
  }
1297
1297
  export interface PassportElementErrorUnspecified {
1298
- source: "<em>unspecified</em>";
1298
+ source: "unspecified";
1299
1299
  type: string;
1300
1300
  element_hash: string;
1301
1301
  message: string;
@@ -1320,7 +1320,7 @@ export interface Poll {
1320
1320
  total_voter_count: number;
1321
1321
  is_closed: boolean;
1322
1322
  is_anonymous: boolean;
1323
- type: string;
1323
+ type: "regular" | "quiz";
1324
1324
  allows_multiple_answers: boolean;
1325
1325
  question_entities?: MessageEntity[];
1326
1326
  correct_option_id?: number;
@@ -1397,8 +1397,8 @@ export interface ReplyParameters {
1397
1397
  message_id: number;
1398
1398
  chat_id?: number | string;
1399
1399
  allow_sending_without_reply?: boolean;
1400
- quote?: "an exact substring of the message to be replied to";
1401
- quote_parse_mode?: string;
1400
+ quote?: string;
1401
+ quote_parse_mode?: "HTML" | "MarkdownV2";
1402
1402
  quote_entities?: MessageEntity[];
1403
1403
  quote_position?: number;
1404
1404
  }
@@ -0,0 +1,12 @@
1
+ import * as Micro from "effect/Micro";
2
+ import * as Context from "effect/Context";
3
+ import { TgBotClientConfig } from "../../client/config.js";
4
+ import { makeClientConfigFrom } from "./client-config.js";
5
+ import { makeBot } from "./make-bot.js";
6
+ export class BotFactoryService extends Context.Tag("BotFactoryService")() {
7
+ }
8
+ ;
9
+ export const BotFactoryServiceDefault = {
10
+ makeBot,
11
+ runBot: (input) => makeBot(input).pipe(Micro.provideServiceEffect(TgBotClientConfig, makeClientConfigFrom(input)))
12
+ };
@@ -0,0 +1,20 @@
1
+ import * as Micro from "effect/Micro";
2
+ import { readFileSync } from "fs";
3
+ import { makeTgBotClientConfig } from "../../client/config.js";
4
+ import { isTgBotClientSettingsInput } from "../../client/guards.js";
5
+ export const makeClientConfigFrom = (input) => Micro.gen(function* () {
6
+ if (input.type == "config") {
7
+ return makeTgBotClientConfig(input);
8
+ }
9
+ const config = yield* Micro.try({
10
+ try: () => JSON.parse(readFileSync("config.json").toString("utf-8")),
11
+ catch: error => {
12
+ console.warn(error);
13
+ return "ReadingConfigError";
14
+ }
15
+ });
16
+ if (!isTgBotClientSettingsInput(config)) {
17
+ return yield* Micro.fail("InvalidConfig");
18
+ }
19
+ return makeTgBotClientConfig(config);
20
+ });
@@ -0,0 +1,9 @@
1
+ import * as Micro from "effect/Micro";
2
+ import { BotUpdatePollerService, BotUpdatesPollerServiceDefault } from "../../bot/update-poller/_service.js";
3
+ export const makeBot = (messageHandler) => Micro.gen(function* () {
4
+ const { runBot } = yield* Micro.service(BotUpdatePollerService);
5
+ return yield* runBot(messageHandler);
6
+ }).pipe(Micro.provideServiceEffect(BotUpdatePollerService, BotUpdatesPollerServiceDefault), Micro.tapError(error => {
7
+ console.error(error);
8
+ return Micro.void;
9
+ }));
@@ -0,0 +1,4 @@
1
+ import * as Context from "effect/Context";
2
+ export class BotMessageHandler extends Context.Tag("BotMessageHandler")() {
3
+ }
4
+ ;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ export const extractUpdate = (input) => {
2
+ for (const [field, value] of Object.entries(input)) {
3
+ if (field == "update_id") {
4
+ continue;
5
+ }
6
+ return {
7
+ type: field,
8
+ ...value
9
+ };
10
+ }
11
+ return undefined;
12
+ };
@@ -0,0 +1,6 @@
1
+ import { Micro } from "effect";
2
+ import { BotFactoryServiceDefault } from "./factory/_service.js";
3
+ export const runTgChatBot = (input) => BotFactoryServiceDefault
4
+ .runBot(input)
5
+ .pipe(Micro.runPromise)
6
+ .finally(() => "Telegram chat bot has been shutdown");
@@ -0,0 +1,31 @@
1
+ import * as Micro from "effect/Micro";
2
+ import * as Context from "effect/Context";
3
+ import { ClientExecuteRequestService, ClientExecuteRequestServiceDefault } from "../../client/execute-request/_service.js";
4
+ import { pollAndHandle } from "./poll-and-handle.js";
5
+ export class BotUpdatePollerService extends Context.Tag("BotUpdatePollerService")() {
6
+ }
7
+ ;
8
+ export const BotUpdatesPollerServiceDefault = Micro.gen(function* () {
9
+ const state = {
10
+ isActive: false,
11
+ };
12
+ const client = yield* Micro.service(ClientExecuteRequestService);
13
+ const runBot = (messageHandler) => Micro.gen(function* () {
14
+ if (state.isActive) {
15
+ return yield* Micro.fail("AlreadyRunning");
16
+ }
17
+ const fiber = yield* pollAndHandle({
18
+ settings: messageHandler,
19
+ execute: client.execute
20
+ }).pipe(Micro.forkDaemon);
21
+ fiber.addObserver((exit) => {
22
+ console.log("bot's fiber has been closed", exit);
23
+ state.isActive = false;
24
+ });
25
+ console.log("Reading bot's updates...");
26
+ return fiber;
27
+ });
28
+ return {
29
+ runBot
30
+ };
31
+ }).pipe(Micro.provideServiceEffect(ClientExecuteRequestService, ClientExecuteRequestServiceDefault));
@@ -0,0 +1 @@
1
+ export {};