create /deploy admin command

This commit is contained in:
Akulij 2025-05-26 20:10:12 +05:00
parent bdb30c8d98
commit a7433cd8cc

View File

@ -1,3 +1,5 @@
use std::fmt::format;
use itertools::Itertools;
use teloxide::{
prelude::*,
@ -5,6 +7,7 @@ use teloxide::{
};
use crate::{
bot_manager::deploy_bot,
db::{CallDB, DB},
BotResult,
};
@ -41,6 +44,8 @@ pub enum AdminCommands {
Users,
/// Cancel current action and sets user state to default
Cancel,
/// Create new instance of telegram bot
Deploy { token: String },
}
pub async fn admin_command_handler(
@ -156,6 +161,15 @@ pub async fn admin_command_handler(
.await?;
Ok(())
}
AdminCommands::Deploy { token } => {
let bot_info = deploy_bot(&mut db, &token).await?;
bot.send_message(
msg.chat.id,
format!("Deployed bot with name: {}", bot_info.name),
)
.await?;
Ok(())
}
}
}