ferrisgram/methods/
edit_message_text.rs

1// WARNING: THIS CODE IS AUTOGENERATED.
2// DO NOT EDIT!!!
3
4#![allow(clippy::too_many_arguments)]
5use serde::Serialize;
6
7use crate::error::Result;
8use crate::types::Message;
9use crate::types::{InlineKeyboardMarkup, LinkPreviewOptions, MessageEntity};
10use crate::Bot;
11
12impl Bot {
13    /// Use this method to edit text and game 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.
14    /// <https://core.telegram.org/bots/api#editmessagetext>
15    pub fn edit_message_text(&self, text: String) -> EditMessageTextBuilder {
16        EditMessageTextBuilder::new(self, text)
17    }
18}
19
20#[derive(Serialize)]
21pub struct EditMessageTextBuilder<'a> {
22    #[serde(skip)]
23    bot: &'a Bot,
24    /// Unique identifier of the business connection on behalf of which the message to be edited was sent
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub business_connection_id: Option<String>,
27    /// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub chat_id: Option<i64>,
30    /// Required if inline_message_id is not specified. Identifier of the message to edit
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub message_id: Option<i64>,
33    /// Required if chat_id and message_id are not specified. Identifier of the inline message
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub inline_message_id: Option<String>,
36    /// New text of the message, 1-4096 characters after entities parsing
37    pub text: String,
38    /// Mode for parsing entities in the message text. See formatting options for more details.
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub parse_mode: Option<String>,
41    /// A JSON-serialized list of special entities that appear in message text, which can be specified instead of parse_mode
42    #[serde(skip_serializing_if = "Option::is_none")]
43    pub entities: Option<Vec<MessageEntity>>,
44    /// Link preview generation options for the message
45    #[serde(skip_serializing_if = "Option::is_none")]
46    pub link_preview_options: Option<LinkPreviewOptions>,
47    /// A JSON-serialized object for an inline keyboard.
48    #[serde(skip_serializing_if = "Option::is_none")]
49    pub reply_markup: Option<InlineKeyboardMarkup>,
50}
51
52impl<'a> EditMessageTextBuilder<'a> {
53    pub fn new(bot: &'a Bot, text: String) -> Self {
54        Self {
55            bot,
56            business_connection_id: None,
57            chat_id: None,
58            message_id: None,
59            inline_message_id: None,
60            text,
61            parse_mode: None,
62            entities: None,
63            link_preview_options: None,
64            reply_markup: None,
65        }
66    }
67
68    pub fn business_connection_id(mut self, business_connection_id: String) -> Self {
69        self.business_connection_id = Some(business_connection_id);
70        self
71    }
72
73    pub fn chat_id(mut self, chat_id: i64) -> Self {
74        self.chat_id = Some(chat_id);
75        self
76    }
77
78    pub fn message_id(mut self, message_id: i64) -> Self {
79        self.message_id = Some(message_id);
80        self
81    }
82
83    pub fn inline_message_id(mut self, inline_message_id: String) -> Self {
84        self.inline_message_id = Some(inline_message_id);
85        self
86    }
87
88    pub fn text(mut self, text: String) -> Self {
89        self.text = text;
90        self
91    }
92
93    pub fn parse_mode(mut self, parse_mode: String) -> Self {
94        self.parse_mode = Some(parse_mode);
95        self
96    }
97
98    pub fn entities(mut self, entities: Vec<MessageEntity>) -> Self {
99        self.entities = Some(entities);
100        self
101    }
102
103    pub fn link_preview_options(mut self, link_preview_options: LinkPreviewOptions) -> Self {
104        self.link_preview_options = Some(link_preview_options);
105        self
106    }
107
108    pub fn reply_markup(mut self, reply_markup: InlineKeyboardMarkup) -> Self {
109        self.reply_markup = Some(reply_markup);
110        self
111    }
112
113    pub async fn send(self) -> Result<Message> {
114        let form = serde_json::to_value(&self)?;
115        self.bot.get("editMessageText", Some(&form)).await
116    }
117}