telegram_bot_raw/requests/
send_chat_action.rs1use crate::requests::*;
2use crate::types::*;
3
4#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)]
7#[must_use = "requests do nothing unless sent"]
8pub enum ChatAction {
9 #[serde(rename = "typing")]
10 Typing,
11 #[serde(rename = "upload_photo")]
12 UploadPhoto,
13 #[serde(rename = "record_video")]
14 RecordVideo,
15 #[serde(rename = "upload_video")]
16 UploadVideo,
17 #[serde(rename = "record_audio")]
18 RecordAudio,
19 #[serde(rename = "upload_audio")]
20 UploadAudio,
21 #[serde(rename = "upload_document")]
22 UploadDocument,
23 #[serde(rename = "find_location")]
24 FindLocation,
25}
26
27#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)]
31pub struct SendChatAction {
32 chat_id: ChatRef,
33 action: ChatAction,
34}
35
36impl Request for SendChatAction {
37 type Type = JsonRequestType<Self>;
38 type Response = JsonTrueToUnitResponse;
39
40 fn serialize(&self) -> Result<HttpRequest, Error> {
41 Self::Type::serialize(RequestUrl::method("sendChatAction"), self)
42 }
43}
44
45impl SendChatAction {
46 pub fn new<C>(chat: C, action: ChatAction) -> Self
47 where
48 C: ToChatRef,
49 {
50 SendChatAction {
51 chat_id: chat.to_chat_ref(),
52 action: action,
53 }
54 }
55}
56
57pub trait CanSendChatAction {
59 fn chat_action(&self, action: ChatAction) -> SendChatAction;
60}
61
62impl<C> CanSendChatAction for C
63where
64 C: ToChatRef,
65{
66 fn chat_action(&self, action: ChatAction) -> SendChatAction {
67 SendChatAction::new(self, action)
68 }
69}