migration to JS engine #1

Merged
akulij merged 131 commits from dev into main 2025-05-31 08:49:52 +00:00
Showing only changes of commit 098cff72bd - Show all commits

View File

@ -23,23 +23,21 @@ pub type BotHandler =
Handler<'static, DependencyMap, BotResult<()>, teloxide::dispatching::DpHandlerDescription>; Handler<'static, DependencyMap, BotResult<()>, teloxide::dispatching::DpHandlerDescription>;
pub fn script_handler(rc: Arc<RwLock<RunnerConfig>>) -> BotHandler { pub fn script_handler(rc: Arc<RwLock<RunnerConfig>>) -> BotHandler {
dptree::entry() dptree::entry().branch(
.inspect(|u: Update| { Update::filter_message()
info!("{u:#?}"); // Print the update to the console with inspect // check if message is command
}) .filter_map(|m: Message| m.text().and_then(|t| BotCommand::from_str(t).ok()))
.branch( // check if command is presented in config
Update::filter_message() .filter_map(move |bc: BotCommand| {
.filter_map(|m: Message| m.text().and_then(|t| BotCommand::from_str(t).ok())) let rc = std::sync::Arc::clone(&rc);
.filter_map(move |bc: BotCommand| { let command = bc.command();
let rc = std::sync::Arc::clone(&rc);
let command = bc.command();
let rc = rc.read().expect("RwLock lock on commands map failed"); let rc = rc.read().expect("RwLock lock on commands map failed");
rc.get_command_message(command) rc.get_command_message(command)
}) })
.endpoint(botscript_command_handler), .endpoint(botscript_command_handler),
) )
} }
async fn botscript_command_handler( async fn botscript_command_handler(