Skip to main content

rust_tg_bot_raw/bot/
reactions.rs

1use super::{push_opt, Bot, ChatId, Result};
2use crate::request::request_parameter::RequestParameter;
3use crate::types::chat_boost;
4
5#[allow(dead_code)]
6impl Bot {
7    // ======================================================================
8    // Reactions & boosts
9    // ======================================================================
10
11    /// Use this method to change the chosen reactions on a message.
12    ///
13    /// Calls the Telegram `setMessageReaction` API method.
14    pub async fn set_message_reaction_raw(
15        &self,
16        chat_id: ChatId,
17        message_id: i64,
18        reaction: Option<Vec<serde_json::Value>>,
19        is_big: Option<bool>,
20    ) -> Result<bool> {
21        let mut params = vec![
22            RequestParameter::new("chat_id", serde_json::to_value(&chat_id)?),
23            RequestParameter::new("message_id", serde_json::to_value(message_id)?),
24        ];
25        push_opt(&mut params, "reaction", &reaction)?;
26        push_opt(&mut params, "is_big", &is_big)?;
27        self.do_post("setMessageReaction", params).await
28    }
29
30    /// Use this method to get the list of boosts added to a chat by a user.
31    ///
32    /// Calls the Telegram `getUserChatBoosts` API method.
33    pub async fn get_user_chat_boosts_raw(
34        &self,
35        chat_id: ChatId,
36        user_id: i64,
37    ) -> Result<chat_boost::UserChatBoosts> {
38        let params = vec![
39            RequestParameter::new("chat_id", serde_json::to_value(&chat_id)?),
40            RequestParameter::new("user_id", serde_json::to_value(user_id)?),
41        ];
42        self.do_post("getUserChatBoosts", params).await
43    }
44}