cucked promote alt
This commit is contained in:
parent
2bf0e0e738
commit
74d938751f
1 changed files with 81 additions and 15 deletions
|
@ -8,6 +8,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
|
use tokio::time::{sleep,Duration};
|
||||||
use twitch_irc::message::PrivmsgMessage;
|
use twitch_irc::message::PrivmsgMessage;
|
||||||
|
|
||||||
use casual_logger::Log;
|
use casual_logger::Log;
|
||||||
|
@ -59,7 +60,10 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
let tempb = BotCommand {
|
let tempb = BotCommand {
|
||||||
module: BotModule(String::from("identity")),
|
module: BotModule(String::from("identity")),
|
||||||
command: String::from("promote"), // command call name
|
command: String::from("promote"), // command call name
|
||||||
alias: vec![], // String of alternative names
|
alias: vec![
|
||||||
|
"cucked".to_string(),
|
||||||
|
"cuck".to_string(),
|
||||||
|
], // String of alternative names
|
||||||
exec_body: actions_util::asyncbox(cmd_promote),
|
exec_body: actions_util::asyncbox(cmd_promote),
|
||||||
help: String::from("promote"),
|
help: String::from("promote"),
|
||||||
required_roles: vec![
|
required_roles: vec![
|
||||||
|
@ -164,7 +168,7 @@ async fn cmd_promote(params : ExecBodyParams) {
|
||||||
|
|
||||||
let mut argv = params.msg.message_text.split(' ');
|
let mut argv = params.msg.message_text.split(' ');
|
||||||
|
|
||||||
argv.next(); // Skip the command name
|
let cmdname = argv.next(); // Skip the command name
|
||||||
|
|
||||||
let arg1 = argv.next();
|
let arg1 = argv.next();
|
||||||
|
|
||||||
|
@ -202,7 +206,7 @@ async fn cmd_promote(params : ExecBodyParams) {
|
||||||
// [x] 1. Get trgusr (regardless of -admin flag)
|
// [x] 1. Get trgusr (regardless of -admin flag)
|
||||||
|
|
||||||
// let targetusr = if arg1 == Some("-admin") { arg2 } else { arg1 };
|
// let targetusr = if arg1 == Some("-admin") { arg2 } else { arg1 };
|
||||||
let targetusr = if
|
let mut targetusr = if
|
||||||
arg1 == Some("-admin")
|
arg1 == Some("-admin")
|
||||||
|| arg1 == Some("-v")
|
|| arg1 == Some("-v")
|
||||||
|| arg1 == Some("-vip")
|
|| arg1 == Some("-vip")
|
||||||
|
@ -222,6 +226,50 @@ async fn cmd_promote(params : ExecBodyParams) {
|
||||||
}
|
}
|
||||||
else { arg1 };
|
else { arg1 };
|
||||||
|
|
||||||
|
|
||||||
|
// [x] Check if target is an existing user
|
||||||
|
targetusr = if let Some(chkusr) = targetusr {
|
||||||
|
match twitch_irc::validate::validate_login(chkusr.to_lowercase().as_str()) {
|
||||||
|
Ok(_) => Some(chkusr),
|
||||||
|
Err(_) => None,
|
||||||
|
}
|
||||||
|
} else { None } ;
|
||||||
|
|
||||||
|
|
||||||
|
// [x] Check if cmd passed is cucked, then go through special cucked handling
|
||||||
|
if let Some(cmd_to_check) = cmdname {
|
||||||
|
if cmd_to_check.to_lowercase() == String::from(botlock.get_prefix()) + "cucked"
|
||||||
|
|| cmd_to_check.to_lowercase() == String::from(botlock.get_prefix()) + "cuck"
|
||||||
|
{
|
||||||
|
|
||||||
|
let idlock = botlock.botmgrs.identity.read().await;
|
||||||
|
let senderroles = idlock.getspecialuserroles(sendername.clone(), Some(Channel(targetchnl.to_lowercase()))).await;
|
||||||
|
|
||||||
|
if senderroles.contains(&UserRole::BotAdmin) && targetusr.is_none() {
|
||||||
|
targetusr = Some(sendername.as_str())
|
||||||
|
}
|
||||||
|
|
||||||
|
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
|
||||||
|
"uuh ".to_string()
|
||||||
|
),
|
||||||
|
params.clone(),
|
||||||
|
).await;
|
||||||
|
|
||||||
|
sleep(Duration::from_secs_f64(1.0)).await;
|
||||||
|
|
||||||
|
|
||||||
|
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
|
||||||
|
"... ".to_string()
|
||||||
|
),
|
||||||
|
params.clone(),
|
||||||
|
).await;
|
||||||
|
|
||||||
|
sleep(Duration::from_secs_f64(2.0)).await;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// [x] 2. promote trguser
|
// [x] 2. promote trguser
|
||||||
|
|
||||||
// [x] Get a required lock first
|
// [x] Get a required lock first
|
||||||
|
@ -272,14 +320,23 @@ async fn cmd_promote(params : ExecBodyParams) {
|
||||||
// [x] 3. Output resulting change
|
// [x] 3. Output resulting change
|
||||||
|
|
||||||
let outmsg = match rslt {
|
let outmsg = match rslt {
|
||||||
ChangeResult::Success(a) => {
|
ChangeResult::Success(rsltstr) => {
|
||||||
format!("o7 Successfully promoted : {a}")
|
format!("o7 Successfully promoted {} : {}",
|
||||||
|
targetusr.unwrap().to_string(),
|
||||||
|
rsltstr
|
||||||
|
)
|
||||||
}
|
}
|
||||||
ChangeResult::Failed(a) => {
|
ChangeResult::Failed(rsltstr) => {
|
||||||
format!("PoroSad failed to promote : {a}")
|
format!("PoroSad failed to promote {} : {}",
|
||||||
|
targetusr.unwrap().to_string(),
|
||||||
|
rsltstr
|
||||||
|
)
|
||||||
}
|
}
|
||||||
ChangeResult::NoChange(a) => {
|
ChangeResult::NoChange(rsltstr) => {
|
||||||
format!("uuh No Promotion Change : {a}")
|
format!("uuh No Promotion Change {} : {}",
|
||||||
|
targetusr.unwrap().to_string(),
|
||||||
|
rsltstr
|
||||||
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -499,14 +556,23 @@ async fn cmd_demote(params : ExecBodyParams) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let outmsg = match rslt {
|
let outmsg = match rslt {
|
||||||
ChangeResult::Success(a) => {
|
ChangeResult::Success(rsltstr) => {
|
||||||
format!("o7 Successfully demoted : {a}")
|
format!("o7 Successfully demoted {} : {}",
|
||||||
|
targetusr.unwrap().to_string(),
|
||||||
|
rsltstr
|
||||||
|
)
|
||||||
}
|
}
|
||||||
ChangeResult::Failed(a) => {
|
ChangeResult::Failed(rsltstr) => {
|
||||||
format!("PoroSad failed to demote : {a}")
|
format!("PoroSad failed to demote {} : {}",
|
||||||
|
targetusr.unwrap().to_string(),
|
||||||
|
rsltstr
|
||||||
|
)
|
||||||
}
|
}
|
||||||
ChangeResult::NoChange(a) => {
|
ChangeResult::NoChange(rsltstr) => {
|
||||||
format!("uuh No Demotion Change : {a}")
|
format!("uuh No Demotion Change {} : {}",
|
||||||
|
targetusr.unwrap().to_string(),
|
||||||
|
rsltstr
|
||||||
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue