diff --git a/crates/teloxide-core/CHANGELOG.md b/crates/teloxide-core/CHANGELOG.md index 5878f77d..40d9a04a 100644 --- a/crates/teloxide-core/CHANGELOG.md +++ b/crates/teloxide-core/CHANGELOG.md @@ -51,6 +51,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - MSRV (Minimal Supported Rust Version) was bumped from `1.64.0` to `1.65.0` - Renamed `ForumTopic::message_thread_id` into `thread_id` ([#887][pr887]) - `ForumTopic::thread_id` and `Message::thread_id` now use `ThreadId` instead of `i32` ([#887][pr887]) +- `message_thread_id` method parameters now use `ThreadId` instead of `i32` ([#887][pr887]) [pr852]: https://github.com/teloxide/teloxide/pull/853 [pr859]: https://github.com/teloxide/teloxide/pull/859 diff --git a/crates/teloxide-core/schema.ron b/crates/teloxide-core/schema.ron index 4dfcb368..66a35e33 100644 --- a/crates/teloxide-core/schema.ron +++ b/crates/teloxide-core/schema.ron @@ -232,7 +232,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( @@ -311,7 +311,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( @@ -356,7 +356,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( @@ -440,7 +440,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( @@ -530,7 +530,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( @@ -635,7 +635,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( @@ -733,7 +733,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( @@ -849,7 +849,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( @@ -963,7 +963,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( @@ -1048,7 +1048,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( @@ -1131,7 +1131,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( @@ -1181,7 +1181,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( @@ -1449,7 +1449,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( @@ -1548,7 +1548,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( @@ -1627,7 +1627,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( @@ -1746,7 +1746,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( @@ -1824,7 +1824,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread; supergroups only") ), ], @@ -2626,7 +2626,7 @@ Schema( ), Param( name: "message_thread_id", - ty: i32, + ty: RawTy("ThreadId"), descr: Doc(md: "Unique identifier for the target message thread of the forum topic"), ), Param( @@ -2655,7 +2655,7 @@ Schema( ), Param( name: "message_thread_id", - ty: i32, + ty: RawTy("ThreadId"), descr: Doc(md: "Unique identifier for the target message thread of the forum topic"), ), ], @@ -2674,7 +2674,7 @@ Schema( ), Param( name: "message_thread_id", - ty: i32, + ty: RawTy("ThreadId"), descr: Doc(md: "Unique identifier for the target message thread of the forum topic"), ), ], @@ -2693,7 +2693,7 @@ Schema( ), Param( name: "message_thread_id", - ty: i32, + ty: RawTy("ThreadId"), descr: Doc(md: "Unique identifier for the target message thread of the forum topic"), ), ], @@ -2712,7 +2712,7 @@ Schema( ), Param( name: "message_thread_id", - ty: i32, + ty: RawTy("ThreadId"), descr: Doc(md: "Unique identifier for the target message thread of the forum topic"), ), ], @@ -3411,7 +3411,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( @@ -3669,7 +3669,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( @@ -4026,7 +4026,7 @@ Schema( ), Param( name: "message_thread_id", - ty: Option(i32), + ty: Option(RawTy("ThreadId")), descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"), ), Param( diff --git a/crates/teloxide-core/src/adaptors/erased.rs b/crates/teloxide-core/src/adaptors/erased.rs index 05cb03cf..0e5ac1db 100644 --- a/crates/teloxide-core/src/adaptors/erased.rs +++ b/crates/teloxide-core/src/adaptors/erased.rs @@ -628,31 +628,31 @@ trait ErasableRequester<'a> { fn edit_forum_topic( &self, chat_id: Recipient, - message_thread_id: i32, + message_thread_id: ThreadId, ) -> ErasedRequest<'a, EditForumTopic, Self::Err>; fn close_forum_topic( &self, chat_id: Recipient, - message_thread_id: i32, + message_thread_id: ThreadId, ) -> ErasedRequest<'a, CloseForumTopic, Self::Err>; fn reopen_forum_topic( &self, chat_id: Recipient, - message_thread_id: i32, + message_thread_id: ThreadId, ) -> ErasedRequest<'a, ReopenForumTopic, Self::Err>; fn delete_forum_topic( &self, chat_id: Recipient, - message_thread_id: i32, + message_thread_id: ThreadId, ) -> ErasedRequest<'a, DeleteForumTopic, Self::Err>; fn unpin_all_forum_topic_messages( &self, chat_id: Recipient, - message_thread_id: i32, + message_thread_id: ThreadId, ) -> ErasedRequest<'a, UnpinAllForumTopicMessages, Self::Err>; fn edit_general_forum_topic( @@ -1368,7 +1368,7 @@ where fn edit_forum_topic( &self, chat_id: Recipient, - message_thread_id: i32, + message_thread_id: ThreadId, ) -> ErasedRequest<'a, EditForumTopic, Self::Err> { Requester::edit_forum_topic(self, chat_id, message_thread_id).erase() } @@ -1376,7 +1376,7 @@ where fn close_forum_topic( &self, chat_id: Recipient, - message_thread_id: i32, + message_thread_id: ThreadId, ) -> ErasedRequest<'a, CloseForumTopic, Self::Err> { Requester::close_forum_topic(self, chat_id, message_thread_id).erase() } @@ -1384,7 +1384,7 @@ where fn reopen_forum_topic( &self, chat_id: Recipient, - message_thread_id: i32, + message_thread_id: ThreadId, ) -> ErasedRequest<'a, ReopenForumTopic, Self::Err> { Requester::reopen_forum_topic(self, chat_id, message_thread_id).erase() } @@ -1392,7 +1392,7 @@ where fn delete_forum_topic( &self, chat_id: Recipient, - message_thread_id: i32, + message_thread_id: ThreadId, ) -> ErasedRequest<'a, DeleteForumTopic, Self::Err> { Requester::delete_forum_topic(self, chat_id, message_thread_id).erase() } @@ -1400,7 +1400,7 @@ where fn unpin_all_forum_topic_messages( &self, chat_id: Recipient, - message_thread_id: i32, + message_thread_id: ThreadId, ) -> ErasedRequest<'a, UnpinAllForumTopicMessages, Self::Err> { Requester::unpin_all_forum_topic_messages(self, chat_id, message_thread_id).erase() } diff --git a/crates/teloxide-core/src/bot/api.rs b/crates/teloxide-core/src/bot/api.rs index 2fbedee0..1c73485f 100644 --- a/crates/teloxide-core/src/bot/api.rs +++ b/crates/teloxide-core/src/bot/api.rs @@ -6,7 +6,7 @@ use crate::{ requests::{JsonRequest, MultipartRequest}, types::{ BotCommand, ChatId, ChatPermissions, InlineQueryResult, InputFile, InputMedia, - InputSticker, LabeledPrice, MessageId, Recipient, UserId, + InputSticker, LabeledPrice, MessageId, Recipient, ThreadId, UserId, }, Bot, }; @@ -671,7 +671,7 @@ impl Requester for Bot { type EditForumTopic = JsonRequest; - fn edit_forum_topic(&self, chat_id: C, message_thread_id: i32) -> Self::EditForumTopic + fn edit_forum_topic(&self, chat_id: C, message_thread_id: ThreadId) -> Self::EditForumTopic where C: Into, { @@ -683,7 +683,7 @@ impl Requester for Bot { type CloseForumTopic = JsonRequest; - fn close_forum_topic(&self, chat_id: C, message_thread_id: i32) -> Self::CloseForumTopic + fn close_forum_topic(&self, chat_id: C, message_thread_id: ThreadId) -> Self::CloseForumTopic where C: Into, { @@ -695,7 +695,11 @@ impl Requester for Bot { type ReopenForumTopic = JsonRequest; - fn reopen_forum_topic(&self, chat_id: C, message_thread_id: i32) -> Self::ReopenForumTopic + fn reopen_forum_topic( + &self, + chat_id: C, + message_thread_id: ThreadId, + ) -> Self::ReopenForumTopic where C: Into, { @@ -707,7 +711,11 @@ impl Requester for Bot { type DeleteForumTopic = JsonRequest; - fn delete_forum_topic(&self, chat_id: C, message_thread_id: i32) -> Self::DeleteForumTopic + fn delete_forum_topic( + &self, + chat_id: C, + message_thread_id: ThreadId, + ) -> Self::DeleteForumTopic where C: Into, { @@ -722,7 +730,7 @@ impl Requester for Bot { fn unpin_all_forum_topic_messages( &self, chat_id: C, - message_thread_id: i32, + message_thread_id: ThreadId, ) -> Self::UnpinAllForumTopicMessages where C: Into, diff --git a/crates/teloxide-core/src/local_macros.rs b/crates/teloxide-core/src/local_macros.rs index 18b4a103..6b66dfe4 100644 --- a/crates/teloxide-core/src/local_macros.rs +++ b/crates/teloxide-core/src/local_macros.rs @@ -931,41 +931,41 @@ macro_rules! requester_forward { (@method edit_forum_topic $body:ident $ty:ident) => { type EditForumTopic = $ty![EditForumTopic]; - fn edit_forum_topic(&self, chat_id: C, message_thread_id: i32) -> Self::EditForumTopic where C: Into { + fn edit_forum_topic(&self, chat_id: C, message_thread_id: ThreadId) -> Self::EditForumTopic where C: Into { let this = self; - $body!(edit_forum_topic this (chat_id: C, message_thread_id: i32)) + $body!(edit_forum_topic this (chat_id: C, message_thread_id: ThreadId)) } }; (@method close_forum_topic $body:ident $ty:ident) => { type CloseForumTopic = $ty![CloseForumTopic]; - fn close_forum_topic(&self, chat_id: C, message_thread_id: i32) -> Self::CloseForumTopic where C: Into { + fn close_forum_topic(&self, chat_id: C, message_thread_id: ThreadId) -> Self::CloseForumTopic where C: Into { let this = self; - $body!(close_forum_topic this (chat_id: C, message_thread_id: i32)) + $body!(close_forum_topic this (chat_id: C, message_thread_id: ThreadId)) } }; (@method reopen_forum_topic $body:ident $ty:ident) => { type ReopenForumTopic = $ty![ReopenForumTopic]; - fn reopen_forum_topic(&self, chat_id: C, message_thread_id: i32) -> Self::ReopenForumTopic where C: Into { + fn reopen_forum_topic(&self, chat_id: C, message_thread_id: ThreadId) -> Self::ReopenForumTopic where C: Into { let this = self; - $body!(reopen_forum_topic this (chat_id: C, message_thread_id: i32)) + $body!(reopen_forum_topic this (chat_id: C, message_thread_id: ThreadId)) } }; (@method delete_forum_topic $body:ident $ty:ident) => { type DeleteForumTopic = $ty![DeleteForumTopic]; - fn delete_forum_topic(&self, chat_id: C, message_thread_id: i32) -> Self::DeleteForumTopic where C: Into { + fn delete_forum_topic(&self, chat_id: C, message_thread_id: ThreadId) -> Self::DeleteForumTopic where C: Into { let this = self; - $body!(delete_forum_topic this (chat_id: C, message_thread_id: i32)) + $body!(delete_forum_topic this (chat_id: C, message_thread_id: ThreadId)) } }; (@method unpin_all_forum_topic_messages $body:ident $ty:ident) => { type UnpinAllForumTopicMessages = $ty![UnpinAllForumTopicMessages]; - fn unpin_all_forum_topic_messages(&self, chat_id: C, message_thread_id: i32) -> Self::UnpinAllForumTopicMessages where C: Into { + fn unpin_all_forum_topic_messages(&self, chat_id: C, message_thread_id: ThreadId) -> Self::UnpinAllForumTopicMessages where C: Into { let this = self; - $body!(unpin_all_forum_topic_messages this (chat_id: C, message_thread_id: i32)) + $body!(unpin_all_forum_topic_messages this (chat_id: C, message_thread_id: ThreadId)) } }; (@method edit_general_forum_topic $body:ident $ty:ident) => { diff --git a/crates/teloxide-core/src/payloads/close_forum_topic.rs b/crates/teloxide-core/src/payloads/close_forum_topic.rs index 4e3d2674..1f81a7ce 100644 --- a/crates/teloxide-core/src/payloads/close_forum_topic.rs +++ b/crates/teloxide-core/src/payloads/close_forum_topic.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{Recipient, True}; +use crate::types::{Recipient, ThreadId, True}; impl_payload! { /// Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights, unless it is the creator of the topic. Returns True on success. @@ -12,7 +12,7 @@ impl_payload! { /// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) pub chat_id: Recipient [into], /// Unique identifier for the target message thread of the forum topic - pub message_thread_id: i32, + pub message_thread_id: ThreadId, } } } diff --git a/crates/teloxide-core/src/payloads/copy_message.rs b/crates/teloxide-core/src/payloads/copy_message.rs index ec5e7a9c..479cbae4 100644 --- a/crates/teloxide-core/src/payloads/copy_message.rs +++ b/crates/teloxide-core/src/payloads/copy_message.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup}; +use crate::types::{MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId}; impl_payload! { /// Use this method to copy messages of any kind. 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. @@ -21,7 +21,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept pub caption: String [into], /// Mode for parsing entities in the photo caption. See [formatting options] for more details. diff --git a/crates/teloxide-core/src/payloads/delete_forum_topic.rs b/crates/teloxide-core/src/payloads/delete_forum_topic.rs index 05824937..66559272 100644 --- a/crates/teloxide-core/src/payloads/delete_forum_topic.rs +++ b/crates/teloxide-core/src/payloads/delete_forum_topic.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{Recipient, True}; +use crate::types::{Recipient, ThreadId, True}; impl_payload! { /// Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_delete\_messages_ administrator rights. Returns True on success. @@ -12,7 +12,7 @@ impl_payload! { /// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) pub chat_id: Recipient [into], /// Unique identifier for the target message thread of the forum topic - pub message_thread_id: i32, + pub message_thread_id: ThreadId, } } } diff --git a/crates/teloxide-core/src/payloads/edit_forum_topic.rs b/crates/teloxide-core/src/payloads/edit_forum_topic.rs index dd311dea..cc589913 100644 --- a/crates/teloxide-core/src/payloads/edit_forum_topic.rs +++ b/crates/teloxide-core/src/payloads/edit_forum_topic.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{Recipient, True}; +use crate::types::{Recipient, ThreadId, True}; impl_payload! { /// Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have _can\_manage\_topics_ administrator rights, unless it is the creator of the topic. Returns True on success. @@ -12,7 +12,7 @@ impl_payload! { /// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) pub chat_id: Recipient [into], /// Unique identifier for the target message thread of the forum topic - pub message_thread_id: i32, + pub message_thread_id: ThreadId, } optional { /// Topic name, 0-128 characters. If not specified or empty, the current name of the topic will be kept diff --git a/crates/teloxide-core/src/payloads/forward_message.rs b/crates/teloxide-core/src/payloads/forward_message.rs index 6b49df99..05be2f37 100644 --- a/crates/teloxide-core/src/payloads/forward_message.rs +++ b/crates/teloxide-core/src/payloads/forward_message.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{Message, MessageId, Recipient}; +use crate::types::{Message, MessageId, Recipient, ThreadId}; impl_payload! { /// Use this method to forward messages of any kind. On success, the sent [`Message`] is returned. @@ -21,7 +21,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// Sends the message [silently]. Users will receive a notification with no sound. /// /// [silently]: https://telegram.org/blog/channels-2-0#silent-messages diff --git a/crates/teloxide-core/src/payloads/reopen_forum_topic.rs b/crates/teloxide-core/src/payloads/reopen_forum_topic.rs index 793fb5ac..33adad27 100644 --- a/crates/teloxide-core/src/payloads/reopen_forum_topic.rs +++ b/crates/teloxide-core/src/payloads/reopen_forum_topic.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{Recipient, True}; +use crate::types::{Recipient, ThreadId, True}; impl_payload! { /// Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights, unless it is the creator of the topic. Returns True on success. @@ -12,7 +12,7 @@ impl_payload! { /// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) pub chat_id: Recipient [into], /// Unique identifier for the target message thread of the forum topic - pub message_thread_id: i32, + pub message_thread_id: ThreadId, } } } diff --git a/crates/teloxide-core/src/payloads/send_animation.rs b/crates/teloxide-core/src/payloads/send_animation.rs index 3c4e487d..a1ee3129 100644 --- a/crates/teloxide-core/src/payloads/send_animation.rs +++ b/crates/teloxide-core/src/payloads/send_animation.rs @@ -3,7 +3,7 @@ use serde::Serialize; use crate::types::{ - InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, + InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId, }; impl_payload! { @@ -23,7 +23,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// Duration of the animation in seconds pub duration: u32, /// Animation width diff --git a/crates/teloxide-core/src/payloads/send_audio.rs b/crates/teloxide-core/src/payloads/send_audio.rs index 5d01eb8b..2fbfe5f5 100644 --- a/crates/teloxide-core/src/payloads/send_audio.rs +++ b/crates/teloxide-core/src/payloads/send_audio.rs @@ -3,7 +3,7 @@ use serde::Serialize; use crate::types::{ - InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, + InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId, }; impl_payload! { @@ -26,7 +26,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// Audio caption, 0-1024 characters after entities parsing pub caption: String [into], /// Mode for parsing entities in the audio caption. See [formatting options] for more details. diff --git a/crates/teloxide-core/src/payloads/send_chat_action.rs b/crates/teloxide-core/src/payloads/send_chat_action.rs index 50b4c3db..46726fba 100644 --- a/crates/teloxide-core/src/payloads/send_chat_action.rs +++ b/crates/teloxide-core/src/payloads/send_chat_action.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{ChatAction, Recipient, True}; +use crate::types::{ChatAction, Recipient, ThreadId, True}; impl_payload! { /// 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. @@ -31,7 +31,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread; supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, } } } diff --git a/crates/teloxide-core/src/payloads/send_contact.rs b/crates/teloxide-core/src/payloads/send_contact.rs index cc8a0c7a..7179cbcc 100644 --- a/crates/teloxide-core/src/payloads/send_contact.rs +++ b/crates/teloxide-core/src/payloads/send_contact.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{Message, MessageId, Recipient, ReplyMarkup}; +use crate::types::{Message, MessageId, Recipient, ReplyMarkup, ThreadId}; impl_payload! { /// Use this method to send phone contacts. On success, the sent [`Message`] is returned. @@ -20,7 +20,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// Contact's last name pub last_name: String [into], /// Additional data about the contact in the form of a [vCard], 0-2048 bytes diff --git a/crates/teloxide-core/src/payloads/send_dice.rs b/crates/teloxide-core/src/payloads/send_dice.rs index 53d1a54c..2a00cbd8 100644 --- a/crates/teloxide-core/src/payloads/send_dice.rs +++ b/crates/teloxide-core/src/payloads/send_dice.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{DiceEmoji, Message, MessageId, Recipient, ReplyMarkup}; +use crate::types::{DiceEmoji, Message, MessageId, Recipient, ReplyMarkup, ThreadId}; impl_payload! { /// Use this method to send an animated emoji that will display a random value. On success, the sent [`Message`] is returned. @@ -16,7 +16,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”. Dice can have values 1-6 for “🎲”, “🎯” and “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲” pub emoji: DiceEmoji, /// Sends the message [silently]. Users will receive a notification with no sound. diff --git a/crates/teloxide-core/src/payloads/send_document.rs b/crates/teloxide-core/src/payloads/send_document.rs index 06fd9f3c..eda12a07 100644 --- a/crates/teloxide-core/src/payloads/send_document.rs +++ b/crates/teloxide-core/src/payloads/send_document.rs @@ -3,7 +3,7 @@ use serde::Serialize; use crate::types::{ - InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, + InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId, }; impl_payload! { @@ -23,7 +23,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . [More info on Sending Files »] /// /// [More info on Sending Files »]: crate::types::InputFile diff --git a/crates/teloxide-core/src/payloads/send_game.rs b/crates/teloxide-core/src/payloads/send_game.rs index be7144d0..734cfede 100644 --- a/crates/teloxide-core/src/payloads/send_game.rs +++ b/crates/teloxide-core/src/payloads/send_game.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{Message, ReplyMarkup}; +use crate::types::{Message, ReplyMarkup, ThreadId}; impl_payload! { /// Use this method to send a game. On success, the sent [`Message`] is returned. @@ -18,7 +18,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// Sends the message [silently]. Users will receive a notification with no sound. /// /// [silently]: https://telegram.org/blog/channels-2-0#silent-messages diff --git a/crates/teloxide-core/src/payloads/send_invoice.rs b/crates/teloxide-core/src/payloads/send_invoice.rs index a888f166..0d428229 100644 --- a/crates/teloxide-core/src/payloads/send_invoice.rs +++ b/crates/teloxide-core/src/payloads/send_invoice.rs @@ -3,7 +3,7 @@ use serde::Serialize; use url::Url; -use crate::types::{InlineKeyboardMarkup, LabeledPrice, Message, Recipient}; +use crate::types::{InlineKeyboardMarkup, LabeledPrice, Message, Recipient, ThreadId}; impl_payload! { /// Use this method to send invoices. On success, the sent [`Message`] is returned. @@ -31,7 +31,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// The maximum accepted amount for tips in the smallest units of the currency (integer, **not** float/double). For example, for a maximum tip of `US$ 1.45` pass `max_tip_amount = 145`. See the exp parameter in [`currencies.json`], it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0 /// /// [`currencies.json`]: https://core.telegram.org/bots/payments/currencies.json diff --git a/crates/teloxide-core/src/payloads/send_location.rs b/crates/teloxide-core/src/payloads/send_location.rs index 68b70791..5d61cbe1 100644 --- a/crates/teloxide-core/src/payloads/send_location.rs +++ b/crates/teloxide-core/src/payloads/send_location.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{Message, MessageId, Recipient, ReplyMarkup}; +use crate::types::{Message, MessageId, Recipient, ReplyMarkup, ThreadId}; impl_payload! { /// Use this method to send point on the map. On success, the sent [`Message`] is returned. @@ -20,7 +20,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// The radius of uncertainty for the location, measured in meters; 0-1500 pub horizontal_accuracy: f64, /// Period in seconds for which the location will be updated (see [Live Locations], should be between 60 and 86400. diff --git a/crates/teloxide-core/src/payloads/send_media_group.rs b/crates/teloxide-core/src/payloads/send_media_group.rs index edf224a9..29c40249 100644 --- a/crates/teloxide-core/src/payloads/send_media_group.rs +++ b/crates/teloxide-core/src/payloads/send_media_group.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{InputMedia, Message, MessageId, Recipient}; +use crate::types::{InputMedia, Message, MessageId, Recipient, ThreadId}; impl_payload! { /// 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 [`Message`]s that were sent is returned. @@ -18,7 +18,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// Sends the message [silently]. Users will receive a notification with no sound. /// /// [silently]: https://telegram.org/blog/channels-2-0#silent-messages diff --git a/crates/teloxide-core/src/payloads/send_message.rs b/crates/teloxide-core/src/payloads/send_message.rs index 0b13dd23..b243aec3 100644 --- a/crates/teloxide-core/src/payloads/send_message.rs +++ b/crates/teloxide-core/src/payloads/send_message.rs @@ -2,7 +2,9 @@ use serde::Serialize; -use crate::types::{Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup}; +use crate::types::{ + Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId, +}; impl_payload! { /// Use this method to send text messages. On success, the sent [`Message`] is returned. @@ -18,7 +20,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// Mode for parsing entities in the message text. See [formatting options] for more details. /// /// [formatting options]: https://core.telegram.org/bots/api#formatting-options diff --git a/crates/teloxide-core/src/payloads/send_photo.rs b/crates/teloxide-core/src/payloads/send_photo.rs index 70e97bea..0c89cc90 100644 --- a/crates/teloxide-core/src/payloads/send_photo.rs +++ b/crates/teloxide-core/src/payloads/send_photo.rs @@ -3,7 +3,7 @@ use serde::Serialize; use crate::types::{ - InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, + InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId, }; impl_payload! { @@ -23,7 +23,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// Photo caption (may also be used when resending photos by _file\_id_), 0-1024 characters after entities parsing pub caption: String [into], /// Mode for parsing entities in the photo caption. See [formatting options] for more details. diff --git a/crates/teloxide-core/src/payloads/send_poll.rs b/crates/teloxide-core/src/payloads/send_poll.rs index d346f61c..080b63d2 100644 --- a/crates/teloxide-core/src/payloads/send_poll.rs +++ b/crates/teloxide-core/src/payloads/send_poll.rs @@ -4,7 +4,7 @@ use chrono::{DateTime, Utc}; use serde::Serialize; use crate::types::{ - Message, MessageEntity, MessageId, ParseMode, PollType, Recipient, ReplyMarkup, + Message, MessageEntity, MessageId, ParseMode, PollType, Recipient, ReplyMarkup, ThreadId, }; impl_payload! { @@ -23,7 +23,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// True, if the poll needs to be anonymous, defaults to True pub is_anonymous: bool, /// Poll type, “quiz” or “regular”, defaults to “regular” diff --git a/crates/teloxide-core/src/payloads/send_sticker.rs b/crates/teloxide-core/src/payloads/send_sticker.rs index b677c5ef..7ab3b568 100644 --- a/crates/teloxide-core/src/payloads/send_sticker.rs +++ b/crates/teloxide-core/src/payloads/send_sticker.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{InputFile, Message, Recipient, ReplyMarkup}; +use crate::types::{InputFile, Message, Recipient, ReplyMarkup, ThreadId}; impl_payload! { @[multipart = sticker] @@ -21,7 +21,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// Sends the message [silently]. Users will receive a notification with no sound. /// /// [silently]: https://telegram.org/blog/channels-2-0#silent-messages diff --git a/crates/teloxide-core/src/payloads/send_venue.rs b/crates/teloxide-core/src/payloads/send_venue.rs index 9b88da62..59fcdcbb 100644 --- a/crates/teloxide-core/src/payloads/send_venue.rs +++ b/crates/teloxide-core/src/payloads/send_venue.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{Message, MessageId, Recipient, ReplyMarkup}; +use crate::types::{Message, MessageId, Recipient, ReplyMarkup, ThreadId}; impl_payload! { /// Use this method to send information about a venue. On success, the sent [`Message`] is returned. @@ -24,7 +24,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// Foursquare identifier of the venue pub foursquare_id: String [into], /// Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) diff --git a/crates/teloxide-core/src/payloads/send_video.rs b/crates/teloxide-core/src/payloads/send_video.rs index 2723e6e4..2c141e8c 100644 --- a/crates/teloxide-core/src/payloads/send_video.rs +++ b/crates/teloxide-core/src/payloads/send_video.rs @@ -3,7 +3,7 @@ use serde::Serialize; use crate::types::{ - InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, + InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId, }; impl_payload! { @@ -24,7 +24,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// Duration of the video in seconds pub duration: u32, /// Video width diff --git a/crates/teloxide-core/src/payloads/send_video_note.rs b/crates/teloxide-core/src/payloads/send_video_note.rs index f4406d48..787e63cb 100644 --- a/crates/teloxide-core/src/payloads/send_video_note.rs +++ b/crates/teloxide-core/src/payloads/send_video_note.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{InputFile, Message, MessageId, Recipient, ReplyMarkup}; +use crate::types::{InputFile, Message, MessageId, Recipient, ReplyMarkup, ThreadId}; impl_payload! { @[multipart = video_note, thumb] @@ -22,7 +22,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// Duration of the video in seconds pub duration: u32, /// Video width and height, i.e. diameter of the video message diff --git a/crates/teloxide-core/src/payloads/send_voice.rs b/crates/teloxide-core/src/payloads/send_voice.rs index 5d854f52..5e5293ed 100644 --- a/crates/teloxide-core/src/payloads/send_voice.rs +++ b/crates/teloxide-core/src/payloads/send_voice.rs @@ -3,7 +3,7 @@ use serde::Serialize; use crate::types::{ - InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, + InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId, }; impl_payload! { @@ -25,7 +25,7 @@ impl_payload! { } optional { /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only - pub message_thread_id: i32, + pub message_thread_id: ThreadId, /// Voice message caption, 0-1024 characters after entities parsing pub caption: String [into], /// Mode for parsing entities in the voice message caption. See [formatting options] for more details. diff --git a/crates/teloxide-core/src/payloads/unpin_all_forum_topic_messages.rs b/crates/teloxide-core/src/payloads/unpin_all_forum_topic_messages.rs index 6b0cc7a4..36a839f4 100644 --- a/crates/teloxide-core/src/payloads/unpin_all_forum_topic_messages.rs +++ b/crates/teloxide-core/src/payloads/unpin_all_forum_topic_messages.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{Recipient, True}; +use crate::types::{Recipient, ThreadId, True}; impl_payload! { /// Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the _can\_pin\_messages_ administrator right in the supergroup. Returns True on success. @@ -12,7 +12,7 @@ impl_payload! { /// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) pub chat_id: Recipient [into], /// Unique identifier for the target message thread of the forum topic - pub message_thread_id: i32, + pub message_thread_id: ThreadId, } } } diff --git a/crates/teloxide-core/src/requests/requester.rs b/crates/teloxide-core/src/requests/requester.rs index 87b9baf1..5336731e 100644 --- a/crates/teloxide-core/src/requests/requester.rs +++ b/crates/teloxide-core/src/requests/requester.rs @@ -678,28 +678,40 @@ pub trait Requester { type EditForumTopic: Request; /// For Telegram documentation see [`EditForumTopic`]. - fn edit_forum_topic(&self, chat_id: C, message_thread_id: i32) -> Self::EditForumTopic + fn edit_forum_topic(&self, chat_id: C, message_thread_id: ThreadId) -> Self::EditForumTopic where C: Into; type CloseForumTopic: Request; /// For Telegram documentation see [`CloseForumTopic`]. - fn close_forum_topic(&self, chat_id: C, message_thread_id: i32) -> Self::CloseForumTopic + fn close_forum_topic( + &self, + chat_id: C, + message_thread_id: ThreadId, + ) -> Self::CloseForumTopic where C: Into; type ReopenForumTopic: Request; /// For Telegram documentation see [`ReopenForumTopic`]. - fn reopen_forum_topic(&self, chat_id: C, message_thread_id: i32) -> Self::ReopenForumTopic + fn reopen_forum_topic( + &self, + chat_id: C, + message_thread_id: ThreadId, + ) -> Self::ReopenForumTopic where C: Into; type DeleteForumTopic: Request; /// For Telegram documentation see [`DeleteForumTopic`]. - fn delete_forum_topic(&self, chat_id: C, message_thread_id: i32) -> Self::DeleteForumTopic + fn delete_forum_topic( + &self, + chat_id: C, + message_thread_id: ThreadId, + ) -> Self::DeleteForumTopic where C: Into; @@ -709,7 +721,7 @@ pub trait Requester { fn unpin_all_forum_topic_messages( &self, chat_id: C, - message_thread_id: i32, + message_thread_id: ThreadId, ) -> Self::UnpinAllForumTopicMessages where C: Into;