teh-bot 1.0.4 → 1.0.6

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,5 +1,5 @@
1
1
  import { EventEmitter } from "events"
2
- import type { ReadableStream } from "stream"
2
+ import type { ReadableStream, Stream } from "stream"
3
3
 
4
4
  export interface BotOptions {
5
5
  polling?: boolean
@@ -21,6 +21,12 @@ export interface User {
21
21
  last_name?: string
22
22
  username?: string
23
23
  language_code?: string
24
+ is_premium?: boolean
25
+ added_to_attachment_menu?: boolean
26
+ can_join_groups?: boolean
27
+ can_read_all_group_messages?: boolean
28
+ supports_inline_queries?: boolean
29
+ can_connect_to_business?: boolean
24
30
  }
25
31
 
26
32
  export interface Chat {
@@ -30,12 +36,58 @@ export interface Chat {
30
36
  username?: string
31
37
  first_name?: string
32
38
  last_name?: string
39
+ is_forum?: boolean
40
+ photo?: ChatPhoto
41
+ bio?: string
42
+ description?: string
43
+ invite_link?: string
44
+ pinned_message?: Message
45
+ permissions?: ChatPermissions
46
+ slow_mode_delay?: number
47
+ message_auto_delete_time?: number
48
+ has_protected_content?: boolean
49
+ sticker_set_name?: string
50
+ can_set_sticker_set?: boolean
51
+ linked_chat_id?: number
52
+ location?: ChatLocation
53
+ is_topic?: boolean
54
+ }
55
+
56
+ export interface ChatPhoto {
57
+ small_file_id: string
58
+ small_file_unique_id: string
59
+ big_file_id: string
60
+ big_file_unique_id: string
61
+ }
62
+
63
+ export interface ChatPermissions {
64
+ can_send_messages?: boolean
65
+ can_send_audios?: boolean
66
+ can_send_documents?: boolean
67
+ can_send_photos?: boolean
68
+ can_send_videos?: boolean
69
+ can_send_video_notes?: boolean
70
+ can_send_voice_notes?: boolean
71
+ can_send_polls?: boolean
72
+ can_send_other_messages?: boolean
73
+ can_add_web_page_previews?: boolean
74
+ can_change_info?: boolean
75
+ can_invite_users?: boolean
76
+ can_pin_messages?: boolean
77
+ can_manage_topics?: boolean
78
+ }
79
+
80
+ export interface ChatLocation {
81
+ location: Location
82
+ address: string
33
83
  }
34
84
 
35
85
  export interface Message {
36
86
  message_id: number
87
+ message_thread_id?: number
37
88
  from?: User
38
89
  sender_chat?: Chat
90
+ sender_boost_count?: number
39
91
  date: number
40
92
  chat: Chat
41
93
  forward_from?: User
@@ -44,26 +96,37 @@ export interface Message {
44
96
  forward_signature?: string
45
97
  forward_sender_name?: string
46
98
  forward_date?: number
99
+ is_topic_message?: boolean
100
+ is_automatic_forward?: boolean
47
101
  reply_to_message?: Message
102
+ external_reply_to_message?: ExternalReplyInfo
103
+ quote?: TextQuote
48
104
  via_bot?: User
49
105
  edit_date?: number
106
+ has_protected_content?: boolean
107
+ media_group_id?: string
108
+ author_signature?: string
50
109
  text?: string
51
110
  entities?: MessageEntity[]
52
- caption?: string
53
- caption_entities?: MessageEntity[]
54
- photo?: PhotoSize[]
111
+ link_preview_options?: LinkPreviewOptions
112
+ animation?: Animation
55
113
  audio?: Audio
56
114
  document?: Document
57
- animation?: Animation
115
+ photo?: PhotoSize[]
116
+ sticker?: Sticker
117
+ story?: Story
58
118
  video?: Video
59
- voice?: Voice
60
119
  video_note?: VideoNote
61
- sticker?: Sticker
62
- location?: Location
63
- venue?: Venue
120
+ voice?: Voice
121
+ caption?: string
122
+ caption_entities?: MessageEntity[]
123
+ has_media_spoiler?: boolean
64
124
  contact?: Contact
65
- poll?: Poll
66
125
  dice?: Dice
126
+ game?: Game
127
+ poll?: Poll
128
+ venue?: Venue
129
+ location?: Location
67
130
  new_chat_members?: User[]
68
131
  left_chat_member?: User
69
132
  new_chat_title?: string
@@ -72,9 +135,34 @@ export interface Message {
72
135
  group_chat_created?: boolean
73
136
  supergroup_chat_created?: boolean
74
137
  channel_chat_created?: boolean
138
+ message_auto_delete_timer_changed?: MessageAutoDeleteTimerChanged
75
139
  migrate_to_chat_id?: number
76
140
  migrate_from_chat_id?: number
77
141
  pinned_message?: Message
142
+ invoice?: Invoice
143
+ successful_payment?: SuccessfulPayment
144
+ users_shared?: UsersShared
145
+ chat_shared?: ChatShared
146
+ connected_website?: string
147
+ write_access_allowed?: WriteAccessAllowed
148
+ passport_data?: PassportData
149
+ proximity_alert_triggered?: ProximityAlertTriggered
150
+ forum_topic_created?: ForumTopicCreated
151
+ forum_topic_edited?: ForumTopicEdited
152
+ forum_topic_closed?: ForumTopicClosed
153
+ forum_topic_reopened?: ForumTopicReopened
154
+ general_forum_topic_hidden?: GeneralForumTopicHidden
155
+ general_forum_topic_unhidden?: GeneralForumTopicUnhidden
156
+ giveaway_created?: GiveawayCreated
157
+ giveaway?: Giveaway
158
+ giveaway_winners?: GiveawayWinners
159
+ giveaway_completed?: GiveawayCompleted
160
+ video_chat_scheduled?: VideoChatScheduled
161
+ video_chat_started?: VideoChatStarted
162
+ video_chat_ended?: VideoChatEnded
163
+ video_chat_participants_invited?: VideoChatParticipantsInvited
164
+ web_app_data?: WebAppData
165
+ reply_markup?: InlineKeyboardMarkup
78
166
  }
79
167
 
80
168
  export interface MessageEntity {
@@ -84,6 +172,60 @@ export interface MessageEntity {
84
172
  url?: string
85
173
  user?: User
86
174
  language?: string
175
+ custom_emoji_id?: string
176
+ }
177
+
178
+ export interface TextQuote {
179
+ text: string
180
+ entities?: MessageEntity[]
181
+ position: number
182
+ is_manual?: boolean
183
+ }
184
+
185
+ export interface ExternalReplyInfo {
186
+ origin: MessageOrigin
187
+ chat?: Chat
188
+ message_id?: number
189
+ link_preview_options?: LinkPreviewOptions
190
+ animation?: Animation
191
+ audio?: Audio
192
+ document?: Document
193
+ photo?: PhotoSize[]
194
+ sticker?: Sticker
195
+ story?: Story
196
+ video?: Video
197
+ video_note?: VideoNote
198
+ voice?: Voice
199
+ has_media_spoiler?: boolean
200
+ contact?: Contact
201
+ dice?: Dice
202
+ game?: Game
203
+ giveaway?: Giveaway
204
+ giveaway_winners?: GiveawayWinners
205
+ invoice?: Invoice
206
+ location?: Location
207
+ poll?: Poll
208
+ venue?: Venue
209
+ }
210
+
211
+ export interface MessageOrigin {
212
+ type: string
213
+ date: number
214
+ user_id?: number
215
+ sender_user_id?: number
216
+ sender_user_name?: string
217
+ sender_chat?: Chat
218
+ author_signature?: string
219
+ chat?: Chat
220
+ message_id?: number
221
+ }
222
+
223
+ export interface LinkPreviewOptions {
224
+ is_disabled?: boolean
225
+ url?: string
226
+ prefer_small_media?: boolean
227
+ prefer_large_media?: boolean
228
+ show_above_text?: boolean
87
229
  }
88
230
 
89
231
  export interface PhotoSize {
@@ -157,6 +299,7 @@ export interface VideoNote {
157
299
  export interface Sticker {
158
300
  file_id: string
159
301
  file_unique_id: string
302
+ type: string
160
303
  width: number
161
304
  height: number
162
305
  is_animated: boolean
@@ -164,8 +307,22 @@ export interface Sticker {
164
307
  thumb?: PhotoSize
165
308
  emoji?: string
166
309
  set_name?: string
310
+ premium_animation?: File
167
311
  mask_position?: MaskPosition
312
+ custom_emoji_id?: string
313
+ file_size?: number
314
+ }
315
+
316
+ export interface Story {
317
+ forward_from_chat_id?: number
318
+ forward_from_message_id?: number
319
+ }
320
+
321
+ export interface File {
322
+ file_id: string
323
+ file_unique_id: string
168
324
  file_size?: number
325
+ file_path?: string
169
326
  }
170
327
 
171
328
  export interface MaskPosition {
@@ -190,6 +347,8 @@ export interface Venue {
190
347
  address: string
191
348
  foursquare_id?: string
192
349
  foursquare_type?: string
350
+ google_place_id?: string
351
+ google_place_type?: string
193
352
  }
194
353
 
195
354
  export interface Contact {
@@ -200,25 +359,47 @@ export interface Contact {
200
359
  vcard?: string
201
360
  }
202
361
 
362
+ export interface Dice {
363
+ emoji: string
364
+ value: number
365
+ }
366
+
367
+ export interface Game {
368
+ title: string
369
+ description: string
370
+ photo: PhotoSize[]
371
+ text?: string
372
+ text_entities?: MessageEntity[]
373
+ animation?: Animation
374
+ }
375
+
203
376
  export interface Poll {
204
377
  id: string
205
378
  question: string
379
+ question_entities?: MessageEntity[]
206
380
  options: PollOption[]
207
381
  total_voter_count: number
208
382
  is_closed: boolean
209
383
  is_anonymous: boolean
210
384
  type: string
211
385
  allows_multiple_answers: boolean
386
+ explanation?: string
387
+ explanation_entities?: MessageEntity[]
388
+ open_period?: number
389
+ close_date?: number
212
390
  }
213
391
 
214
392
  export interface PollOption {
215
393
  text: string
394
+ text_entities?: MessageEntity[]
216
395
  voter_count: number
396
+ is_chosen?: boolean
217
397
  }
218
398
 
219
- export interface Dice {
220
- emoji: string
221
- value: number
399
+ export interface PollAnswer {
400
+ poll_id: string
401
+ user: User
402
+ option_ids: number[]
222
403
  }
223
404
 
224
405
  export interface Update {
@@ -227,13 +408,49 @@ export interface Update {
227
408
  edited_message?: Message
228
409
  channel_post?: Message
229
410
  edited_channel_post?: Message
411
+ message_reaction?: MessageReactionUpdated
412
+ message_reaction_count?: MessageReactionCountUpdated
230
413
  inline_query?: InlineQuery
231
414
  chosen_inline_result?: ChosenInlineResult
232
415
  callback_query?: CallbackQuery
416
+ shipping_query?: ShippingQuery
417
+ pre_checkout_query?: PreCheckoutQuery
233
418
  poll?: Poll
234
419
  poll_answer?: PollAnswer
235
420
  my_chat_member?: ChatMemberUpdated
236
421
  chat_member?: ChatMemberUpdated
422
+ chat_join_request?: ChatJoinRequest
423
+ chat_boost?: ChatBoostUpdated
424
+ removed_chat_boost?: ChatBoostRemoved
425
+ }
426
+
427
+ export interface MessageReactionUpdated {
428
+ chat: Chat
429
+ message_id: number
430
+ user?: User
431
+ actor_chat?: Chat
432
+ date: number
433
+ old_reaction: ReactionType[]
434
+ new_reaction: ReactionType[]
435
+ }
436
+
437
+ export interface MessageReactionCountUpdated {
438
+ chat: Chat
439
+ message_id: number
440
+ date: number
441
+ reactions: ReactionCount[]
442
+ }
443
+
444
+ export interface ReactionType {
445
+ type: string
446
+ emoji?: string
447
+ custom_emoji_id?: string
448
+ }
449
+
450
+ export interface ReactionCount {
451
+ type: ReactionType
452
+ total_count: number
453
+ recent_donators?: User[]
237
454
  }
238
455
 
239
456
  export interface InlineQuery {
@@ -263,10 +480,37 @@ export interface CallbackQuery {
263
480
  game_short_name?: string
264
481
  }
265
482
 
266
- export interface PollAnswer {
267
- poll_id: string
268
- user: User
269
- option_ids: number[]
483
+ export interface ShippingQuery {
484
+ id: string
485
+ from: User
486
+ invoice_payload: string
487
+ shipping_address: ShippingAddress
488
+ }
489
+
490
+ export interface ShippingAddress {
491
+ country_code: string
492
+ state: string
493
+ city: string
494
+ street_line1: string
495
+ street_line2: string
496
+ post_code: string
497
+ }
498
+
499
+ export interface PreCheckoutQuery {
500
+ id: string
501
+ from: User
502
+ currency: string
503
+ total_amount: number
504
+ invoice_payload: string
505
+ shipping_option_id?: string
506
+ order_info?: OrderInfo
507
+ }
508
+
509
+ export interface OrderInfo {
510
+ name?: string
511
+ phone_number?: string
512
+ email?: string
513
+ shipping_address?: ShippingAddress
270
514
  }
271
515
 
272
516
  export interface ChatMemberUpdated {
@@ -276,6 +520,7 @@ export interface ChatMemberUpdated {
276
520
  old_chat_member: ChatMember
277
521
  new_chat_member: ChatMember
278
522
  invite_link?: ChatInviteLink
523
+ via_chat_folder_invite_link?: boolean
279
524
  }
280
525
 
281
526
  export interface ChatMember {
@@ -294,9 +539,15 @@ export interface ChatMember {
294
539
  can_change_info?: boolean
295
540
  can_invite_users?: boolean
296
541
  can_pin_messages?: boolean
542
+ can_manage_topics?: boolean
297
543
  is_member?: boolean
298
544
  can_send_messages?: boolean
299
- can_send_media_messages?: boolean
545
+ can_send_audios?: boolean
546
+ can_send_documents?: boolean
547
+ can_send_photos?: boolean
548
+ can_send_videos?: boolean
549
+ can_send_video_notes?: boolean
550
+ can_send_voice_notes?: boolean
300
551
  can_send_polls?: boolean
301
552
  can_send_other_messages?: boolean
302
553
  can_add_web_page_previews?: boolean
@@ -315,6 +566,189 @@ export interface ChatInviteLink {
315
566
  pending_join_request_count?: number
316
567
  }
317
568
 
569
+ export interface ChatJoinRequest {
570
+ chat: Chat
571
+ from: User
572
+ user_chat_id: number
573
+ date: number
574
+ bio?: string
575
+ invite_link?: ChatInviteLink
576
+ }
577
+
578
+ export interface ChatBoostUpdated {
579
+ chat: Chat
580
+ boost: ChatBoost
581
+ }
582
+
583
+ export interface ChatBoost {
584
+ boost_id: string
585
+ user_id: number
586
+ expiration_date: number
587
+ start_date: number
588
+ }
589
+
590
+ export interface ChatBoostRemoved {
591
+ chat: Chat
592
+ boost_id: string
593
+ remove_date: number
594
+ source: ChatBoostSource
595
+ }
596
+
597
+ export interface ChatBoostSource {
598
+ source: string
599
+ user?: User
600
+ }
601
+
602
+ export interface VideoChatScheduled {
603
+ start_date: number
604
+ }
605
+
606
+ export interface VideoChatStarted {}
607
+
608
+ export interface VideoChatEnded {
609
+ duration: number
610
+ }
611
+
612
+ export interface VideoChatParticipantsInvited {
613
+ users: User[]
614
+ }
615
+
616
+ export interface WebAppData {
617
+ data: string
618
+ button_text: string
619
+ }
620
+
621
+ export interface ProximityAlertTriggered {
622
+ traveler: User
623
+ watcher: User
624
+ distance: number
625
+ }
626
+
627
+ export interface MessageAutoDeleteTimerChanged {
628
+ message_auto_delete_time: number
629
+ }
630
+
631
+ export interface ForumTopicCreated {
632
+ name: string
633
+ icon_color: number
634
+ icon_custom_emoji_id?: string
635
+ }
636
+
637
+ export interface ForumTopicEdited {
638
+ name?: string
639
+ icon_custom_emoji_id?: string
640
+ }
641
+
642
+ export interface ForumTopicClosed {}
643
+
644
+ export interface ForumTopicReopened {}
645
+
646
+ export interface GeneralForumTopicHidden {}
647
+
648
+ export interface GeneralForumTopicUnhidden {}
649
+
650
+ export interface GiveawayCreated {
651
+ parameters?: GiveawayParameters
652
+ }
653
+
654
+ export interface Giveaway {
655
+ chats: Chat[]
656
+ winners_selection_date: number
657
+ winner_count: number
658
+ only_new_members?: boolean
659
+ has_public_winners?: boolean
660
+ prize_description?: string
661
+ country_codes?: string[]
662
+ premium_subscription_month_count?: number
663
+ }
664
+
665
+ export interface GiveawayWinners {
666
+ chat: Chat
667
+ giveaway_message_id: number
668
+ winners_selection_date: number
669
+ winner_count: number
670
+ winners: User[]
671
+ additional_chat_count?: number
672
+ premium_subscription_month_count?: number
673
+ unclaimed_prize_count?: number
674
+ only_new_members?: boolean
675
+ was_refunded?: boolean
676
+ prize_description?: string
677
+ }
678
+
679
+ export interface GiveawayCompleted {
680
+ winner_count: number
681
+ unclaimed_prize_count?: number
682
+ giveaway_message?: Message
683
+ }
684
+
685
+ export interface GiveawayParameters {
686
+ boosted_chat_id: number
687
+ }
688
+
689
+ export interface UsersShared {
690
+ request_id: number
691
+ user_ids: number[]
692
+ }
693
+
694
+ export interface ChatShared {
695
+ request_id: number
696
+ chat_id: number
697
+ }
698
+
699
+ export interface WriteAccessAllowed {
700
+ web_app_name?: string
701
+ }
702
+
703
+ export interface PassportData {
704
+ data: EncryptedPassportElement[]
705
+ credentials: EncryptedCredentials
706
+ }
707
+
708
+ export interface EncryptedPassportElement {
709
+ type: string
710
+ hash: string
711
+ data?: string
712
+ phone_number?: string
713
+ email?: string
714
+ files?: PassportFile[]
715
+ front_side?: PassportFile
716
+ reverse_side?: PassportFile
717
+ selfie?: PassportFile
718
+ translation?: PassportFile[]
719
+ }
720
+
721
+ export interface PassportFile {
722
+ file_id: string
723
+ file_unique_id: string
724
+ file_size: number
725
+ file_date: number
726
+ }
727
+
728
+ export interface EncryptedCredentials {
729
+ data: string
730
+ hash: string
731
+ secret: string
732
+ }
733
+
734
+ export interface Invoice {
735
+ title: string
736
+ description: string
737
+ start_parameter: string
738
+ currency: string
739
+ total_amount: number
740
+ }
741
+
742
+ export interface SuccessfulPayment {
743
+ currency: string
744
+ total_amount: number
745
+ invoice_payload: string
746
+ shipping_option_id?: string
747
+ order_info?: OrderInfo
748
+ telegram_payment_charge_id: string
749
+ provider_payment_charge_id: string
750
+ }
751
+
318
752
  export interface InlineKeyboardMarkup {
319
753
  inline_keyboard: InlineKeyboardButton[][]
320
754
  }
@@ -323,32 +757,91 @@ export interface InlineKeyboardButton {
323
757
  text: string
324
758
  url?: string
325
759
  callback_data?: string
760
+ web_app?: WebAppInfo
761
+ login_url?: LoginUrl
326
762
  switch_inline_query?: string
327
763
  switch_inline_query_current_chat?: string
764
+ switch_inline_query_chosen_chat?: SwitchInlineQueryChosenChat
328
765
  callback_game?: any
329
766
  pay?: boolean
330
- login_url?: any
767
+ }
768
+
769
+ export interface WebAppInfo {
770
+ url: string
771
+ }
772
+
773
+ export interface LoginUrl {
774
+ url: string
775
+ forward_text?: string
776
+ bot_username?: string
777
+ request_write_access?: boolean
778
+ }
779
+
780
+ export interface SwitchInlineQueryChosenChat {
781
+ allow_user_chats?: boolean
782
+ allow_bot_chats?: boolean
783
+ allow_group_chats?: boolean
784
+ allow_channel_chats?: boolean
331
785
  }
332
786
 
333
787
  export interface ReplyKeyboardMarkup {
334
788
  keyboard: KeyboardButton[][]
789
+ is_persistent?: boolean
335
790
  resize_keyboard?: boolean
336
791
  one_time_keyboard?: boolean
337
- selective?: boolean
338
792
  input_field_placeholder?: string
793
+ selective?: boolean
339
794
  }
340
795
 
341
796
  export interface KeyboardButton {
342
797
  text: string
798
+ request_user?: KeyboardButtonRequestUser
799
+ request_chat?: KeyboardButtonRequestChat
343
800
  request_contact?: boolean
344
801
  request_location?: boolean
345
802
  request_poll?: KeyboardButtonPollType
803
+ request_location_access_denied?: boolean
804
+ web_app?: WebAppInfo
805
+ }
806
+
807
+ export interface KeyboardButtonRequestUser {
808
+ request_id: number
809
+ user_is_bot?: boolean
810
+ user_is_premium?: boolean
811
+ max_quantity?: number
812
+ }
813
+
814
+ export interface KeyboardButtonRequestChat {
815
+ request_id: number
816
+ chat_is_channel: boolean
817
+ chat_is_forum?: boolean
818
+ chat_is_group_n_supergroup?: boolean
819
+ chat_is_created?: boolean
820
+ user_administrator_rights?: ChatAdministratorRights
821
+ bot_administrator_rights?: ChatAdministratorRights
822
+ bot_is_member?: boolean
823
+ max_quantity?: number
346
824
  }
347
825
 
348
826
  export interface KeyboardButtonPollType {
349
827
  type?: string
350
828
  }
351
829
 
830
+ export interface ChatAdministratorRights {
831
+ is_anonymous?: boolean
832
+ can_manage_chat?: boolean
833
+ can_delete_messages?: boolean
834
+ can_manage_video_chats?: boolean
835
+ can_restrict_members?: boolean
836
+ can_promote_members?: boolean
837
+ can_change_info?: boolean
838
+ can_invite_users?: boolean
839
+ can_post_messages?: boolean
840
+ can_edit_messages?: boolean
841
+ can_pin_messages?: boolean
842
+ can_manage_topics?: boolean
843
+ }
844
+
352
845
  export interface ReplyKeyboardRemove {
353
846
  remove_keyboard: true
354
847
  selective?: boolean
@@ -356,24 +849,27 @@ export interface ReplyKeyboardRemove {
356
849
 
357
850
  export interface ForceReply {
358
851
  force_reply: true
359
- selective?: boolean
360
852
  input_field_placeholder?: string
853
+ selective?: boolean
361
854
  }
362
855
 
363
856
  export interface SendMessageOptions {
364
857
  parse_mode?: "Markdown" | "MarkdownV2" | "HTML"
365
858
  entities?: MessageEntity[]
366
- disable_web_page_preview?: boolean
859
+ link_preview_options?: LinkPreviewOptions
367
860
  disable_notification?: boolean
368
861
  protect_content?: boolean
369
862
  reply_to_message_id?: number
370
863
  allow_sending_without_reply?: boolean
371
864
  reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply
865
+ message_thread_id?: number
866
+ business_connection_id?: string
372
867
  }
373
868
 
374
869
  export interface SendPhotoOptions extends SendMessageOptions {
375
870
  caption?: string
376
871
  caption_entities?: MessageEntity[]
872
+ show_caption_above_media?: boolean
377
873
  }
378
874
 
379
875
  export interface SendDocumentOptions extends SendMessageOptions {
@@ -451,7 +947,6 @@ export class TelegramBot extends EventEmitter {
451
947
  constructor(token: string, options?: BotOptions)
452
948
 
453
949
  request(method: string, params?: any, formData?: any): Promise<any>
454
- queuedRequest(method: string, params?: any, formData?: any): Promise<any>
455
950
 
456
951
  getMe(): Promise<User>
457
952
  getUpdates(params?: any): Promise<Update[]>