added Forsen
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful

This commit is contained in:
haruyuumei 2024-04-03 09:34:41 -03:00
parent 07028cb519
commit bb2222e42b

View file

@ -2,7 +2,7 @@ use std::collections::HashMap;
use std::sync::Arc;
use crate::core::bot_actions::{actions_util, ExecBodyParams};
use crate::core::botinstance::Channel;
use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule,ModulesManager};
use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, Listener, ModulesManager};
use crate::core::identity::UserRole::*;
const OF_CMD_CHANNEL:Channel = Channel(String::new());
//use rand::{thread_rng, Rng};
@ -28,8 +28,34 @@ pub async fn init(mgr: Arc<ModulesManager>) {
};
//ADDINNG BOT ACTION TO MODULE MANAGER
replyer.add_to_modmgr(Arc::clone(&mgr)).await;
let forsen_listener = Listener{
module:BotModule(String::from("TextMods")),
name:String::from("Forsen Listener"),
exec_body:actions_util::asyncbox(forsenforsen),
help:String::from("Forsen helper"),
};
forsen_listener.add_to_modmgr(Arc::clone(&mgr)).await;
}
async fn forsenforsen(params : ExecBodyParams)
{
if params.msg.message_text == "forsen" || params.msg.message_text == "Forsen"
{
let bot = Arc::clone(&params.bot);
let botlock = bot.read().await;
// uses chat.say_in_reply_to() for the bot controls for messages
botlock
.botmgrs
.chat
.say_in_reply_to(
&params.msg,
String::from("Forsen!"),
params.clone()
).await;
}
}
async fn thereplyer(params : ExecBodyParams)
{
@ -62,8 +88,6 @@ pub async fn init(mgr: Arc<ModulesManager>) {
let bot = Arc::clone(&params.bot);
let botlock = bot.read().await;
// uses chat.say_in_reply_to() for the bot controls for messages
@ -75,6 +99,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
bot_reply.clone(),
params.clone()
).await;
}