Cucked alt for promote #75
1 changed files with 97 additions and 20 deletions
|
@ -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<ModulesManager>) {
|
|||
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(2.0)).await;
|
||||
|
||||
|
||||
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
|
||||
"... chatter getting cucked ...".to_string()
|
||||
),
|
||||
params.clone(),
|
||||
).await;
|
||||
|
||||
sleep(Duration::from_secs_f64(1.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(),
|
||||
rsltstr
|
||||
)
|
||||
}
|
||||
ChangeResult::Failed(a) => {
|
||||
format!("PoroSad failed to promote : {a}")
|
||||
ChangeResult::Failed(rsltstr) => {
|
||||
format!("PoroSad failed to promote {} : {}",
|
||||
targetusr.unwrap(),
|
||||
rsltstr
|
||||
)
|
||||
}
|
||||
ChangeResult::NoChange(a) => {
|
||||
format!("uuh No Promotion Change : {a}")
|
||||
ChangeResult::NoChange(rsltstr) => {
|
||||
format!("uuh No Promotion Change {} : {}",
|
||||
targetusr.unwrap(),
|
||||
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(),
|
||||
rsltstr
|
||||
)
|
||||
}
|
||||
ChangeResult::Failed(a) => {
|
||||
format!("PoroSad failed to demote : {a}")
|
||||
ChangeResult::Failed(rsltstr) => {
|
||||
format!("PoroSad failed to demote {} : {}",
|
||||
targetusr.unwrap(),
|
||||
rsltstr
|
||||
)
|
||||
}
|
||||
ChangeResult::NoChange(a) => {
|
||||
format!("uuh No Demotion Change : {a}")
|
||||
ChangeResult::NoChange(rsltstr) => {
|
||||
format!("uuh No Demotion Change {} : {}",
|
||||
targetusr.unwrap(),
|
||||
rsltstr
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -542,6 +608,8 @@ async fn getroles(params : ExecBodyParams) {
|
|||
|
||||
*/
|
||||
|
||||
let sendername = params.msg.clone().sender.name;
|
||||
|
||||
|
||||
let mut argv = params.msg.message_text.split(' ');
|
||||
|
||||
|
@ -549,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;
|
||||
|
@ -637,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(
|
||||
|
@ -646,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(
|
||||
|
|
Loading…
Reference in a new issue