Skip to main content

telers/methods/
edit_message_reply_markup.rs

1use crate::client::Bot;
2use serde::Serialize;
3/// Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise `true` is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
4/// # Documentation
5/// <https://core.telegram.org/bots/api#editmessagereplymarkup>
6/// # Returns
7/// - `crate::types::Message`
8/// - `bool`
9#[derive(Clone, Debug, Serialize)]
10pub struct EditMessageReplyMarkup {
11    /// Unique identifier of the business connection on behalf of which the message to be edited was sent
12    #[serde(skip_serializing_if = "Option::is_none")]
13    pub business_connection_id: Option<Box<str>>,
14    /// Required if `inline_message_id` is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub chat_id: Option<crate::types::ChatIdKind>,
17    /// Required if `inline_message_id` is not specified. Identifier of the message to edit
18    #[serde(skip_serializing_if = "Option::is_none")]
19    pub message_id: Option<i64>,
20    /// Required if `chat_id` and `message_id` are not specified. Identifier of the inline message
21    #[serde(skip_serializing_if = "Option::is_none")]
22    pub inline_message_id: Option<Box<str>>,
23    /// A JSON-serialized object for an inline keyboard.
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub reply_markup: Option<crate::types::InlineKeyboardMarkup>,
26}
27impl EditMessageReplyMarkup {
28    /// Creates a new `EditMessageReplyMarkup`.
29    ///
30    /// # Notes
31    /// Use builder methods to set optional fields.
32    #[must_use]
33    pub fn new() -> Self {
34        Self {
35            business_connection_id: None,
36            chat_id: None,
37            message_id: None,
38            inline_message_id: None,
39            reply_markup: None,
40        }
41    }
42
43    /// Unique identifier of the business connection on behalf of which the message to be edited was sent
44    #[must_use]
45    pub fn business_connection_id<T: Into<Box<str>>>(self, val: T) -> Self {
46        let mut this = self;
47        this.business_connection_id = Some(val.into());
48        this
49    }
50
51    /// Unique identifier of the business connection on behalf of which the message to be edited was sent
52    #[must_use]
53    pub fn business_connection_id_option<T: Into<Box<str>>>(self, val: Option<T>) -> Self {
54        let mut this = self;
55        this.business_connection_id = val.map(Into::into);
56        this
57    }
58
59    /// Required if `inline_message_id` is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
60    #[must_use]
61    pub fn chat_id<T: Into<crate::types::ChatIdKind>>(self, val: T) -> Self {
62        let mut this = self;
63        this.chat_id = Some(val.into());
64        this
65    }
66
67    /// Required if `inline_message_id` is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
68    #[must_use]
69    pub fn chat_id_option<T: Into<crate::types::ChatIdKind>>(self, val: Option<T>) -> Self {
70        let mut this = self;
71        this.chat_id = val.map(Into::into);
72        this
73    }
74
75    /// Required if `inline_message_id` is not specified. Identifier of the message to edit
76    #[must_use]
77    pub fn message_id<T: Into<i64>>(self, val: T) -> Self {
78        let mut this = self;
79        this.message_id = Some(val.into());
80        this
81    }
82
83    /// Required if `inline_message_id` is not specified. Identifier of the message to edit
84    #[must_use]
85    pub fn message_id_option<T: Into<i64>>(self, val: Option<T>) -> Self {
86        let mut this = self;
87        this.message_id = val.map(Into::into);
88        this
89    }
90
91    /// Required if `chat_id` and `message_id` are not specified. Identifier of the inline message
92    #[must_use]
93    pub fn inline_message_id<T: Into<Box<str>>>(self, val: T) -> Self {
94        let mut this = self;
95        this.inline_message_id = Some(val.into());
96        this
97    }
98
99    /// Required if `chat_id` and `message_id` are not specified. Identifier of the inline message
100    #[must_use]
101    pub fn inline_message_id_option<T: Into<Box<str>>>(self, val: Option<T>) -> Self {
102        let mut this = self;
103        this.inline_message_id = val.map(Into::into);
104        this
105    }
106
107    /// A JSON-serialized object for an inline keyboard.
108    #[must_use]
109    pub fn reply_markup<T: Into<crate::types::InlineKeyboardMarkup>>(self, val: T) -> Self {
110        let mut this = self;
111        this.reply_markup = Some(val.into());
112        this
113    }
114
115    /// A JSON-serialized object for an inline keyboard.
116    #[must_use]
117    pub fn reply_markup_option<T: Into<crate::types::InlineKeyboardMarkup>>(
118        self,
119        val: Option<T>,
120    ) -> Self {
121        let mut this = self;
122        this.reply_markup = val.map(Into::into);
123        this
124    }
125}
126impl Default for EditMessageReplyMarkup {
127    fn default() -> Self {
128        Self::new()
129    }
130}
131impl super::TelegramMethod for EditMessageReplyMarkup {
132    type Method = Self;
133    type Return = crate::Either<crate::types::Message, bool>;
134
135    fn build_request<Client>(self, _bot: &Bot<Client>) -> super::Request<Self::Method> {
136        super::Request::new("editMessageReplyMarkup", self, None)
137    }
138}