create /deploy admin command
This commit is contained in:
parent
bdb30c8d98
commit
a7433cd8cc
14
src/admin.rs
14
src/admin.rs
@ -1,3 +1,5 @@
|
|||||||
|
use std::fmt::format;
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use teloxide::{
|
use teloxide::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
@ -5,6 +7,7 @@ use teloxide::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
bot_manager::deploy_bot,
|
||||||
db::{CallDB, DB},
|
db::{CallDB, DB},
|
||||||
BotResult,
|
BotResult,
|
||||||
};
|
};
|
||||||
@ -41,6 +44,8 @@ pub enum AdminCommands {
|
|||||||
Users,
|
Users,
|
||||||
/// Cancel current action and sets user state to default
|
/// Cancel current action and sets user state to default
|
||||||
Cancel,
|
Cancel,
|
||||||
|
/// Create new instance of telegram bot
|
||||||
|
Deploy { token: String },
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn admin_command_handler(
|
pub async fn admin_command_handler(
|
||||||
@ -156,6 +161,15 @@ pub async fn admin_command_handler(
|
|||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
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(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user