migration to JS engine #1

Merged
akulij merged 131 commits from dev into main 2025-05-31 08:49:52 +00:00
2 changed files with 6 additions and 5 deletions
Showing only changes of commit 2fdd8a346d - Show all commits

View File

@ -7,7 +7,7 @@ use teloxide::{
}; };
use crate::{ use crate::{
bot_manager::deploy_bot, bot_manager::create_bot,
db::{CallDB, DB}, db::{CallDB, DB},
BotResult, BotResult,
}; };
@ -162,10 +162,11 @@ pub async fn admin_command_handler(
Ok(()) Ok(())
} }
AdminCommands::Deploy { token } => { AdminCommands::Deploy { token } => {
let bot_info = deploy_bot(&mut db, &token).await?; let bot_instance = create_bot(&mut db, &token).await?;
bot.send_message( bot.send_message(
msg.chat.id, msg.chat.id,
format!("Deployed bot with name: {}", bot_info.name), format!("Deployed bot with name: {}", bot_instance.name),
) )
.await?; .await?;
Ok(()) Ok(())

View File

@ -36,7 +36,7 @@ lazy_static! {
static DEFAULT_SCRIPT: &str = static DEFAULT_SCRIPT: &str =
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/default_script.js")); include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/default_script.js"));
pub async fn deploy_bot(db: &mut DB, token: &str) -> BotResult<BotInfo> { pub async fn create_bot(db: &mut DB, token: &str) -> BotResult<BotInstance> {
let bot = Bot::new(token); let bot = Bot::new(token);
let name = bot.get_me().await?.username().to_string(); let name = bot.get_me().await?.username().to_string();
@ -44,7 +44,7 @@ pub async fn deploy_bot(db: &mut DB, token: &str) -> BotResult<BotInfo> {
.store(db) .store(db)
.await?; .await?;
start_bot(bi, &mut db.clone().with_name(name)).await Ok(bi)
} }
pub async fn start_bot(bi: BotInstance, db: &mut DB) -> BotResult<BotInfo> { pub async fn start_bot(bi: BotInstance, db: &mut DB) -> BotResult<BotInfo> {