diff --git a/src/custom/text_mods.rs b/src/custom/text_mods.rs index 015c4e9..2a1b87b 100644 --- a/src/custom/text_mods.rs +++ b/src/custom/text_mods.rs @@ -93,7 +93,87 @@ pub async fn init(mgr: Arc) { }; the8ball.add_to_modmgr(Arc::clone(&mgr)).await; + let percent:BotCommand = BotCommand{ + module:BotModule(String::from("percent")), + command:String::from("%"), + alias:vec![], + exec_body: actions_util::asyncbox(percentage), + help: String::from("Percent Help"), + required_roles: vec![ + BotAdmin, + Broadcaster, + Mod(OF_CMD_CHANNEL), + VIP(OF_CMD_CHANNEL), + Chatter + ] + }; + percent.add_to_modmgr(Arc::clone(&mgr)).await; + let filler: BotCommand = BotCommand{ + module:BotModule(String::from("filler")), + command:String::from("fill"), + alias:vec![String::from("Fill")], + exec_body:actions_util::asyncbox(fill), + help:String::from("fill Help"), + required_roles: vec![ + BotAdmin, + Broadcaster, + Mod(OF_CMD_CHANNEL), + VIP(OF_CMD_CHANNEL) + ] + }; + filler.add_to_modmgr(Arc::clone(&mgr)).await; + +} + +///Fill command, can be used to make the bot reply with a certain quantity of the same message +/// +/// only works with `(prefix)fill` `word` `quantity` +/// +/// +async fn fill(params : ExecBodyParams) +{ + let usermessage = usermsg(¶ms); + let quantity = usermessage.get(&2).unwrap(); + let mut botreply = String::new(); + + for _i in 0..quantity.parse::().unwrap(){ + botreply.push_str(usermessage.get(&1).unwrap().trim()); + botreply.push(' '); + } + + let bot = Arc::clone(¶ms.bot); + let botlock = bot.read().await; + botlock + .botmgrs + .chat + .say_in_reply( + Channel(params.clone().msg.channel_login().to_string()), + botreply.clone(), + params.clone() + ).await; +} + + +///Percentage is a function that returns a ramdom % +/// +async fn percentage (params : ExecBodyParams) +{ + let mut _botreply = String::new(); + let rng = thread_rng().gen_range(0..100); + let rng_string = rng.to_string(); + _botreply = rng_string + "%"; + + let bot = Arc::clone(¶ms.bot); + let botlock = bot.read().await; + botlock + .botmgrs + .chat + .say_in_reply( + Channel(params.clone().msg.channel_login().to_string()), + _botreply.clone(), + params.clone() + ).await; } @@ -132,8 +212,6 @@ async fn the8ball(params : ExecBodyParams) let randchoice = thread_rng().gen_range(0..vecanswears.len()); let ballmessage = &vecanswears[randchoice]; - - let bot = Arc::clone(¶ms.bot); let botlock = bot.read().await; botlock