Merge branch 'master' into haru_test
Some checks failed
ci/woodpecker/pr/cargo-checks Pipeline failed
Some checks failed
ci/woodpecker/pr/cargo-checks Pipeline failed
This commit is contained in:
commit
b949c70fa8
3 changed files with 99 additions and 22 deletions
|
@ -1,5 +1,5 @@
|
||||||
when:
|
when:
|
||||||
branch: main
|
branch: master
|
||||||
event: [push, pull_request]
|
event: [push, pull_request]
|
||||||
path:
|
path:
|
||||||
include:
|
include:
|
||||||
|
|
|
@ -37,7 +37,7 @@ steps:
|
||||||
owner: ${CI_REPO_OWNER}
|
owner: ${CI_REPO_OWNER}
|
||||||
repo: ${CI_REPO_NAME}
|
repo: ${CI_REPO_NAME}
|
||||||
branch: flake-lock-update
|
branch: flake-lock-update
|
||||||
base_branch: main
|
base_branch: master
|
||||||
pr_title: "flake.lock: update"
|
pr_title: "flake.lock: update"
|
||||||
pr_body: PR automatically created by Woodpecker CI
|
pr_body: PR automatically created by Woodpecker CI
|
||||||
close_pr_if_empty: true
|
close_pr_if_empty: true
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -70,7 +71,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![
|
||||||
|
@ -175,7 +179,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();
|
||||||
|
|
||||||
|
@ -213,7 +217,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")
|
||||||
|
@ -233,6 +237,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(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] 2. promote trguser
|
||||||
|
|
||||||
// [x] Get a required lock first
|
// [x] Get a required lock first
|
||||||
|
@ -283,14 +331,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(),
|
||||||
|
rsltstr
|
||||||
|
)
|
||||||
}
|
}
|
||||||
ChangeResult::Failed(a) => {
|
ChangeResult::Failed(rsltstr) => {
|
||||||
format!("PoroSad failed to promote : {a}")
|
format!("PoroSad failed to promote {} : {}",
|
||||||
|
targetusr.unwrap(),
|
||||||
|
rsltstr
|
||||||
|
)
|
||||||
}
|
}
|
||||||
ChangeResult::NoChange(a) => {
|
ChangeResult::NoChange(rsltstr) => {
|
||||||
format!("uuh No Promotion Change : {a}")
|
format!("uuh No Promotion Change {} : {}",
|
||||||
|
targetusr.unwrap(),
|
||||||
|
rsltstr
|
||||||
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -510,14 +567,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(),
|
||||||
|
rsltstr
|
||||||
|
)
|
||||||
}
|
}
|
||||||
ChangeResult::Failed(a) => {
|
ChangeResult::Failed(rsltstr) => {
|
||||||
format!("PoroSad failed to demote : {a}")
|
format!("PoroSad failed to demote {} : {}",
|
||||||
|
targetusr.unwrap(),
|
||||||
|
rsltstr
|
||||||
|
)
|
||||||
}
|
}
|
||||||
ChangeResult::NoChange(a) => {
|
ChangeResult::NoChange(rsltstr) => {
|
||||||
format!("uuh No Demotion Change : {a}")
|
format!("uuh No Demotion Change {} : {}",
|
||||||
|
targetusr.unwrap(),
|
||||||
|
rsltstr
|
||||||
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -553,6 +619,8 @@ async fn getroles(params : ExecBodyParams) {
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
let sendername = params.msg.clone().sender.name;
|
||||||
|
|
||||||
|
|
||||||
let mut argv = params.msg.message_text.split(' ');
|
let mut argv = params.msg.message_text.split(' ');
|
||||||
|
|
||||||
|
@ -560,11 +628,17 @@ async fn getroles(params : ExecBodyParams) {
|
||||||
|
|
||||||
let arg1 = argv.next();
|
let arg1 = argv.next();
|
||||||
|
|
||||||
let targetuser = match arg1 {
|
let mut targetuser = match arg1 {
|
||||||
None => return, // exit if no arguments
|
// None => return, // exit if no arguments
|
||||||
|
None => sendername.as_str(), // self-invoke in this case
|
||||||
Some(arg) => arg,
|
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 arg2 = argv.next();
|
||||||
|
|
||||||
let targetchnl = arg2;
|
let targetchnl = arg2;
|
||||||
|
@ -648,7 +722,9 @@ async fn getroles(params : ExecBodyParams) {
|
||||||
params.msg.channel_login.to_lowercase(),
|
params.msg.channel_login.to_lowercase(),
|
||||||
))) || sproles.contains(&UserRole::BotAdmin)
|
))) || 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
|
outmsg
|
||||||
} else if sproles.contains(&UserRole::Mod(Channel(
|
} else if sproles.contains(&UserRole::Mod(Channel(
|
||||||
|
@ -657,9 +733,10 @@ async fn getroles(params : ExecBodyParams) {
|
||||||
params.msg.channel_login.to_lowercase(),
|
params.msg.channel_login.to_lowercase(),
|
||||||
))) || sproles.contains(&UserRole::BotAdmin)
|
))) || 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 {
|
} else {
|
||||||
"Target chatter has no special roles LULE ".to_string()
|
format!("{} has no special roles LULE ",targetuser)
|
||||||
};
|
};
|
||||||
|
|
||||||
botlog::debug(
|
botlog::debug(
|
||||||
|
|
Loading…
Reference in a new issue