grammy 1.37.0 β†’ 1.37.1

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.
package/README.md CHANGED
@@ -106,7 +106,6 @@ The Russian community chat can be found [here](https://t.me/grammyjs_ru).
106
106
  ### [grammY news](https://t.me/grammyjs_news)
107
107
 
108
108
  β€”The channel where updates to grammY and the ecosystem are posted.
109
- We are also [on Twitter](https://twitter.com/grammy_js).
110
109
 
111
110
  ### [Telegram Bot API Reference](https://core.telegram.org/bots/api)
112
111
 
@@ -148,7 +147,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
148
147
  <td align="center" valign="top" width="11.11%"><a href="https://github.com/MegaITA"><img src="https://avatars.githubusercontent.com/u/32493080?v=4?s=100" width="100px;" alt="Alessandro Bertozzi"/><br /><sub><b>Alessandro Bertozzi</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=MegaITA" title="Documentation">πŸ“–</a></td>
149
148
  <td align="center" valign="top" width="11.11%"><a href="https://trgwii.no/"><img src="https://avatars.githubusercontent.com/u/11262022?v=4?s=100" width="100px;" alt="trgwii"/><br /><sub><b>trgwii</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=trgwii" title="Code">πŸ’»</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Atrgwii" title="Reviewed Pull Requests">πŸ‘€</a></td>
150
149
  <td align="center" valign="top" width="11.11%"><a href="https://github.com/KnightNiwrem"><img src="https://avatars.githubusercontent.com/u/9781814?v=4?s=100" width="100px;" alt="KnightNiwrem"/><br /><sub><b>KnightNiwrem</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=KnightNiwrem" title="Code">πŸ’»</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3AKnightNiwrem" title="Bug reports">πŸ›</a> <a href="#plugin-KnightNiwrem" title="Plugin/utility libraries">πŸ”Œ</a> <a href="https://github.com/grammyjs/grammY/commits?author=KnightNiwrem" title="Documentation">πŸ“–</a> <a href="#example-KnightNiwrem" title="Examples">πŸ’‘</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AKnightNiwrem" title="Reviewed Pull Requests">πŸ‘€</a> <a href="#mentoring-KnightNiwrem" title="Mentoring">πŸ§‘β€πŸ«</a></td>
151
- <td align="center" valign="top" width="11.11%"><a href="https://mkr.pw"><img src="https://avatars.githubusercontent.com/u/19621208?v=4?s=100" width="100px;" alt="Muthu Kumar"/><br /><sub><b>Muthu Kumar</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AMKRhere" title="Reviewed Pull Requests">πŸ‘€</a></td>
150
+ <td align="center" valign="top" width="11.11%"><a href="https://mkr.pw"><img src="https://avatars.githubusercontent.com/u/19621208?v=4?s=100" width="100px;" alt="Muthu Kumar"/><br /><sub><b>Muthu Kumar</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AMKRhere" title="Reviewed Pull Requests">πŸ‘€</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3AMKRhere" title="Bug reports">πŸ›</a> <a href="https://github.com/grammyjs/grammY/commits?author=MKRhere" title="Code">πŸ’»</a></td>
152
151
  <td align="center" valign="top" width="11.11%"><a href="https://edjopato.de/"><img src="https://avatars.githubusercontent.com/u/7953011?v=4?s=100" width="100px;" alt="EdJoPaTo"/><br /><sub><b>EdJoPaTo</b></sub></a><br /><a href="#plugin-EdJoPaTo" title="Plugin/utility libraries">πŸ”Œ</a> <a href="https://github.com/grammyjs/grammY/commits?author=EdJoPaTo" title="Documentation">πŸ“–</a> <a href="#ideas-EdJoPaTo" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AEdJoPaTo" title="Reviewed Pull Requests">πŸ‘€</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3AEdJoPaTo" title="Bug reports">πŸ›</a> <a href="https://github.com/grammyjs/grammY/commits?author=EdJoPaTo" title="Code">πŸ’»</a></td>
153
152
  <td align="center" valign="top" width="11.11%"><a href="https://github.com/Amir-Zouerami"><img src="https://avatars.githubusercontent.com/u/53701884?v=4?s=100" width="100px;" alt="Amir Zouerami"/><br /><sub><b>Amir Zouerami</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Amir-Zouerami" title="Documentation">πŸ“–</a> <a href="#plugin-Amir-Zouerami" title="Plugin/utility libraries">πŸ”Œ</a> <a href="#example-Amir-Zouerami" title="Examples">πŸ’‘</a></td>
154
153
  </tr>
package/out/context.d.ts CHANGED
@@ -513,7 +513,7 @@ export declare class Context implements RenamedUpdate {
513
513
  *
514
514
  * **Official reference:** https://core.telegram.org/bots/api#copymessages
515
515
  */
516
- copyMessages(chat_id: number | string, message_ids: number[], other?: Other<"copyMessages", "chat_id" | "from_chat_id" | "message_id">, signal?: AbortSignal): Promise<import("@grammyjs/types/message.js").MessageId[]>;
516
+ copyMessages(chat_id: number | string, message_ids: number[], other?: Other<"copyMessages", "chat_id" | "from_chat_id" | "message_ids">, signal?: AbortSignal): Promise<import("@grammyjs/types/message.js").MessageId[]>;
517
517
  /**
518
518
  * Context-aware alias for `api.sendPhoto`. Use this method to send photos. On success, the sent Message is returned.
519
519
  *
@@ -1023,6 +1023,7 @@ export declare class Context implements RenamedUpdate {
1023
1023
  * Context-aware alias for `api.unpinChatMessage`. Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.
1024
1024
  *
1025
1025
  * @param message_id Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be unpinned.
1026
+ * @param other Optional remaining parameters, confer the official reference below
1026
1027
  * @param signal Optional `AbortSignal` to cancel the request
1027
1028
  *
1028
1029
  * **Official reference:** https://core.telegram.org/bots/api#unpinchatmessage
package/out/context.js CHANGED
@@ -666,7 +666,12 @@ class Context {
666
666
  * **Official reference:** https://core.telegram.org/bots/api#sendmessage
667
667
  */
668
668
  reply(text, other, signal) {
669
- return this.api.sendMessage(orThrow(this.chatId, "sendMessage"), text, { business_connection_id: this.businessConnectionId, ...other }, signal);
669
+ var _a;
670
+ return this.api.sendMessage(orThrow(this.chatId, "sendMessage"), text, {
671
+ business_connection_id: this.businessConnectionId,
672
+ message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id,
673
+ ...other,
674
+ }, signal);
670
675
  }
671
676
  /**
672
677
  * Context-aware alias for `api.forwardMessage`. Use this method to forward messages of any kind. Service messages and messages with protected content can't be forwarded. On success, the sent Message is returned.
@@ -678,7 +683,8 @@ class Context {
678
683
  * **Official reference:** https://core.telegram.org/bots/api#forwardmessage
679
684
  */
680
685
  forwardMessage(chat_id, other, signal) {
681
- return this.api.forwardMessage(chat_id, orThrow(this.chatId, "forwardMessage"), orThrow(this.msgId, "forwardMessage"), other, signal);
686
+ var _a;
687
+ return this.api.forwardMessage(chat_id, orThrow(this.chatId, "forwardMessage"), orThrow(this.msgId, "forwardMessage"), { message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id, ...other }, signal);
682
688
  }
683
689
  /**
684
690
  * Context-aware alias for `api.forwardMessages`. Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. On success, an array of MessageId of the sent messages is returned.
@@ -691,7 +697,8 @@ class Context {
691
697
  * **Official reference:** https://core.telegram.org/bots/api#forwardmessages
692
698
  */
693
699
  forwardMessages(chat_id, message_ids, other, signal) {
694
- return this.api.forwardMessages(chat_id, orThrow(this.chatId, "forwardMessages"), message_ids, other, signal);
700
+ var _a;
701
+ return this.api.forwardMessages(chat_id, orThrow(this.chatId, "forwardMessages"), message_ids, { message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id, ...other }, signal);
695
702
  }
696
703
  /**
697
704
  * Context-aware alias for `api.copyMessage`. Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success.
@@ -703,7 +710,8 @@ class Context {
703
710
  * **Official reference:** https://core.telegram.org/bots/api#copymessage
704
711
  */
705
712
  copyMessage(chat_id, other, signal) {
706
- return this.api.copyMessage(chat_id, orThrow(this.chatId, "copyMessage"), orThrow(this.msgId, "copyMessage"), other, signal);
713
+ var _a;
714
+ return this.api.copyMessage(chat_id, orThrow(this.chatId, "copyMessage"), orThrow(this.msgId, "copyMessage"), { message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id, ...other }, signal);
707
715
  }
708
716
  /**
709
717
  * Context-aware alias for `api.copyMessages`. Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an array of MessageId of the sent messages is returned.
@@ -716,7 +724,8 @@ class Context {
716
724
  * **Official reference:** https://core.telegram.org/bots/api#copymessages
717
725
  */
718
726
  copyMessages(chat_id, message_ids, other, signal) {
719
- return this.api.copyMessages(chat_id, orThrow(this.chatId, "copyMessages"), message_ids, other, signal);
727
+ var _a;
728
+ return this.api.copyMessages(chat_id, orThrow(this.chatId, "copyMessages"), message_ids, { message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id, ...other }, signal);
720
729
  }
721
730
  /**
722
731
  * Context-aware alias for `api.sendPhoto`. Use this method to send photos. On success, the sent Message is returned.
@@ -728,7 +737,12 @@ class Context {
728
737
  * **Official reference:** https://core.telegram.org/bots/api#sendphoto
729
738
  */
730
739
  replyWithPhoto(photo, other, signal) {
731
- return this.api.sendPhoto(orThrow(this.chatId, "sendPhoto"), photo, { business_connection_id: this.businessConnectionId, ...other }, signal);
740
+ var _a;
741
+ return this.api.sendPhoto(orThrow(this.chatId, "sendPhoto"), photo, {
742
+ business_connection_id: this.businessConnectionId,
743
+ message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id,
744
+ ...other,
745
+ }, signal);
732
746
  }
733
747
  /**
734
748
  * Context-aware alias for `api.sendAudio`. Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
@@ -742,7 +756,12 @@ class Context {
742
756
  * **Official reference:** https://core.telegram.org/bots/api#sendaudio
743
757
  */
744
758
  replyWithAudio(audio, other, signal) {
745
- return this.api.sendAudio(orThrow(this.chatId, "sendAudio"), audio, { business_connection_id: this.businessConnectionId, ...other }, signal);
759
+ var _a;
760
+ return this.api.sendAudio(orThrow(this.chatId, "sendAudio"), audio, {
761
+ business_connection_id: this.businessConnectionId,
762
+ message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id,
763
+ ...other,
764
+ }, signal);
746
765
  }
747
766
  /**
748
767
  * Context-aware alias for `api.sendDocument`. Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
@@ -754,7 +773,12 @@ class Context {
754
773
  * **Official reference:** https://core.telegram.org/bots/api#senddocument
755
774
  */
756
775
  replyWithDocument(document, other, signal) {
757
- return this.api.sendDocument(orThrow(this.chatId, "sendDocument"), document, { business_connection_id: this.businessConnectionId, ...other }, signal);
776
+ var _a;
777
+ return this.api.sendDocument(orThrow(this.chatId, "sendDocument"), document, {
778
+ business_connection_id: this.businessConnectionId,
779
+ message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id,
780
+ ...other,
781
+ }, signal);
758
782
  }
759
783
  /**
760
784
  * Context-aware alias for `api.sendVideo`. Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
@@ -766,7 +790,12 @@ class Context {
766
790
  * **Official reference:** https://core.telegram.org/bots/api#sendvideo
767
791
  */
768
792
  replyWithVideo(video, other, signal) {
769
- return this.api.sendVideo(orThrow(this.chatId, "sendVideo"), video, { business_connection_id: this.businessConnectionId, ...other }, signal);
793
+ var _a;
794
+ return this.api.sendVideo(orThrow(this.chatId, "sendVideo"), video, {
795
+ business_connection_id: this.businessConnectionId,
796
+ message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id,
797
+ ...other,
798
+ }, signal);
770
799
  }
771
800
  /**
772
801
  * Context-aware alias for `api.sendAnimation`. Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.
@@ -778,7 +807,12 @@ class Context {
778
807
  * **Official reference:** https://core.telegram.org/bots/api#sendanimation
779
808
  */
780
809
  replyWithAnimation(animation, other, signal) {
781
- return this.api.sendAnimation(orThrow(this.chatId, "sendAnimation"), animation, { business_connection_id: this.businessConnectionId, ...other }, signal);
810
+ var _a;
811
+ return this.api.sendAnimation(orThrow(this.chatId, "sendAnimation"), animation, {
812
+ business_connection_id: this.businessConnectionId,
813
+ message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id,
814
+ ...other,
815
+ }, signal);
782
816
  }
783
817
  /**
784
818
  * Context-aware alias for `api.sendVoice`. Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
@@ -790,7 +824,12 @@ class Context {
790
824
  * **Official reference:** https://core.telegram.org/bots/api#sendvoice
791
825
  */
792
826
  replyWithVoice(voice, other, signal) {
793
- return this.api.sendVoice(orThrow(this.chatId, "sendVoice"), voice, { business_connection_id: this.businessConnectionId, ...other }, signal);
827
+ var _a;
828
+ return this.api.sendVoice(orThrow(this.chatId, "sendVoice"), voice, {
829
+ business_connection_id: this.businessConnectionId,
830
+ message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id,
831
+ ...other,
832
+ }, signal);
794
833
  }
795
834
  /**
796
835
  * Context-aware alias for `api.sendVideoNote`. Use this method to send video messages. On success, the sent Message is returned.
@@ -803,7 +842,12 @@ class Context {
803
842
  * **Official reference:** https://core.telegram.org/bots/api#sendvideonote
804
843
  */
805
844
  replyWithVideoNote(video_note, other, signal) {
806
- return this.api.sendVideoNote(orThrow(this.chatId, "sendVideoNote"), video_note, { business_connection_id: this.businessConnectionId, ...other }, signal);
845
+ var _a;
846
+ return this.api.sendVideoNote(orThrow(this.chatId, "sendVideoNote"), video_note, {
847
+ business_connection_id: this.businessConnectionId,
848
+ message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id,
849
+ ...other,
850
+ }, signal);
807
851
  }
808
852
  /**
809
853
  * Context-aware alias for `api.sendMediaGroup`. Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned.
@@ -815,7 +859,12 @@ class Context {
815
859
  * **Official reference:** https://core.telegram.org/bots/api#sendmediagroup
816
860
  */
817
861
  replyWithMediaGroup(media, other, signal) {
818
- return this.api.sendMediaGroup(orThrow(this.chatId, "sendMediaGroup"), media, { business_connection_id: this.businessConnectionId, ...other }, signal);
862
+ var _a;
863
+ return this.api.sendMediaGroup(orThrow(this.chatId, "sendMediaGroup"), media, {
864
+ business_connection_id: this.businessConnectionId,
865
+ message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id,
866
+ ...other,
867
+ }, signal);
819
868
  }
820
869
  /**
821
870
  * Context-aware alias for `api.sendLocation`. Use this method to send point on the map. On success, the sent Message is returned.
@@ -828,7 +877,12 @@ class Context {
828
877
  * **Official reference:** https://core.telegram.org/bots/api#sendlocation
829
878
  */
830
879
  replyWithLocation(latitude, longitude, other, signal) {
831
- return this.api.sendLocation(orThrow(this.chatId, "sendLocation"), latitude, longitude, { business_connection_id: this.businessConnectionId, ...other }, signal);
880
+ var _a;
881
+ return this.api.sendLocation(orThrow(this.chatId, "sendLocation"), latitude, longitude, {
882
+ business_connection_id: this.businessConnectionId,
883
+ message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id,
884
+ ...other,
885
+ }, signal);
832
886
  }
833
887
  /**
834
888
  * Context-aware alias for `api.editMessageLiveLocation`. Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.
@@ -886,7 +940,12 @@ class Context {
886
940
  * **Official reference:** https://core.telegram.org/bots/api#sendvenue
887
941
  */
888
942
  replyWithVenue(latitude, longitude, title, address, other, signal) {
889
- return this.api.sendVenue(orThrow(this.chatId, "sendVenue"), latitude, longitude, title, address, { business_connection_id: this.businessConnectionId, ...other }, signal);
943
+ var _a;
944
+ return this.api.sendVenue(orThrow(this.chatId, "sendVenue"), latitude, longitude, title, address, {
945
+ business_connection_id: this.businessConnectionId,
946
+ message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id,
947
+ ...other,
948
+ }, signal);
890
949
  }
891
950
  /**
892
951
  * Context-aware alias for `api.sendContact`. Use this method to send phone contacts. On success, the sent Message is returned.
@@ -899,7 +958,12 @@ class Context {
899
958
  * **Official reference:** https://core.telegram.org/bots/api#sendcontact
900
959
  */
901
960
  replyWithContact(phone_number, first_name, other, signal) {
902
- return this.api.sendContact(orThrow(this.chatId, "sendContact"), phone_number, first_name, { business_connection_id: this.businessConnectionId, ...other }, signal);
961
+ var _a;
962
+ return this.api.sendContact(orThrow(this.chatId, "sendContact"), phone_number, first_name, {
963
+ business_connection_id: this.businessConnectionId,
964
+ message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id,
965
+ ...other,
966
+ }, signal);
903
967
  }
904
968
  /**
905
969
  * Context-aware alias for `api.sendPoll`. Use this method to send a native poll. On success, the sent Message is returned.
@@ -912,7 +976,12 @@ class Context {
912
976
  * **Official reference:** https://core.telegram.org/bots/api#sendpoll
913
977
  */
914
978
  replyWithPoll(question, options, other, signal) {
915
- return this.api.sendPoll(orThrow(this.chatId, "sendPoll"), question, options, { business_connection_id: this.businessConnectionId, ...other }, signal);
979
+ var _a;
980
+ return this.api.sendPoll(orThrow(this.chatId, "sendPoll"), question, options, {
981
+ business_connection_id: this.businessConnectionId,
982
+ message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id,
983
+ ...other,
984
+ }, signal);
916
985
  }
917
986
  /**
918
987
  * Context-aware alias for `api.sendChecklist`. Use this method to send a checklist on behalf of a connected business account. On success, the sent Message is returned.
@@ -951,7 +1020,12 @@ class Context {
951
1020
  * **Official reference:** https://core.telegram.org/bots/api#senddice
952
1021
  */
953
1022
  replyWithDice(emoji, other, signal) {
954
- return this.api.sendDice(orThrow(this.chatId, "sendDice"), emoji, { business_connection_id: this.businessConnectionId, ...other }, signal);
1023
+ var _a;
1024
+ return this.api.sendDice(orThrow(this.chatId, "sendDice"), emoji, {
1025
+ business_connection_id: this.businessConnectionId,
1026
+ message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id,
1027
+ ...other,
1028
+ }, signal);
955
1029
  }
956
1030
  /**
957
1031
  * Context-aware alias for `api.sendChatAction`. Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success.
@@ -967,7 +1041,12 @@ class Context {
967
1041
  * **Official reference:** https://core.telegram.org/bots/api#sendchataction
968
1042
  */
969
1043
  replyWithChatAction(action, other, signal) {
970
- return this.api.sendChatAction(orThrow(this.chatId, "sendChatAction"), action, { business_connection_id: this.businessConnectionId, ...other }, signal);
1044
+ var _a;
1045
+ return this.api.sendChatAction(orThrow(this.chatId, "sendChatAction"), action, {
1046
+ business_connection_id: this.businessConnectionId,
1047
+ message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id,
1048
+ ...other,
1049
+ }, signal);
971
1050
  }
972
1051
  /**
973
1052
  * Context-aware alias for `api.setMessageReaction`. Use this method to change the chosen reactions on a message. Service messages of some types can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success.
@@ -1346,6 +1425,7 @@ class Context {
1346
1425
  * Context-aware alias for `api.unpinChatMessage`. Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.
1347
1426
  *
1348
1427
  * @param message_id Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be unpinned.
1428
+ * @param other Optional remaining parameters, confer the official reference below
1349
1429
  * @param signal Optional `AbortSignal` to cancel the request
1350
1430
  *
1351
1431
  * **Official reference:** https://core.telegram.org/bots/api#unpinchatmessage
@@ -1938,7 +2018,12 @@ class Context {
1938
2018
  * **Official reference:** https://core.telegram.org/bots/api#sendsticker
1939
2019
  */
1940
2020
  replyWithSticker(sticker, other, signal) {
1941
- return this.api.sendSticker(orThrow(this.chatId, "sendSticker"), sticker, { business_connection_id: this.businessConnectionId, ...other }, signal);
2021
+ var _a;
2022
+ return this.api.sendSticker(orThrow(this.chatId, "sendSticker"), sticker, {
2023
+ business_connection_id: this.businessConnectionId,
2024
+ message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id,
2025
+ ...other,
2026
+ }, signal);
1942
2027
  }
1943
2028
  /**
1944
2029
  * Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of Sticker objects.
@@ -2032,7 +2117,8 @@ class Context {
2032
2117
  * **Official reference:** https://core.telegram.org/bots/api#sendinvoice
2033
2118
  */
2034
2119
  replyWithInvoice(title, description, payload, currency, prices, other, signal) {
2035
- return this.api.sendInvoice(orThrow(this.chatId, "sendInvoice"), title, description, payload, currency, prices, other, signal);
2120
+ var _a;
2121
+ return this.api.sendInvoice(orThrow(this.chatId, "sendInvoice"), title, description, payload, currency, prices, { message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id, ...other }, signal);
2036
2122
  }
2037
2123
  /**
2038
2124
  * Context-aware alias for `api.answerShippingQuery`. If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.
@@ -2158,7 +2244,12 @@ class Context {
2158
2244
  * **Official reference:** https://core.telegram.org/bots/api#sendgame
2159
2245
  */
2160
2246
  replyWithGame(game_short_name, other, signal) {
2161
- return this.api.sendGame(orThrow(this.chatId, "sendGame"), game_short_name, { business_connection_id: this.businessConnectionId, ...other }, signal);
2247
+ var _a;
2248
+ return this.api.sendGame(orThrow(this.chatId, "sendGame"), game_short_name, {
2249
+ business_connection_id: this.businessConnectionId,
2250
+ message_thread_id: (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_thread_id,
2251
+ ...other,
2252
+ }, signal);
2162
2253
  }
2163
2254
  }
2164
2255
  exports.Context = Context;
@@ -1,4 +1,5 @@
1
1
  import { type Update } from "../types.js";
2
+ type MaybePromise<T> = T | Promise<T>;
2
3
  /**
3
4
  * Abstraction over a request-response cycle, providing access to the update, as
4
5
  * well as a mechanism for responding to the request and to end it.
@@ -8,7 +9,7 @@ export interface ReqResHandler<T = void> {
8
9
  * The update object sent from Telegram, usually resolves the request's JSON
9
10
  * body
10
11
  */
11
- update: Promise<Update>;
12
+ update: MaybePromise<Update>;
12
13
  /**
13
14
  * X-Telegram-Bot-Api-Secret-Token header of the request, or undefined if
14
15
  * not present
@@ -214,3 +215,4 @@ export declare const adapters: {
214
215
  sveltekit: SveltekitAdapter;
215
216
  worktop: WorktopAdapter;
216
217
  };
218
+ export {};
@@ -14,27 +14,29 @@ const unauthorized = () => new Response('"unauthorized"', {
14
14
  statusText: WRONG_TOKEN_ERROR,
15
15
  });
16
16
  /** AWS lambda serverless functions */
17
- const awsLambda = (event, _context, callback) => {
18
- var _a;
19
- return ({
20
- update: JSON.parse((_a = event.body) !== null && _a !== void 0 ? _a : "{}"),
21
- header: event.headers[SECRET_HEADER],
22
- end: () => callback(null, { statusCode: 200 }),
23
- respond: (json) => callback(null, {
24
- statusCode: 200,
25
- headers: { "Content-Type": "application/json" },
26
- body: json,
27
- }),
28
- unauthorized: () => callback(null, { statusCode: 401 }),
29
- });
30
- };
17
+ const awsLambda = (event, _context, callback) => ({
18
+ get update() {
19
+ var _a;
20
+ return JSON.parse((_a = event.body) !== null && _a !== void 0 ? _a : "{}");
21
+ },
22
+ header: event.headers[SECRET_HEADER],
23
+ end: () => callback(null, { statusCode: 200 }),
24
+ respond: (json) => callback(null, {
25
+ statusCode: 200,
26
+ headers: { "Content-Type": "application/json" },
27
+ body: json,
28
+ }),
29
+ unauthorized: () => callback(null, { statusCode: 401 }),
30
+ });
31
31
  /** AWS lambda async/await serverless functions */
32
32
  const awsLambdaAsync = (event, _context) => {
33
- var _a;
34
33
  // deno-lint-ignore no-explicit-any
35
34
  let resolveResponse;
36
35
  return {
37
- update: JSON.parse((_a = event.body) !== null && _a !== void 0 ? _a : "{}"),
36
+ get update() {
37
+ var _a;
38
+ return JSON.parse((_a = event.body) !== null && _a !== void 0 ? _a : "{}");
39
+ },
38
40
  header: event.headers[SECRET_HEADER],
39
41
  end: () => resolveResponse({ statusCode: 200 }),
40
42
  respond: (json) => resolveResponse({
@@ -43,16 +45,16 @@ const awsLambdaAsync = (event, _context) => {
43
45
  body: json,
44
46
  }),
45
47
  unauthorized: () => resolveResponse({ statusCode: 401 }),
46
- handlerReturn: new Promise((resolve) => {
47
- resolveResponse = resolve;
48
- }),
48
+ handlerReturn: new Promise((res) => resolveResponse = res),
49
49
  };
50
50
  };
51
51
  /** Azure Functions v3 and v4 */
52
52
  const azure = (context, request) => {
53
53
  var _a, _b;
54
54
  return ({
55
- update: Promise.resolve(request.body),
55
+ get update() {
56
+ return request.body;
57
+ },
56
58
  header: (_b = (_a = context.res) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b[SECRET_HEADER],
57
59
  end: () => (context.res = {
58
60
  status: 200,
@@ -72,21 +74,23 @@ const azure = (context, request) => {
72
74
  const azureV4 = (request) => {
73
75
  let resolveResponse;
74
76
  return {
75
- update: Promise.resolve(request.json()),
77
+ get update() {
78
+ return request.json();
79
+ },
76
80
  header: request.headers.get(SECRET_HEADER) || undefined,
77
81
  end: () => resolveResponse({ status: 204 }),
78
82
  respond: (json) => resolveResponse({ jsonBody: json }),
79
83
  unauthorized: () => resolveResponse({ status: 401, body: WRONG_TOKEN_ERROR }),
80
- handlerReturn: new Promise((resolve) => {
81
- resolveResponse = resolve;
82
- }),
84
+ handlerReturn: new Promise((resolve) => resolveResponse = resolve),
83
85
  };
84
86
  };
85
87
  /** Bun.serve */
86
88
  const bun = (request) => {
87
89
  let resolveResponse;
88
90
  return {
89
- update: request.json(),
91
+ get update() {
92
+ return request.json();
93
+ },
90
94
  header: request.headers.get(SECRET_HEADER) || undefined,
91
95
  end: () => {
92
96
  resolveResponse(ok());
@@ -97,9 +101,7 @@ const bun = (request) => {
97
101
  unauthorized: () => {
98
102
  resolveResponse(unauthorized());
99
103
  },
100
- handlerReturn: new Promise((resolve) => {
101
- resolveResponse = resolve;
102
- }),
104
+ handlerReturn: new Promise((res) => resolveResponse = res),
103
105
  };
104
106
  };
105
107
  /** Native CloudFlare workers (service worker) */
@@ -109,7 +111,9 @@ const cloudflare = (event) => {
109
111
  resolveResponse = resolve;
110
112
  }));
111
113
  return {
112
- update: event.request.json(),
114
+ get update() {
115
+ return event.request.json();
116
+ },
113
117
  header: event.request.headers.get(SECRET_HEADER) || undefined,
114
118
  end: () => {
115
119
  resolveResponse(ok());
@@ -126,7 +130,9 @@ const cloudflare = (event) => {
126
130
  const cloudflareModule = (request) => {
127
131
  let resolveResponse;
128
132
  return {
129
- update: request.json(),
133
+ get update() {
134
+ return request.json();
135
+ },
130
136
  header: request.headers.get(SECRET_HEADER) || undefined,
131
137
  end: () => {
132
138
  resolveResponse(ok());
@@ -137,14 +143,14 @@ const cloudflareModule = (request) => {
137
143
  unauthorized: () => {
138
144
  resolveResponse(unauthorized());
139
145
  },
140
- handlerReturn: new Promise((resolve) => {
141
- resolveResponse = resolve;
142
- }),
146
+ handlerReturn: new Promise((res) => resolveResponse = res),
143
147
  };
144
148
  };
145
149
  /** express web framework */
146
150
  const express = (req, res) => ({
147
- update: Promise.resolve(req.body),
151
+ get update() {
152
+ return req.body;
153
+ },
148
154
  header: req.header(SECRET_HEADER),
149
155
  end: () => res.end(),
150
156
  respond: (json) => {
@@ -157,7 +163,9 @@ const express = (req, res) => ({
157
163
  });
158
164
  /** fastify web framework */
159
165
  const fastify = (request, reply) => ({
160
- update: Promise.resolve(request.body),
166
+ get update() {
167
+ return request.body;
168
+ },
161
169
  header: request.headers[SECRET_HEADER_LOWERCASE],
162
170
  end: () => reply.status(200).send(),
163
171
  respond: (json) => reply.headers({ "Content-Type": "application/json" }).send(json),
@@ -167,7 +175,9 @@ const fastify = (request, reply) => ({
167
175
  const hono = (c) => {
168
176
  let resolveResponse;
169
177
  return {
170
- update: c.req.json(),
178
+ get update() {
179
+ return c.req.json();
180
+ },
171
181
  header: c.req.header(SECRET_HEADER),
172
182
  end: () => {
173
183
  resolveResponse(c.body(""));
@@ -179,26 +189,26 @@ const hono = (c) => {
179
189
  c.status(401);
180
190
  resolveResponse(c.body(""));
181
191
  },
182
- handlerReturn: new Promise((resolve) => {
183
- resolveResponse = resolve;
184
- }),
192
+ handlerReturn: new Promise((res) => resolveResponse = res),
185
193
  };
186
194
  };
187
195
  /** Node.js native 'http' and 'https' modules */
188
196
  const http = (req, res) => {
189
197
  const secretHeaderFromRequest = req.headers[SECRET_HEADER_LOWERCASE];
190
198
  return {
191
- update: new Promise((resolve, reject) => {
192
- const chunks = [];
193
- req.on("data", (chunk) => chunks.push(chunk))
194
- .once("end", () => {
195
- // @ts-ignore `Buffer` is Node-only
196
- // deno-lint-ignore no-node-globals
197
- const raw = Buffer.concat(chunks).toString("utf-8");
198
- resolve(JSON.parse(raw));
199
- })
200
- .once("error", reject);
201
- }),
199
+ get update() {
200
+ return new Promise((resolve, reject) => {
201
+ const chunks = [];
202
+ req.on("data", (chunk) => chunks.push(chunk))
203
+ .once("end", () => {
204
+ // @ts-ignore `Buffer` is Node-only
205
+ // deno-lint-ignore no-node-globals
206
+ const raw = Buffer.concat(chunks).toString("utf-8");
207
+ resolve(JSON.parse(raw));
208
+ })
209
+ .once("error", reject);
210
+ });
211
+ },
202
212
  header: Array.isArray(secretHeaderFromRequest)
203
213
  ? secretHeaderFromRequest[0]
204
214
  : secretHeaderFromRequest,
@@ -211,7 +221,9 @@ const http = (req, res) => {
211
221
  };
212
222
  /** koa web framework */
213
223
  const koa = (ctx) => ({
214
- update: Promise.resolve(ctx.request.body),
224
+ get update() {
225
+ return ctx.request.body;
226
+ },
215
227
  header: ctx.get(SECRET_HEADER) || undefined,
216
228
  end: () => {
217
229
  ctx.body = "";
@@ -226,7 +238,9 @@ const koa = (ctx) => ({
226
238
  });
227
239
  /** Next.js Serverless Functions */
228
240
  const nextJs = (request, response) => ({
229
- update: Promise.resolve(request.body),
241
+ get update() {
242
+ return request.body;
243
+ },
230
244
  header: request.headers[SECRET_HEADER_LOWERCASE],
231
245
  end: () => response.end(),
232
246
  respond: (json) => response.status(200).json(json),
@@ -234,7 +248,9 @@ const nextJs = (request, response) => ({
234
248
  });
235
249
  /** nhttp web framework */
236
250
  const nhttp = (rev) => ({
237
- update: Promise.resolve(rev.body),
251
+ get update() {
252
+ return rev.body;
253
+ },
238
254
  header: rev.headers.get(SECRET_HEADER) || undefined,
239
255
  end: () => rev.response.sendStatus(200),
240
256
  respond: (json) => rev.response.status(200).send(json),
@@ -242,7 +258,9 @@ const nhttp = (rev) => ({
242
258
  });
243
259
  /** oak web framework */
244
260
  const oak = (ctx) => ({
245
- update: ctx.request.body.json(),
261
+ get update() {
262
+ return ctx.request.body.json();
263
+ },
246
264
  header: ctx.request.headers.get(SECRET_HEADER) || undefined,
247
265
  end: () => {
248
266
  ctx.response.status = 200;
@@ -257,7 +275,9 @@ const oak = (ctx) => ({
257
275
  });
258
276
  /** Deno.serve */
259
277
  const serveHttp = (requestEvent) => ({
260
- update: requestEvent.request.json(),
278
+ get update() {
279
+ return requestEvent.request.json();
280
+ },
261
281
  header: requestEvent.request.headers.get(SECRET_HEADER) || undefined,
262
282
  end: () => requestEvent.respondWith(ok()),
263
283
  respond: (json) => requestEvent.respondWith(okJson(json)),
@@ -267,7 +287,9 @@ const serveHttp = (requestEvent) => ({
267
287
  const stdHttp = (req) => {
268
288
  let resolveResponse;
269
289
  return {
270
- update: req.json(),
290
+ get update() {
291
+ return req.json();
292
+ },
271
293
  header: req.headers.get(SECRET_HEADER) || undefined,
272
294
  end: () => {
273
295
  if (resolveResponse)
@@ -281,16 +303,16 @@ const stdHttp = (req) => {
281
303
  if (resolveResponse)
282
304
  resolveResponse(unauthorized());
283
305
  },
284
- handlerReturn: new Promise((resolve) => {
285
- resolveResponse = resolve;
286
- }),
306
+ handlerReturn: new Promise((res) => resolveResponse = res),
287
307
  };
288
308
  };
289
309
  /** Sveltekit Serverless Functions */
290
310
  const sveltekit = ({ request }) => {
291
311
  let resolveResponse;
292
312
  return {
293
- update: Promise.resolve(request.json()),
313
+ get update() {
314
+ return request.json();
315
+ },
294
316
  header: request.headers.get(SECRET_HEADER) || undefined,
295
317
  end: () => {
296
318
  if (resolveResponse)
@@ -304,16 +326,16 @@ const sveltekit = ({ request }) => {
304
326
  if (resolveResponse)
305
327
  resolveResponse(unauthorized());
306
328
  },
307
- handlerReturn: new Promise((resolve) => {
308
- resolveResponse = resolve;
309
- }),
329
+ handlerReturn: new Promise((res) => resolveResponse = res),
310
330
  };
311
331
  };
312
332
  /** worktop Cloudflare workers framework */
313
333
  const worktop = (req, res) => {
314
334
  var _a;
315
335
  return ({
316
- update: Promise.resolve(req.json()),
336
+ get update() {
337
+ return req.json();
338
+ },
317
339
  header: (_a = req.headers.get(SECRET_HEADER)) !== null && _a !== void 0 ? _a : undefined,
318
340
  end: () => res.end(null),
319
341
  respond: (json) => res.send(200, json),
@@ -323,25 +345,26 @@ const worktop = (req, res) => {
323
345
  const elysia = (ctx) => {
324
346
  // @note upgrade target to use modern code?
325
347
  // const { promise, resolve } = Promise.withResolvers<string>();
326
- let resolve;
327
- const handlerReturn = new Promise((res) => resolve = res);
348
+ let resolveResponse;
328
349
  return {
329
350
  // @note technically the type shouldn't be limited to Promise, because it's fine to await plain values as well
330
- update: Promise.resolve(ctx.body),
351
+ get update() {
352
+ return ctx.body;
353
+ },
331
354
  header: ctx.headers[SECRET_HEADER_LOWERCASE],
332
355
  end() {
333
- resolve("");
356
+ resolveResponse("");
334
357
  },
335
358
  respond(json) {
336
359
  // @note since json is passed as string here, we gotta define proper content-type
337
360
  ctx.set.headers["content-type"] = "application/json";
338
- resolve(json);
361
+ resolveResponse(json);
339
362
  },
340
363
  unauthorized() {
341
364
  ctx.set.status = 401;
342
- resolve("");
365
+ resolveResponse("");
343
366
  },
344
- handlerReturn,
367
+ handlerReturn: new Promise((res) => resolveResponse = res),
345
368
  };
346
369
  };
347
370
  // Please open a pull request if you want to add another adapter
@@ -28,29 +28,28 @@ function webhookCallback(bot, adapter = platform_node_js_1.defaultAdapter, onTim
28
28
  ? adapters[adapter]
29
29
  : adapter;
30
30
  return async (...args) => {
31
- const { update, respond, unauthorized, end, handlerReturn, header } = server(...args);
31
+ var _a;
32
+ const handler = server(...args);
32
33
  if (!initialized) {
33
34
  // Will dedupe concurrently incoming calls from several updates
34
35
  await bot.init();
35
36
  initialized = true;
36
37
  }
37
- if (header !== token) {
38
- await unauthorized();
39
- // TODO: investigate deno bug that happens when this console logging is removed
40
- console.log(handlerReturn);
41
- return handlerReturn;
38
+ if (handler.header !== token) {
39
+ await handler.unauthorized();
40
+ return handler.handlerReturn;
42
41
  }
43
42
  let usedWebhookReply = false;
44
43
  const webhookReplyEnvelope = {
45
44
  async send(json) {
46
45
  usedWebhookReply = true;
47
- await respond(json);
46
+ await handler.respond(json);
48
47
  },
49
48
  };
50
- await timeoutIfNecessary(bot.handleUpdate(await update, webhookReplyEnvelope), typeof timeout === "function" ? () => timeout(...args) : timeout, ms);
49
+ await timeoutIfNecessary(bot.handleUpdate(await handler.update, webhookReplyEnvelope), typeof timeout === "function" ? () => timeout(...args) : timeout, ms);
51
50
  if (!usedWebhookReply)
52
- end === null || end === void 0 ? void 0 : end();
53
- return handlerReturn;
51
+ (_a = handler.end) === null || _a === void 0 ? void 0 : _a.call(handler);
52
+ return handler.handlerReturn;
54
53
  };
55
54
  }
56
55
  function timeoutIfNecessary(task, onTimeout, timeout) {
package/out/core/api.d.ts CHANGED
@@ -201,7 +201,7 @@ export declare class Api<R extends RawApi = RawApi> {
201
201
  *
202
202
  * **Official reference:** https://core.telegram.org/bots/api#copymessages
203
203
  */
204
- copyMessages(chat_id: number | string, from_chat_id: number | string, message_ids: number[], other?: Other<R, "copyMessages", "chat_id" | "from_chat_id" | "message_id">, signal?: AbortSignal): Promise<import("@grammyjs/types/message.js").MessageId[]>;
204
+ copyMessages(chat_id: number | string, from_chat_id: number | string, message_ids: number[], other?: Other<R, "copyMessages", "chat_id" | "from_chat_id" | "message_ids">, signal?: AbortSignal): Promise<import("@grammyjs/types/message.js").MessageId[]>;
205
205
  /**
206
206
  * Use this method to send photos. On success, the sent Message is returned.
207
207
  *
package/out/web.mjs CHANGED
@@ -746,72 +746,94 @@ class Context {
746
746
  reply(text, other, signal) {
747
747
  return this.api.sendMessage(orThrow(this.chatId, "sendMessage"), text, {
748
748
  business_connection_id: this.businessConnectionId,
749
+ message_thread_id: this.msg?.message_thread_id,
749
750
  ...other
750
751
  }, signal);
751
752
  }
752
753
  forwardMessage(chat_id, other, signal) {
753
- return this.api.forwardMessage(chat_id, orThrow(this.chatId, "forwardMessage"), orThrow(this.msgId, "forwardMessage"), other, signal);
754
+ return this.api.forwardMessage(chat_id, orThrow(this.chatId, "forwardMessage"), orThrow(this.msgId, "forwardMessage"), {
755
+ message_thread_id: this.msg?.message_thread_id,
756
+ ...other
757
+ }, signal);
754
758
  }
755
759
  forwardMessages(chat_id, message_ids, other, signal) {
756
- return this.api.forwardMessages(chat_id, orThrow(this.chatId, "forwardMessages"), message_ids, other, signal);
760
+ return this.api.forwardMessages(chat_id, orThrow(this.chatId, "forwardMessages"), message_ids, {
761
+ message_thread_id: this.msg?.message_thread_id,
762
+ ...other
763
+ }, signal);
757
764
  }
758
765
  copyMessage(chat_id, other, signal) {
759
- return this.api.copyMessage(chat_id, orThrow(this.chatId, "copyMessage"), orThrow(this.msgId, "copyMessage"), other, signal);
766
+ return this.api.copyMessage(chat_id, orThrow(this.chatId, "copyMessage"), orThrow(this.msgId, "copyMessage"), {
767
+ message_thread_id: this.msg?.message_thread_id,
768
+ ...other
769
+ }, signal);
760
770
  }
761
771
  copyMessages(chat_id, message_ids, other, signal) {
762
- return this.api.copyMessages(chat_id, orThrow(this.chatId, "copyMessages"), message_ids, other, signal);
772
+ return this.api.copyMessages(chat_id, orThrow(this.chatId, "copyMessages"), message_ids, {
773
+ message_thread_id: this.msg?.message_thread_id,
774
+ ...other
775
+ }, signal);
763
776
  }
764
777
  replyWithPhoto(photo, other, signal) {
765
778
  return this.api.sendPhoto(orThrow(this.chatId, "sendPhoto"), photo, {
766
779
  business_connection_id: this.businessConnectionId,
780
+ message_thread_id: this.msg?.message_thread_id,
767
781
  ...other
768
782
  }, signal);
769
783
  }
770
784
  replyWithAudio(audio, other, signal) {
771
785
  return this.api.sendAudio(orThrow(this.chatId, "sendAudio"), audio, {
772
786
  business_connection_id: this.businessConnectionId,
787
+ message_thread_id: this.msg?.message_thread_id,
773
788
  ...other
774
789
  }, signal);
775
790
  }
776
791
  replyWithDocument(document1, other, signal) {
777
792
  return this.api.sendDocument(orThrow(this.chatId, "sendDocument"), document1, {
778
793
  business_connection_id: this.businessConnectionId,
794
+ message_thread_id: this.msg?.message_thread_id,
779
795
  ...other
780
796
  }, signal);
781
797
  }
782
798
  replyWithVideo(video, other, signal) {
783
799
  return this.api.sendVideo(orThrow(this.chatId, "sendVideo"), video, {
784
800
  business_connection_id: this.businessConnectionId,
801
+ message_thread_id: this.msg?.message_thread_id,
785
802
  ...other
786
803
  }, signal);
787
804
  }
788
805
  replyWithAnimation(animation, other, signal) {
789
806
  return this.api.sendAnimation(orThrow(this.chatId, "sendAnimation"), animation, {
790
807
  business_connection_id: this.businessConnectionId,
808
+ message_thread_id: this.msg?.message_thread_id,
791
809
  ...other
792
810
  }, signal);
793
811
  }
794
812
  replyWithVoice(voice, other, signal) {
795
813
  return this.api.sendVoice(orThrow(this.chatId, "sendVoice"), voice, {
796
814
  business_connection_id: this.businessConnectionId,
815
+ message_thread_id: this.msg?.message_thread_id,
797
816
  ...other
798
817
  }, signal);
799
818
  }
800
819
  replyWithVideoNote(video_note, other, signal) {
801
820
  return this.api.sendVideoNote(orThrow(this.chatId, "sendVideoNote"), video_note, {
802
821
  business_connection_id: this.businessConnectionId,
822
+ message_thread_id: this.msg?.message_thread_id,
803
823
  ...other
804
824
  }, signal);
805
825
  }
806
826
  replyWithMediaGroup(media, other, signal) {
807
827
  return this.api.sendMediaGroup(orThrow(this.chatId, "sendMediaGroup"), media, {
808
828
  business_connection_id: this.businessConnectionId,
829
+ message_thread_id: this.msg?.message_thread_id,
809
830
  ...other
810
831
  }, signal);
811
832
  }
812
833
  replyWithLocation(latitude, longitude, other, signal) {
813
834
  return this.api.sendLocation(orThrow(this.chatId, "sendLocation"), latitude, longitude, {
814
835
  business_connection_id: this.businessConnectionId,
836
+ message_thread_id: this.msg?.message_thread_id,
815
837
  ...other
816
838
  }, signal);
817
839
  }
@@ -844,18 +866,21 @@ class Context {
844
866
  replyWithVenue(latitude, longitude, title, address, other, signal) {
845
867
  return this.api.sendVenue(orThrow(this.chatId, "sendVenue"), latitude, longitude, title, address, {
846
868
  business_connection_id: this.businessConnectionId,
869
+ message_thread_id: this.msg?.message_thread_id,
847
870
  ...other
848
871
  }, signal);
849
872
  }
850
873
  replyWithContact(phone_number, first_name, other, signal) {
851
874
  return this.api.sendContact(orThrow(this.chatId, "sendContact"), phone_number, first_name, {
852
875
  business_connection_id: this.businessConnectionId,
876
+ message_thread_id: this.msg?.message_thread_id,
853
877
  ...other
854
878
  }, signal);
855
879
  }
856
880
  replyWithPoll(question, options, other, signal) {
857
881
  return this.api.sendPoll(orThrow(this.chatId, "sendPoll"), question, options, {
858
882
  business_connection_id: this.businessConnectionId,
883
+ message_thread_id: this.msg?.message_thread_id,
859
884
  ...other
860
885
  }, signal);
861
886
  }
@@ -870,12 +895,14 @@ class Context {
870
895
  replyWithDice(emoji, other, signal) {
871
896
  return this.api.sendDice(orThrow(this.chatId, "sendDice"), emoji, {
872
897
  business_connection_id: this.businessConnectionId,
898
+ message_thread_id: this.msg?.message_thread_id,
873
899
  ...other
874
900
  }, signal);
875
901
  }
876
902
  replyWithChatAction(action, other, signal) {
877
903
  return this.api.sendChatAction(orThrow(this.chatId, "sendChatAction"), action, {
878
904
  business_connection_id: this.businessConnectionId,
905
+ message_thread_id: this.msg?.message_thread_id,
879
906
  ...other
880
907
  }, signal);
881
908
  }
@@ -1195,6 +1222,7 @@ class Context {
1195
1222
  replyWithSticker(sticker, other, signal) {
1196
1223
  return this.api.sendSticker(orThrow(this.chatId, "sendSticker"), sticker, {
1197
1224
  business_connection_id: this.businessConnectionId,
1225
+ message_thread_id: this.msg?.message_thread_id,
1198
1226
  ...other
1199
1227
  }, signal);
1200
1228
  }
@@ -1217,7 +1245,10 @@ class Context {
1217
1245
  return this.api.savePreparedInlineMessage(orThrow(this.from, "savePreparedInlineMessage").id, result, other, signal);
1218
1246
  }
1219
1247
  replyWithInvoice(title, description, payload, currency, prices, other, signal) {
1220
- return this.api.sendInvoice(orThrow(this.chatId, "sendInvoice"), title, description, payload, currency, prices, other, signal);
1248
+ return this.api.sendInvoice(orThrow(this.chatId, "sendInvoice"), title, description, payload, currency, prices, {
1249
+ message_thread_id: this.msg?.message_thread_id,
1250
+ ...other
1251
+ }, signal);
1221
1252
  }
1222
1253
  answerShippingQuery(ok, other, signal) {
1223
1254
  return this.api.answerShippingQuery(orThrow(this.shippingQuery, "answerShippingQuery").id, ok, other, signal);
@@ -1254,6 +1285,7 @@ class Context {
1254
1285
  replyWithGame(game_short_name, other, signal) {
1255
1286
  return this.api.sendGame(orThrow(this.chatId, "sendGame"), game_short_name, {
1256
1287
  business_connection_id: this.businessConnectionId,
1288
+ message_thread_id: this.msg?.message_thread_id,
1257
1289
  ...other
1258
1290
  }, signal);
1259
1291
  }
@@ -4977,7 +5009,9 @@ const unauthorized = ()=>new Response('"unauthorized"', {
4977
5009
  statusText: WRONG_TOKEN_ERROR
4978
5010
  });
4979
5011
  const awsLambda = (event, _context, callback)=>({
4980
- update: JSON.parse(event.body ?? "{}"),
5012
+ get update () {
5013
+ return JSON.parse(event.body ?? "{}");
5014
+ },
4981
5015
  header: event.headers[SECRET_HEADER],
4982
5016
  end: ()=>callback(null, {
4983
5017
  statusCode: 200
@@ -4996,7 +5030,9 @@ const awsLambda = (event, _context, callback)=>({
4996
5030
  const awsLambdaAsync = (event, _context)=>{
4997
5031
  let resolveResponse;
4998
5032
  return {
4999
- update: JSON.parse(event.body ?? "{}"),
5033
+ get update () {
5034
+ return JSON.parse(event.body ?? "{}");
5035
+ },
5000
5036
  header: event.headers[SECRET_HEADER],
5001
5037
  end: ()=>resolveResponse({
5002
5038
  statusCode: 200
@@ -5011,13 +5047,13 @@ const awsLambdaAsync = (event, _context)=>{
5011
5047
  unauthorized: ()=>resolveResponse({
5012
5048
  statusCode: 401
5013
5049
  }),
5014
- handlerReturn: new Promise((resolve)=>{
5015
- resolveResponse = resolve;
5016
- })
5050
+ handlerReturn: new Promise((res)=>resolveResponse = res)
5017
5051
  };
5018
5052
  };
5019
5053
  const azure = (context, request)=>({
5020
- update: Promise.resolve(request.body),
5054
+ get update () {
5055
+ return request.body;
5056
+ },
5021
5057
  header: context.res?.headers?.[SECRET_HEADER],
5022
5058
  end: ()=>context.res = {
5023
5059
  status: 200,
@@ -5034,7 +5070,9 @@ const azure = (context, request)=>({
5034
5070
  const azureV4 = (request)=>{
5035
5071
  let resolveResponse;
5036
5072
  return {
5037
- update: Promise.resolve(request.json()),
5073
+ get update () {
5074
+ return request.json();
5075
+ },
5038
5076
  header: request.headers.get(SECRET_HEADER) || undefined,
5039
5077
  end: ()=>resolveResponse({
5040
5078
  status: 204
@@ -5046,15 +5084,15 @@ const azureV4 = (request)=>{
5046
5084
  status: 401,
5047
5085
  body: WRONG_TOKEN_ERROR
5048
5086
  }),
5049
- handlerReturn: new Promise((resolve)=>{
5050
- resolveResponse = resolve;
5051
- })
5087
+ handlerReturn: new Promise((resolve)=>resolveResponse = resolve)
5052
5088
  };
5053
5089
  };
5054
5090
  const bun = (request)=>{
5055
5091
  let resolveResponse;
5056
5092
  return {
5057
- update: request.json(),
5093
+ get update () {
5094
+ return request.json();
5095
+ },
5058
5096
  header: request.headers.get(SECRET_HEADER) || undefined,
5059
5097
  end: ()=>{
5060
5098
  resolveResponse(ok());
@@ -5065,9 +5103,7 @@ const bun = (request)=>{
5065
5103
  unauthorized: ()=>{
5066
5104
  resolveResponse(unauthorized());
5067
5105
  },
5068
- handlerReturn: new Promise((resolve)=>{
5069
- resolveResponse = resolve;
5070
- })
5106
+ handlerReturn: new Promise((res)=>resolveResponse = res)
5071
5107
  };
5072
5108
  };
5073
5109
  const cloudflare = (event)=>{
@@ -5076,7 +5112,9 @@ const cloudflare = (event)=>{
5076
5112
  resolveResponse = resolve;
5077
5113
  }));
5078
5114
  return {
5079
- update: event.request.json(),
5115
+ get update () {
5116
+ return event.request.json();
5117
+ },
5080
5118
  header: event.request.headers.get(SECRET_HEADER) || undefined,
5081
5119
  end: ()=>{
5082
5120
  resolveResponse(ok());
@@ -5092,7 +5130,9 @@ const cloudflare = (event)=>{
5092
5130
  const cloudflareModule = (request)=>{
5093
5131
  let resolveResponse;
5094
5132
  return {
5095
- update: request.json(),
5133
+ get update () {
5134
+ return request.json();
5135
+ },
5096
5136
  header: request.headers.get(SECRET_HEADER) || undefined,
5097
5137
  end: ()=>{
5098
5138
  resolveResponse(ok());
@@ -5103,13 +5143,13 @@ const cloudflareModule = (request)=>{
5103
5143
  unauthorized: ()=>{
5104
5144
  resolveResponse(unauthorized());
5105
5145
  },
5106
- handlerReturn: new Promise((resolve)=>{
5107
- resolveResponse = resolve;
5108
- })
5146
+ handlerReturn: new Promise((res)=>resolveResponse = res)
5109
5147
  };
5110
5148
  };
5111
5149
  const express = (req, res)=>({
5112
- update: Promise.resolve(req.body),
5150
+ get update () {
5151
+ return req.body;
5152
+ },
5113
5153
  header: req.header(SECRET_HEADER),
5114
5154
  end: ()=>res.end(),
5115
5155
  respond: (json)=>{
@@ -5121,7 +5161,9 @@ const express = (req, res)=>({
5121
5161
  }
5122
5162
  });
5123
5163
  const fastify = (request, reply)=>({
5124
- update: Promise.resolve(request.body),
5164
+ get update () {
5165
+ return request.body;
5166
+ },
5125
5167
  header: request.headers[SECRET_HEADER_LOWERCASE],
5126
5168
  end: ()=>reply.status(200).send(),
5127
5169
  respond: (json)=>reply.headers({
@@ -5132,7 +5174,9 @@ const fastify = (request, reply)=>({
5132
5174
  const hono = (c)=>{
5133
5175
  let resolveResponse;
5134
5176
  return {
5135
- update: c.req.json(),
5177
+ get update () {
5178
+ return c.req.json();
5179
+ },
5136
5180
  header: c.req.header(SECRET_HEADER),
5137
5181
  end: ()=>{
5138
5182
  resolveResponse(c.body(""));
@@ -5144,21 +5188,21 @@ const hono = (c)=>{
5144
5188
  c.status(401);
5145
5189
  resolveResponse(c.body(""));
5146
5190
  },
5147
- handlerReturn: new Promise((resolve)=>{
5148
- resolveResponse = resolve;
5149
- })
5191
+ handlerReturn: new Promise((res)=>resolveResponse = res)
5150
5192
  };
5151
5193
  };
5152
5194
  const http = (req, res)=>{
5153
5195
  const secretHeaderFromRequest = req.headers[SECRET_HEADER_LOWERCASE];
5154
5196
  return {
5155
- update: new Promise((resolve, reject)=>{
5156
- const chunks = [];
5157
- req.on("data", (chunk)=>chunks.push(chunk)).once("end", ()=>{
5158
- const raw = Buffer.concat(chunks).toString("utf-8");
5159
- resolve(JSON.parse(raw));
5160
- }).once("error", reject);
5161
- }),
5197
+ get update () {
5198
+ return new Promise((resolve, reject)=>{
5199
+ const chunks = [];
5200
+ req.on("data", (chunk)=>chunks.push(chunk)).once("end", ()=>{
5201
+ const raw = Buffer.concat(chunks).toString("utf-8");
5202
+ resolve(JSON.parse(raw));
5203
+ }).once("error", reject);
5204
+ });
5205
+ },
5162
5206
  header: Array.isArray(secretHeaderFromRequest) ? secretHeaderFromRequest[0] : secretHeaderFromRequest,
5163
5207
  end: ()=>res.end(),
5164
5208
  respond: (json)=>res.writeHead(200, {
@@ -5168,7 +5212,9 @@ const http = (req, res)=>{
5168
5212
  };
5169
5213
  };
5170
5214
  const koa = (ctx)=>({
5171
- update: Promise.resolve(ctx.request.body),
5215
+ get update () {
5216
+ return ctx.request.body;
5217
+ },
5172
5218
  header: ctx.get(SECRET_HEADER) || undefined,
5173
5219
  end: ()=>{
5174
5220
  ctx.body = "";
@@ -5182,21 +5228,27 @@ const koa = (ctx)=>({
5182
5228
  }
5183
5229
  });
5184
5230
  const nextJs = (request, response)=>({
5185
- update: Promise.resolve(request.body),
5231
+ get update () {
5232
+ return request.body;
5233
+ },
5186
5234
  header: request.headers[SECRET_HEADER_LOWERCASE],
5187
5235
  end: ()=>response.end(),
5188
5236
  respond: (json)=>response.status(200).json(json),
5189
5237
  unauthorized: ()=>response.status(401).send(WRONG_TOKEN_ERROR)
5190
5238
  });
5191
5239
  const nhttp = (rev)=>({
5192
- update: Promise.resolve(rev.body),
5240
+ get update () {
5241
+ return rev.body;
5242
+ },
5193
5243
  header: rev.headers.get(SECRET_HEADER) || undefined,
5194
5244
  end: ()=>rev.response.sendStatus(200),
5195
5245
  respond: (json)=>rev.response.status(200).send(json),
5196
5246
  unauthorized: ()=>rev.response.status(401).send(WRONG_TOKEN_ERROR)
5197
5247
  });
5198
5248
  const oak = (ctx)=>({
5199
- update: ctx.request.body.json(),
5249
+ get update () {
5250
+ return ctx.request.body.json();
5251
+ },
5200
5252
  header: ctx.request.headers.get(SECRET_HEADER) || undefined,
5201
5253
  end: ()=>{
5202
5254
  ctx.response.status = 200;
@@ -5210,7 +5262,9 @@ const oak = (ctx)=>({
5210
5262
  }
5211
5263
  });
5212
5264
  const serveHttp = (requestEvent)=>({
5213
- update: requestEvent.request.json(),
5265
+ get update () {
5266
+ return requestEvent.request.json();
5267
+ },
5214
5268
  header: requestEvent.request.headers.get(SECRET_HEADER) || undefined,
5215
5269
  end: ()=>requestEvent.respondWith(ok()),
5216
5270
  respond: (json)=>requestEvent.respondWith(okJson(json)),
@@ -5219,7 +5273,9 @@ const serveHttp = (requestEvent)=>({
5219
5273
  const stdHttp = (req)=>{
5220
5274
  let resolveResponse;
5221
5275
  return {
5222
- update: req.json(),
5276
+ get update () {
5277
+ return req.json();
5278
+ },
5223
5279
  header: req.headers.get(SECRET_HEADER) || undefined,
5224
5280
  end: ()=>{
5225
5281
  if (resolveResponse) resolveResponse(ok());
@@ -5230,15 +5286,15 @@ const stdHttp = (req)=>{
5230
5286
  unauthorized: ()=>{
5231
5287
  if (resolveResponse) resolveResponse(unauthorized());
5232
5288
  },
5233
- handlerReturn: new Promise((resolve)=>{
5234
- resolveResponse = resolve;
5235
- })
5289
+ handlerReturn: new Promise((res)=>resolveResponse = res)
5236
5290
  };
5237
5291
  };
5238
5292
  const sveltekit = ({ request })=>{
5239
5293
  let resolveResponse;
5240
5294
  return {
5241
- update: Promise.resolve(request.json()),
5295
+ get update () {
5296
+ return request.json();
5297
+ },
5242
5298
  header: request.headers.get(SECRET_HEADER) || undefined,
5243
5299
  end: ()=>{
5244
5300
  if (resolveResponse) resolveResponse(ok());
@@ -5249,36 +5305,37 @@ const sveltekit = ({ request })=>{
5249
5305
  unauthorized: ()=>{
5250
5306
  if (resolveResponse) resolveResponse(unauthorized());
5251
5307
  },
5252
- handlerReturn: new Promise((resolve)=>{
5253
- resolveResponse = resolve;
5254
- })
5308
+ handlerReturn: new Promise((res)=>resolveResponse = res)
5255
5309
  };
5256
5310
  };
5257
5311
  const worktop = (req, res)=>({
5258
- update: Promise.resolve(req.json()),
5312
+ get update () {
5313
+ return req.json();
5314
+ },
5259
5315
  header: req.headers.get(SECRET_HEADER) ?? undefined,
5260
5316
  end: ()=>res.end(null),
5261
5317
  respond: (json)=>res.send(200, json),
5262
5318
  unauthorized: ()=>res.send(401, WRONG_TOKEN_ERROR)
5263
5319
  });
5264
5320
  const elysia = (ctx)=>{
5265
- let resolve;
5266
- const handlerReturn = new Promise((res)=>resolve = res);
5321
+ let resolveResponse;
5267
5322
  return {
5268
- update: Promise.resolve(ctx.body),
5323
+ get update () {
5324
+ return ctx.body;
5325
+ },
5269
5326
  header: ctx.headers[SECRET_HEADER_LOWERCASE],
5270
5327
  end () {
5271
- resolve("");
5328
+ resolveResponse("");
5272
5329
  },
5273
5330
  respond (json) {
5274
5331
  ctx.set.headers["content-type"] = "application/json";
5275
- resolve(json);
5332
+ resolveResponse(json);
5276
5333
  },
5277
5334
  unauthorized () {
5278
5335
  ctx.set.status = 401;
5279
- resolve("");
5336
+ resolveResponse("");
5280
5337
  },
5281
- handlerReturn
5338
+ handlerReturn: new Promise((res)=>resolveResponse = res)
5282
5339
  };
5283
5340
  };
5284
5341
  const adapters = {
@@ -5331,26 +5388,25 @@ function webhookCallback(bot, adapter = defaultAdapter, onTimeout, timeoutMillis
5331
5388
  let initialized = false;
5332
5389
  const server = typeof adapter === "string" ? adapters1[adapter] : adapter;
5333
5390
  return async (...args)=>{
5334
- const { update, respond, unauthorized, end, handlerReturn, header } = server(...args);
5391
+ const handler = server(...args);
5335
5392
  if (!initialized) {
5336
5393
  await bot.init();
5337
5394
  initialized = true;
5338
5395
  }
5339
- if (header !== token) {
5340
- await unauthorized();
5341
- console.log(handlerReturn);
5342
- return handlerReturn;
5396
+ if (handler.header !== token) {
5397
+ await handler.unauthorized();
5398
+ return handler.handlerReturn;
5343
5399
  }
5344
5400
  let usedWebhookReply = false;
5345
5401
  const webhookReplyEnvelope = {
5346
5402
  async send (json) {
5347
5403
  usedWebhookReply = true;
5348
- await respond(json);
5404
+ await handler.respond(json);
5349
5405
  }
5350
5406
  };
5351
- await timeoutIfNecessary(bot.handleUpdate(await update, webhookReplyEnvelope), typeof timeout === "function" ? ()=>timeout(...args) : timeout, ms);
5352
- if (!usedWebhookReply) end?.();
5353
- return handlerReturn;
5407
+ await timeoutIfNecessary(bot.handleUpdate(await handler.update, webhookReplyEnvelope), typeof timeout === "function" ? ()=>timeout(...args) : timeout, ms);
5408
+ if (!usedWebhookReply) handler.end?.();
5409
+ return handler.handlerReturn;
5354
5410
  };
5355
5411
  }
5356
5412
  function timeoutIfNecessary(task, onTimeout, timeout) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "grammy",
3
3
  "description": "The Telegram Bot Framework.",
4
- "version": "1.37.0",
4
+ "version": "1.37.1",
5
5
  "author": "KnorpelSenf",
6
6
  "license": "MIT",
7
7
  "engines": {