1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// WARNING: THIS CODE IS AUTOGENERATED.
// DO NOT EDIT!!!
#![allow(clippy::too_many_arguments)]
use serde::Serialize;
use crate::error::Result;
use crate::Bot;
impl Bot {
/// Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success.
/// We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
/// <https://core.telegram.org/bots/api#sendchataction>
pub fn send_chat_action(&self, chat_id: i64, action: String) -> SendChatActionBuilder {
SendChatActionBuilder::new(self, chat_id, action)
}
}
#[derive(Serialize)]
pub struct SendChatActionBuilder<'a> {
#[serde(skip)]
bot: &'a Bot,
/// Unique identifier of the business connection on behalf of which the action will be sent
#[serde(skip_serializing_if = "Option::is_none")]
pub business_connection_id: Option<String>,
/// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
pub chat_id: i64,
/// Unique identifier for the target message thread; for supergroups only
#[serde(skip_serializing_if = "Option::is_none")]
pub message_thread_id: Option<i64>,
/// Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes.
pub action: String,
}
impl<'a> SendChatActionBuilder<'a> {
pub fn new(bot: &'a Bot, chat_id: i64, action: String) -> Self {
Self {
bot,
business_connection_id: None,
chat_id,
message_thread_id: None,
action,
}
}
pub fn business_connection_id(mut self, business_connection_id: String) -> Self {
self.business_connection_id = Some(business_connection_id);
self
}
pub fn chat_id(mut self, chat_id: i64) -> Self {
self.chat_id = chat_id;
self
}
pub fn message_thread_id(mut self, message_thread_id: i64) -> Self {
self.message_thread_id = Some(message_thread_id);
self
}
pub fn action(mut self, action: String) -> Self {
self.action = action;
self
}
pub async fn send(self) -> Result<bool> {
let form = serde_json::to_value(&self)?;
self.bot.get("sendChatAction", Some(&form)).await
}
}