From 6b97f72d12d2eace936a972daae415773a842918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=8B=D1=80=D1=86=D0=B5=D0=B2=20=D0=92=D0=B0=D0=B4?= =?UTF-8?q?=D0=B8=D0=BC=20=D0=98=D0=B3=D0=BE=D1=80=D0=B5=D0=B2=D0=B8=D1=87?= Date: Wed, 26 Jun 2024 11:40:00 +0300 Subject: [PATCH] Add the TBA method unpinAllGeneralForumTopicMessages --- crates/teloxide-core/schema.ron | 16 +++++++++++++++- crates/teloxide-core/src/adaptors/cache_me.rs | 1 + crates/teloxide-core/src/adaptors/erased.rs | 13 +++++++++++++ crates/teloxide-core/src/adaptors/parse_mode.rs | 3 ++- .../src/adaptors/throttle/requester_impl.rs | 1 + crates/teloxide-core/src/adaptors/trace.rs | 1 + crates/teloxide-core/src/bot/api.rs | 16 ++++++++++++++++ crates/teloxide-core/src/local_macros.rs | 8 ++++++++ crates/teloxide-core/src/payloads.rs | 4 ++++ crates/teloxide-core/src/payloads/setters.rs | 4 ++-- .../unpin_all_general_forum_topic_messages.rs | 16 ++++++++++++++++ crates/teloxide-core/src/requests/requester.rs | 14 ++++++++++++++ 12 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 crates/teloxide-core/src/payloads/unpin_all_general_forum_topic_messages.rs diff --git a/crates/teloxide-core/schema.ron b/crates/teloxide-core/schema.ron index 2e876287..cc649e5d 100644 --- a/crates/teloxide-core/schema.ron +++ b/crates/teloxide-core/schema.ron @@ -39,7 +39,7 @@ //! [github]: https://github.com/WaffleLapkin/tg-methods-schema Schema( - api_version: ApiVersion(ver: "6.7", date: "April 21, 2023"), + api_version: ApiVersion(ver: "6.8", date: "August 18, 2023"), methods: [ Method( names: ("getUpdates", "GetUpdates", "get_updates"), @@ -2801,6 +2801,20 @@ Schema( ), ], ), + Method( + names: ("unpinAllGeneralForumTopicMessages", "UnpinAllGeneralForumTopicMessages", "unpin_all_general_forum_topic_messages"), + return_ty: True, + doc: Doc(md: "Use this method to clear the list of pinned messages in a General 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."), + tg_doc: "https://core.telegram.org/bots/api#unpinallgeneralforumtopicmessages", + tg_category: "Available methods", + params: [ + Param( + name: "chat_id", + ty: RawTy("Recipient"), + descr: Doc(md: "Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)") + ), + ], + ), Method( names: ("answerCallbackQuery", "AnswerCallbackQuery", "answer_callback_query"), return_ty: True, diff --git a/crates/teloxide-core/src/adaptors/cache_me.rs b/crates/teloxide-core/src/adaptors/cache_me.rs index 84b4887e..eecac8bc 100644 --- a/crates/teloxide-core/src/adaptors/cache_me.rs +++ b/crates/teloxide-core/src/adaptors/cache_me.rs @@ -156,6 +156,7 @@ where reopen_general_forum_topic, hide_general_forum_topic, unhide_general_forum_topic, + unpin_all_general_forum_topic_messages, answer_callback_query, set_my_commands, get_my_commands, diff --git a/crates/teloxide-core/src/adaptors/erased.rs b/crates/teloxide-core/src/adaptors/erased.rs index 7e4f390c..509cbdaa 100644 --- a/crates/teloxide-core/src/adaptors/erased.rs +++ b/crates/teloxide-core/src/adaptors/erased.rs @@ -251,6 +251,7 @@ where reopen_general_forum_topic, hide_general_forum_topic, unhide_general_forum_topic, + unpin_all_general_forum_topic_messages, answer_callback_query, set_my_commands, get_my_commands, @@ -699,6 +700,11 @@ trait ErasableRequester<'a> { chat_id: Recipient, ) -> ErasedRequest<'a, UnhideGeneralForumTopic, Self::Err>; + fn unpin_all_general_forum_topic_messages( + &self, + chat_id: Recipient, + ) -> ErasedRequest<'a, UnpinAllGeneralForumTopicMessages, Self::Err>; + fn answer_callback_query( &self, callback_query_id: String, @@ -1500,6 +1506,13 @@ where Requester::unhide_general_forum_topic(self, chat_id).erase() } + fn unpin_all_general_forum_topic_messages( + &self, + chat_id: Recipient, + ) -> ErasedRequest<'a, UnpinAllGeneralForumTopicMessages, Self::Err> { + Requester::unpin_all_general_forum_topic_messages(self, chat_id).erase() + } + fn answer_callback_query( &self, callback_query_id: String, diff --git a/crates/teloxide-core/src/adaptors/parse_mode.rs b/crates/teloxide-core/src/adaptors/parse_mode.rs index d7540115..216893a4 100644 --- a/crates/teloxide-core/src/adaptors/parse_mode.rs +++ b/crates/teloxide-core/src/adaptors/parse_mode.rs @@ -231,12 +231,13 @@ where close_forum_topic, reopen_forum_topic, delete_forum_topic, + unpin_all_forum_topic_messages, edit_general_forum_topic, close_general_forum_topic, reopen_general_forum_topic, hide_general_forum_topic, unhide_general_forum_topic, - unpin_all_forum_topic_messages, + unpin_all_general_forum_topic_messages, answer_callback_query, set_my_commands, get_my_commands, diff --git a/crates/teloxide-core/src/adaptors/throttle/requester_impl.rs b/crates/teloxide-core/src/adaptors/throttle/requester_impl.rs index 436f6488..28d82051 100644 --- a/crates/teloxide-core/src/adaptors/throttle/requester_impl.rs +++ b/crates/teloxide-core/src/adaptors/throttle/requester_impl.rs @@ -139,6 +139,7 @@ where reopen_general_forum_topic, hide_general_forum_topic, unhide_general_forum_topic, + unpin_all_general_forum_topic_messages, answer_callback_query, set_my_commands, get_my_commands, diff --git a/crates/teloxide-core/src/adaptors/trace.rs b/crates/teloxide-core/src/adaptors/trace.rs index 466674d1..bf4141bc 100644 --- a/crates/teloxide-core/src/adaptors/trace.rs +++ b/crates/teloxide-core/src/adaptors/trace.rs @@ -185,6 +185,7 @@ where reopen_general_forum_topic, hide_general_forum_topic, unhide_general_forum_topic, + unpin_all_general_forum_topic_messages, answer_callback_query, set_my_commands, get_my_commands, diff --git a/crates/teloxide-core/src/bot/api.rs b/crates/teloxide-core/src/bot/api.rs index 35c6231c..6ff8b81d 100644 --- a/crates/teloxide-core/src/bot/api.rs +++ b/crates/teloxide-core/src/bot/api.rs @@ -802,6 +802,22 @@ impl Requester for Bot { ) } + type UnpinAllGeneralForumTopicMessages = + JsonRequest; + + fn unpin_all_general_forum_topic_messages( + &self, + chat_id: C, + ) -> Self::UnpinAllGeneralForumTopicMessages + where + C: Into, + { + Self::UnpinAllGeneralForumTopicMessages::new( + self.clone(), + payloads::UnpinAllGeneralForumTopicMessages::new(chat_id), + ) + } + type AnswerCallbackQuery = JsonRequest; fn answer_callback_query(&self, callback_query_id: C) -> Self::AnswerCallbackQuery diff --git a/crates/teloxide-core/src/local_macros.rs b/crates/teloxide-core/src/local_macros.rs index 9ce59f58..8207bd01 100644 --- a/crates/teloxide-core/src/local_macros.rs +++ b/crates/teloxide-core/src/local_macros.rs @@ -1009,6 +1009,14 @@ macro_rules! requester_forward { $body!(unhide_general_forum_topic this (chat_id: C)) } }; + (@method unpin_all_general_forum_topic_messages $body:ident $ty:ident) => { + type UnpinAllGeneralForumTopicMessages = $ty![UnpinAllGeneralForumTopicMessages]; + + fn unpin_all_general_forum_topic_messages(&self, chat_id: C) -> Self::UnpinAllGeneralForumTopicMessages where C: Into { + let this = self; + $body!(unpin_all_general_forum_topic_messages this (chat_id: C)) + } + }; (@method answer_callback_query $body:ident $ty:ident) => { type AnswerCallbackQuery = $ty![AnswerCallbackQuery]; diff --git a/crates/teloxide-core/src/payloads.rs b/crates/teloxide-core/src/payloads.rs index 97d2e61d..7f3cf308 100644 --- a/crates/teloxide-core/src/payloads.rs +++ b/crates/teloxide-core/src/payloads.rs @@ -135,6 +135,7 @@ mod unban_chat_sender_chat; mod unhide_general_forum_topic; mod unpin_all_chat_messages; mod unpin_all_forum_topic_messages; +mod unpin_all_general_forum_topic_messages; mod unpin_chat_message; mod upload_sticker_file; @@ -276,6 +277,9 @@ pub use unpin_all_chat_messages::{UnpinAllChatMessages, UnpinAllChatMessagesSett pub use unpin_all_forum_topic_messages::{ UnpinAllForumTopicMessages, UnpinAllForumTopicMessagesSetters, }; +pub use unpin_all_general_forum_topic_messages::{ + UnpinAllGeneralForumTopicMessages, UnpinAllGeneralForumTopicMessagesSetters, +}; pub use unpin_chat_message::{UnpinChatMessage, UnpinChatMessageSetters}; pub use upload_sticker_file::{UploadStickerFile, UploadStickerFileSetters}; // END BLOCK payload_modules diff --git a/crates/teloxide-core/src/payloads/setters.rs b/crates/teloxide-core/src/payloads/setters.rs index 6faa7d16..9771e38b 100644 --- a/crates/teloxide-core/src/payloads/setters.rs +++ b/crates/teloxide-core/src/payloads/setters.rs @@ -47,6 +47,6 @@ pub use crate::payloads::{ StopMessageLiveLocationInlineSetters as _, StopMessageLiveLocationSetters as _, StopPollSetters as _, UnbanChatMemberSetters as _, UnbanChatSenderChatSetters as _, UnhideGeneralForumTopicSetters as _, UnpinAllChatMessagesSetters as _, - UnpinAllForumTopicMessagesSetters as _, UnpinChatMessageSetters as _, - UploadStickerFileSetters as _, + UnpinAllForumTopicMessagesSetters as _, UnpinAllGeneralForumTopicMessagesSetters as _, + UnpinChatMessageSetters as _, UploadStickerFileSetters as _, }; diff --git a/crates/teloxide-core/src/payloads/unpin_all_general_forum_topic_messages.rs b/crates/teloxide-core/src/payloads/unpin_all_general_forum_topic_messages.rs new file mode 100644 index 00000000..776b066a --- /dev/null +++ b/crates/teloxide-core/src/payloads/unpin_all_general_forum_topic_messages.rs @@ -0,0 +1,16 @@ +//! Generated by `codegen_payloads`, do not edit by hand. + +use serde::Serialize; + +use crate::types::{Recipient, True}; + +impl_payload! { + /// Use this method to clear the list of pinned messages in a General 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. + #[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)] + pub UnpinAllGeneralForumTopicMessages (UnpinAllGeneralForumTopicMessagesSetters) => True { + required { + /// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + pub chat_id: Recipient [into], + } + } +} diff --git a/crates/teloxide-core/src/requests/requester.rs b/crates/teloxide-core/src/requests/requester.rs index 58adb2b6..f178ab8b 100644 --- a/crates/teloxide-core/src/requests/requester.rs +++ b/crates/teloxide-core/src/requests/requester.rs @@ -758,6 +758,19 @@ pub trait Requester { where C: Into; + type UnpinAllGeneralForumTopicMessages: Request< + Payload = UnpinAllGeneralForumTopicMessages, + Err = Self::Err, + >; + + /// For Telegram documentation see [`UnpinAllGeneralForumTopicMessages`]. + fn unpin_all_general_forum_topic_messages( + &self, + chat_id: C, + ) -> Self::UnpinAllGeneralForumTopicMessages + where + C: Into; + type AnswerCallbackQuery: Request; /// For Telegram documentation see [`AnswerCallbackQuery`]. @@ -1297,6 +1310,7 @@ macro_rules! forward_all { reopen_general_forum_topic, hide_general_forum_topic, unhide_general_forum_topic, + unpin_all_general_forum_topic_messages, answer_callback_query, set_my_commands, get_my_commands,