ferrisgram/methods/
send_video_note.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::input_file::InputFile;
9use crate::types::Message;
10use crate::types::{InlineKeyboardMarkup, ReplyParameters};
11use crate::Bot;
12use std::collections::HashMap;
13
14impl Bot {
15    /// As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent Message is returned.
16    /// <https://core.telegram.org/bots/api#sendvideonote>
17    pub fn send_video_note<F: InputFile>(
18        &self,
19        chat_id: i64,
20        video_note: F,
21    ) -> SendVideoNoteBuilder<F> {
22        SendVideoNoteBuilder::new(self, chat_id, video_note)
23    }
24}
25
26#[derive(Serialize)]
27pub struct SendVideoNoteBuilder<'a, F: InputFile> {
28    #[serde(skip)]
29    bot: &'a Bot,
30    #[serde(skip)]
31    data: HashMap<&'a str, F>,
32    /// Unique identifier of the business connection on behalf of which the message will be sent
33    #[serde(skip_serializing_if = "Option::is_none")]
34    pub business_connection_id: Option<String>,
35    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
36    pub chat_id: i64,
37    /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub message_thread_id: Option<i64>,
40    /// Duration of sent video in seconds
41    #[serde(skip_serializing_if = "Option::is_none")]
42    pub duration: Option<i64>,
43    /// Video width and height, i.e. diameter of the video message
44    #[serde(skip_serializing_if = "Option::is_none")]
45    pub length: Option<i64>,
46    /// Sends the message silently. Users will receive a notification with no sound.
47    #[serde(skip_serializing_if = "Option::is_none")]
48    pub disable_notification: Option<bool>,
49    /// Protects the contents of the sent message from forwarding and saving
50    #[serde(skip_serializing_if = "Option::is_none")]
51    pub protect_content: Option<bool>,
52    /// Unique identifier of the message effect to be added to the message; for private chats only
53    #[serde(skip_serializing_if = "Option::is_none")]
54    pub message_effect_id: Option<String>,
55    /// Description of the message to reply to
56    #[serde(skip_serializing_if = "Option::is_none")]
57    pub reply_parameters: Option<ReplyParameters>,
58    /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub reply_markup: Option<InlineKeyboardMarkup>,
61}
62
63impl<'a, F: InputFile> SendVideoNoteBuilder<'a, F> {
64    pub fn new(bot: &'a Bot, chat_id: i64, video_note: F) -> Self {
65        let mut data = HashMap::new();
66        data.insert("video_note", video_note);
67        Self {
68            bot,
69            data,
70            business_connection_id: None,
71            chat_id,
72            message_thread_id: None,
73            duration: None,
74            length: None,
75            disable_notification: None,
76            protect_content: None,
77            message_effect_id: None,
78            reply_parameters: None,
79            reply_markup: None,
80        }
81    }
82
83    pub fn business_connection_id(mut self, business_connection_id: String) -> Self {
84        self.business_connection_id = Some(business_connection_id);
85        self
86    }
87
88    pub fn chat_id(mut self, chat_id: i64) -> Self {
89        self.chat_id = chat_id;
90        self
91    }
92
93    pub fn message_thread_id(mut self, message_thread_id: i64) -> Self {
94        self.message_thread_id = Some(message_thread_id);
95        self
96    }
97
98    pub fn video_note(mut self, video_note: F) -> Self {
99        self.data.insert("video_note", video_note);
100        self
101    }
102
103    pub fn duration(mut self, duration: i64) -> Self {
104        self.duration = Some(duration);
105        self
106    }
107
108    pub fn length(mut self, length: i64) -> Self {
109        self.length = Some(length);
110        self
111    }
112
113    pub fn thumbnail(mut self, thumbnail: F) -> Self {
114        self.data.insert("thumbnail", thumbnail);
115        self
116    }
117
118    pub fn disable_notification(mut self, disable_notification: bool) -> Self {
119        self.disable_notification = Some(disable_notification);
120        self
121    }
122
123    pub fn protect_content(mut self, protect_content: bool) -> Self {
124        self.protect_content = Some(protect_content);
125        self
126    }
127
128    pub fn message_effect_id(mut self, message_effect_id: String) -> Self {
129        self.message_effect_id = Some(message_effect_id);
130        self
131    }
132
133    pub fn reply_parameters(mut self, reply_parameters: ReplyParameters) -> Self {
134        self.reply_parameters = Some(reply_parameters);
135        self
136    }
137
138    pub fn reply_markup(mut self, reply_markup: InlineKeyboardMarkup) -> Self {
139        self.reply_markup = Some(reply_markup);
140        self
141    }
142
143    pub async fn send(self) -> Result<Message> {
144        let form = serde_json::to_value(&self)?;
145        self.bot
146            .post("sendVideoNote", Some(&form), Some(self.data))
147            .await
148    }
149}