// 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 to unban a previously banned user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned. Returns True on success.
/// <https://core.telegram.org/bots/api#unbanchatmember>
pub fn unban_chat_member(&self, chat_id: i64, user_id: i64) -> UnbanChatMemberBuilder {
UnbanChatMemberBuilder::new(self, chat_id, user_id)
}
}
#[derive(Serialize)]
pub struct UnbanChatMemberBuilder<'a> {
#[serde(skip)]
bot: &'a Bot,
/// Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername)
pub chat_id: i64,
/// Unique identifier of the target user
pub user_id: i64,
/// Do nothing if the user is not banned
#[serde(skip_serializing_if = "Option::is_none")]
pub only_if_banned: Option<bool>,
}
impl<'a> UnbanChatMemberBuilder<'a> {
pub fn new(bot: &'a Bot, chat_id: i64, user_id: i64) -> Self {
Self {
bot,
chat_id,
user_id,
only_if_banned: None,
}
}
pub fn chat_id(mut self, chat_id: i64) -> Self {
self.chat_id = chat_id;
self
}
pub fn user_id(mut self, user_id: i64) -> Self {
self.user_id = user_id;
self
}
pub fn only_if_banned(mut self, only_if_banned: bool) -> Self {
self.only_if_banned = Some(only_if_banned);
self
}
pub async fn send(self) -> Result<bool> {
let form = serde_json::to_value(&self)?;
self.bot.get("unbanChatMember", Some(&form)).await
}
}