Skip to main content

rust_tg_bot_raw/bot/
verification.rs

1use super::{push_opt_str, Bot, ChatId, Result};
2use crate::request::request_parameter::RequestParameter;
3
4#[allow(dead_code)]
5impl Bot {
6    // ======================================================================
7    // Verification
8    // ======================================================================
9
10    /// Use this method to verify a chat on behalf of the organization that the bot represents.
11    ///
12    /// Calls the Telegram `verifyChat` API method.
13    pub async fn verify_chat_raw(
14        &self,
15        chat_id: ChatId,
16        custom_description: Option<&str>,
17    ) -> Result<bool> {
18        let mut params = vec![RequestParameter::new(
19            "chat_id",
20            serde_json::to_value(&chat_id)?,
21        )];
22        push_opt_str(&mut params, "custom_description", custom_description);
23        self.do_post("verifyChat", params).await
24    }
25
26    /// Use this method to verify a user on behalf of the organization that the bot represents.
27    ///
28    /// Calls the Telegram `verifyUser` API method.
29    pub async fn verify_user_raw(
30        &self,
31        user_id: i64,
32        custom_description: Option<&str>,
33    ) -> Result<bool> {
34        let mut params = vec![RequestParameter::new(
35            "user_id",
36            serde_json::to_value(user_id)?,
37        )];
38        push_opt_str(&mut params, "custom_description", custom_description);
39        self.do_post("verifyUser", params).await
40    }
41
42    /// Use this method to remove verification from a chat.
43    ///
44    /// Calls the Telegram `removeChatVerification` API method.
45    pub async fn remove_chat_verification_raw(&self, chat_id: ChatId) -> Result<bool> {
46        let params = vec![RequestParameter::new(
47            "chat_id",
48            serde_json::to_value(&chat_id)?,
49        )];
50        self.do_post("removeChatVerification", params).await
51    }
52
53    /// Use this method to remove verification from a user.
54    ///
55    /// Calls the Telegram `removeUserVerification` API method.
56    pub async fn remove_user_verification_raw(&self, user_id: i64) -> Result<bool> {
57        let params = vec![RequestParameter::new(
58            "user_id",
59            serde_json::to_value(user_id)?,
60        )];
61        self.do_post("removeUserVerification", params).await
62    }
63}