Skip to main content

telers/methods/
edit_general_forum_topic.rs

1use crate::client::Bot;
2use serde::Serialize;
3/// Use this method to edit the name of the 'General' 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. Returns `true` on success.
4/// # Documentation
5/// <https://core.telegram.org/bots/api#editgeneralforumtopic>
6/// # Returns
7/// - `bool`
8#[derive(Clone, Debug, Serialize)]
9pub struct EditGeneralForumTopic {
10    /// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
11    pub chat_id: crate::types::ChatIdKind,
12    /// New topic name, 1-128 characters
13    pub name: Box<str>,
14}
15impl EditGeneralForumTopic {
16    /// Creates a new `EditGeneralForumTopic`.
17    ///
18    /// # Arguments
19    /// * `chat_id` - Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
20    /// * `name` - New topic name, 1-128 characters
21    #[must_use]
22    pub fn new<T0: Into<crate::types::ChatIdKind>, T1: Into<Box<str>>>(
23        chat_id: T0,
24        name: T1,
25    ) -> Self {
26        Self {
27            chat_id: chat_id.into(),
28            name: name.into(),
29        }
30    }
31
32    /// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
33    #[must_use]
34    pub fn chat_id<T: Into<crate::types::ChatIdKind>>(self, val: T) -> Self {
35        let mut this = self;
36        this.chat_id = val.into();
37        this
38    }
39
40    /// New topic name, 1-128 characters
41    #[must_use]
42    pub fn name<T: Into<Box<str>>>(self, val: T) -> Self {
43        let mut this = self;
44        this.name = val.into();
45        this
46    }
47}
48impl super::TelegramMethod for EditGeneralForumTopic {
49    type Method = Self;
50    type Return = bool;
51
52    fn build_request<Client>(self, _bot: &Bot<Client>) -> super::Request<Self::Method> {
53        super::Request::new("editGeneralForumTopic", self, None)
54    }
55}