From a7433cd8cc93b762a3ce23fe6f5d3dc220f22324 Mon Sep 17 00:00:00 2001 From: Akulij Date: Mon, 26 May 2025 20:10:12 +0500 Subject: [PATCH] create /deploy admin command --- src/admin.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/admin.rs b/src/admin.rs index e8102cc..5cf648f 100644 --- a/src/admin.rs +++ b/src/admin.rs @@ -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(()) + } } }