WIP: TextMods-Module #58

Draft
HaruYuumei wants to merge 15 commits from TextMods-Module into master
Showing only changes of commit bb2222e42b - Show all commits

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,19 +88,18 @@ 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
botlock
.botmgrs
.chat
.say_in_reply_to(
&params.msg,
bot_reply.clone(),
params.clone()
).await;
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,
bot_reply.clone(),
params.clone()
).await;
}