This commit is contained in:
parent
6a71e3375b
commit
13663d1ae3
1 changed files with 63 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
|
use rand::seq::SliceRandom;
|
||||||
|
|
||||||
use crate::core::bot_actions::{actions_util, ExecBodyParams};
|
use crate::core::bot_actions::{actions_util, ExecBodyParams};
|
||||||
use crate::core::botinstance::Channel;
|
use crate::core::botinstance::Channel;
|
||||||
|
@ -26,6 +27,8 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
//said I had no permission, even if being the broadcaster of the channel
|
//said I had no permission, even if being the broadcaster of the channel
|
||||||
Broadcaster,
|
Broadcaster,
|
||||||
Mod(OF_CMD_CHANNEL),
|
Mod(OF_CMD_CHANNEL),
|
||||||
|
VIP(OF_CMD_CHANNEL),
|
||||||
|
Chatter
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
//ADDINNG BOT ACTION TO MODULE MANAGER
|
//ADDINNG BOT ACTION TO MODULE MANAGER
|
||||||
|
@ -50,12 +53,72 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
BotAdmin,
|
BotAdmin,
|
||||||
Broadcaster,
|
Broadcaster,
|
||||||
Mod(OF_CMD_CHANNEL),
|
Mod(OF_CMD_CHANNEL),
|
||||||
|
Chatter,
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
butt.add_to_modmgr(Arc::clone(&mgr)).await;
|
butt.add_to_modmgr(Arc::clone(&mgr)).await;
|
||||||
|
|
||||||
|
let shuffler = BotCommand{
|
||||||
|
module:BotModule(String::from("Shuffler")),
|
||||||
|
command:String::from("Shuffle"),
|
||||||
|
alias: vec![],
|
||||||
|
exec_body: actions_util::asyncbox(shuff),
|
||||||
|
help:String::from("Shuffle Help"),
|
||||||
|
required_roles:vec![
|
||||||
|
BotAdmin,
|
||||||
|
Broadcaster,
|
||||||
|
Mod(OF_CMD_CHANNEL),
|
||||||
|
VIP(OF_CMD_CHANNEL),
|
||||||
|
Chatter
|
||||||
|
]
|
||||||
|
};
|
||||||
|
shuffler.add_to_modmgr(Arc::clone(&mgr)).await;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn shuff(params : ExecBodyParams)
|
||||||
|
{
|
||||||
|
let usermessage = usermsg(¶ms);
|
||||||
|
|
||||||
|
if usermessage.len() > 2
|
||||||
|
{
|
||||||
|
|
||||||
|
let mut indexes: Vec<usize> = (1..usermessage.len()).collect();
|
||||||
|
indexes.shuffle(&mut thread_rng());
|
||||||
|
|
||||||
|
let mut new_reply: HashMap<usize, String> = HashMap::new();
|
||||||
|
for (index, &new_index) in indexes.iter().enumerate() {
|
||||||
|
new_reply.insert(index, usermessage[&new_index].clone());
|
||||||
|
//println!("{:?}", new_reply[&index]);
|
||||||
|
}
|
||||||
|
let mut botreply = String::new();
|
||||||
|
for value in new_reply.values(){
|
||||||
|
botreply.push_str(value);
|
||||||
|
botreply.push(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let bot = Arc::clone(¶ms.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(
|
||||||
|
¶ms.msg,
|
||||||
|
botreply,
|
||||||
|
params.clone()
|
||||||
|
).await;
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//if it only has one word, shuffle its chars (exclude the n word monkaLaugh)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async fn butt(params : ExecBodyParams)
|
async fn butt(params : ExecBodyParams)
|
||||||
{
|
{
|
||||||
//getting User message
|
//getting User message
|
||||||
|
@ -94,10 +157,6 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async fn forsenforsen(params : ExecBodyParams)
|
async fn forsenforsen(params : ExecBodyParams)
|
||||||
{
|
{
|
||||||
if params.msg.message_text == "forsen" || params.msg.message_text == "Forsen"
|
if params.msg.message_text == "forsen" || params.msg.message_text == "Forsen"
|
||||||
|
|
Loading…
Reference in a new issue