From 74d938751fd44234057a1882e1850a348f83d7fd Mon Sep 17 00:00:00 2001 From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com> Date: Tue, 9 Apr 2024 10:00:01 -0400 Subject: [PATCH 1/3] cucked promote alt --- src/core/identity.rs | 96 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 81 insertions(+), 15 deletions(-) diff --git a/src/core/identity.rs b/src/core/identity.rs index 726bbdf..a6e623d 100644 --- a/src/core/identity.rs +++ b/src/core/identity.rs @@ -8,6 +8,7 @@ use std::sync::Arc; use tokio::sync::RwLock; +use tokio::time::{sleep,Duration}; use twitch_irc::message::PrivmsgMessage; use casual_logger::Log; @@ -59,7 +60,10 @@ pub async fn init(mgr: Arc) { let tempb = BotCommand { module: BotModule(String::from("identity")), 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), help: String::from("promote"), required_roles: vec![ @@ -164,7 +168,7 @@ async fn cmd_promote(params : ExecBodyParams) { 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(); @@ -202,7 +206,7 @@ async fn cmd_promote(params : ExecBodyParams) { // [x] 1. Get trgusr (regardless of -admin flag) // let targetusr = if arg1 == Some("-admin") { arg2 } else { arg1 }; - let targetusr = if + let mut targetusr = if arg1 == Some("-admin") || arg1 == Some("-v") || arg1 == Some("-vip") @@ -222,6 +226,50 @@ async fn cmd_promote(params : ExecBodyParams) { } 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] Get a required lock first @@ -272,14 +320,23 @@ async fn cmd_promote(params : ExecBodyParams) { // [x] 3. Output resulting change let outmsg = match rslt { - ChangeResult::Success(a) => { - format!("o7 Successfully promoted : {a}") + ChangeResult::Success(rsltstr) => { + format!("o7 Successfully promoted {} : {}", + targetusr.unwrap().to_string(), + rsltstr + ) } - ChangeResult::Failed(a) => { - format!("PoroSad failed to promote : {a}") + ChangeResult::Failed(rsltstr) => { + format!("PoroSad failed to promote {} : {}", + targetusr.unwrap().to_string(), + rsltstr + ) } - ChangeResult::NoChange(a) => { - format!("uuh No Promotion Change : {a}") + ChangeResult::NoChange(rsltstr) => { + format!("uuh No Promotion Change {} : {}", + targetusr.unwrap().to_string(), + rsltstr + ) } }; @@ -499,14 +556,23 @@ async fn cmd_demote(params : ExecBodyParams) { */ let outmsg = match rslt { - ChangeResult::Success(a) => { - format!("o7 Successfully demoted : {a}") + ChangeResult::Success(rsltstr) => { + format!("o7 Successfully demoted {} : {}", + targetusr.unwrap().to_string(), + rsltstr + ) } - ChangeResult::Failed(a) => { - format!("PoroSad failed to demote : {a}") + ChangeResult::Failed(rsltstr) => { + format!("PoroSad failed to demote {} : {}", + targetusr.unwrap().to_string(), + rsltstr + ) } - ChangeResult::NoChange(a) => { - format!("uuh No Demotion Change : {a}") + ChangeResult::NoChange(rsltstr) => { + format!("uuh No Demotion Change {} : {}", + targetusr.unwrap().to_string(), + rsltstr + ) } }; From 16c6b0eebb3670fd398c4f8eb0d085faa2eb6b69 Mon Sep 17 00:00:00 2001 From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com> Date: Tue, 9 Apr 2024 12:32:02 -0400 Subject: [PATCH 2/3] self-invoking identity methods --- src/core/identity.rs | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/core/identity.rs b/src/core/identity.rs index a6e623d..59f6eed 100644 --- a/src/core/identity.rs +++ b/src/core/identity.rs @@ -255,16 +255,16 @@ async fn cmd_promote(params : ExecBodyParams) { params.clone(), ).await; - sleep(Duration::from_secs_f64(1.0)).await; + sleep(Duration::from_secs_f64(2.0)).await; botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif( - "... ".to_string() + "... chatter getting cucked ...".to_string() ), params.clone(), ).await; - sleep(Duration::from_secs_f64(2.0)).await; + sleep(Duration::from_secs_f64(1.0)).await; } } @@ -608,6 +608,8 @@ async fn getroles(params : ExecBodyParams) { */ + let sendername = params.msg.clone().sender.name; + let mut argv = params.msg.message_text.split(' '); @@ -615,11 +617,17 @@ async fn getroles(params : ExecBodyParams) { let arg1 = argv.next(); - let targetuser = match arg1 { - None => return, // exit if no arguments + let mut targetuser = match arg1 { + // None => return, // exit if no arguments + None => sendername.as_str(), // self-invoke in this case Some(arg) => arg, }; + targetuser = match twitch_irc::validate::validate_login(targetuser.to_lowercase().as_str()) { + Ok(_) => targetuser, + Err(_) => sendername.as_str(), // self-invoke in this case + }; + let arg2 = argv.next(); let targetchnl = arg2; @@ -703,7 +711,9 @@ async fn getroles(params : ExecBodyParams) { params.msg.channel_login.to_lowercase(), ))) || sproles.contains(&UserRole::BotAdmin) { - outmsg += format!("Target chatter's user roles are : {:?}", sproles).as_str(); + // targetuser + // outmsg += format!("Target chatter's user roles are : {:?}", sproles).as_str(); + outmsg += format!("{}'s user roles are : {:?}", targetuser, sproles).as_str(); } outmsg } else if sproles.contains(&UserRole::Mod(Channel( @@ -712,9 +722,10 @@ async fn getroles(params : ExecBodyParams) { params.msg.channel_login.to_lowercase(), ))) || sproles.contains(&UserRole::BotAdmin) { - format!("Target chatter's user roles are : {:?}", sproles) + // format!("Target chatter's user roles are : {:?}", sproles) + format!("{}'s user roles are : {:?}", targetuser, sproles) } else { - "Target chatter has no special roles LULE ".to_string() + format!("{} has no special roles LULE ",targetuser) }; botlog::debug( From dfb37717b38cec08ad96faad8454d7dd81852ef7 Mon Sep 17 00:00:00 2001 From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com> Date: Tue, 9 Apr 2024 12:36:46 -0400 Subject: [PATCH 3/3] clippy --- src/core/identity.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/identity.rs b/src/core/identity.rs index 59f6eed..0e092e0 100644 --- a/src/core/identity.rs +++ b/src/core/identity.rs @@ -322,19 +322,19 @@ async fn cmd_promote(params : ExecBodyParams) { let outmsg = match rslt { ChangeResult::Success(rsltstr) => { format!("o7 Successfully promoted {} : {}", - targetusr.unwrap().to_string(), + targetusr.unwrap(), rsltstr ) } ChangeResult::Failed(rsltstr) => { format!("PoroSad failed to promote {} : {}", - targetusr.unwrap().to_string(), + targetusr.unwrap(), rsltstr ) } ChangeResult::NoChange(rsltstr) => { format!("uuh No Promotion Change {} : {}", - targetusr.unwrap().to_string(), + targetusr.unwrap(), rsltstr ) } @@ -558,19 +558,19 @@ async fn cmd_demote(params : ExecBodyParams) { let outmsg = match rslt { ChangeResult::Success(rsltstr) => { format!("o7 Successfully demoted {} : {}", - targetusr.unwrap().to_string(), + targetusr.unwrap(), rsltstr ) } ChangeResult::Failed(rsltstr) => { format!("PoroSad failed to demote {} : {}", - targetusr.unwrap().to_string(), + targetusr.unwrap(), rsltstr ) } ChangeResult::NoChange(rsltstr) => { format!("uuh No Demotion Change {} : {}", - targetusr.unwrap().to_string(), + targetusr.unwrap(), rsltstr ) }