Skip to main content

rust_tg_bot_raw/bot/
suggested_posts.rs

1use super::{push_opt, push_opt_str, Bot, Result};
2use crate::request::request_parameter::RequestParameter;
3
4#[allow(dead_code)]
5impl Bot {
6    // ======================================================================
7    // Suggested posts
8    // ======================================================================
9
10    /// Use this method to approve a suggested post in a channel managed by the bot.
11    ///
12    /// Calls the Telegram `approveSuggestedPost` API method.
13    pub async fn approve_suggested_post_raw(
14        &self,
15        chat_id: i64,
16        message_id: i64,
17        send_date: Option<i64>,
18    ) -> Result<bool> {
19        let mut params = vec![
20            RequestParameter::new("chat_id", serde_json::to_value(chat_id)?),
21            RequestParameter::new("message_id", serde_json::to_value(message_id)?),
22        ];
23        push_opt(&mut params, "send_date", &send_date)?;
24        self.do_post("approveSuggestedPost", params).await
25    }
26
27    /// Use this method to decline a suggested post in a channel managed by the bot.
28    ///
29    /// Calls the Telegram `declineSuggestedPost` API method.
30    pub async fn decline_suggested_post_raw(
31        &self,
32        chat_id: i64,
33        message_id: i64,
34        comment: Option<&str>,
35    ) -> Result<bool> {
36        let mut params = vec![
37            RequestParameter::new("chat_id", serde_json::to_value(chat_id)?),
38            RequestParameter::new("message_id", serde_json::to_value(message_id)?),
39        ];
40        push_opt_str(&mut params, "comment", comment);
41        self.do_post("declineSuggestedPost", params).await
42    }
43}