promote/demote checks invalid arg flag
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful

This commit is contained in:
ModulatingForce 2024-03-25 20:24:05 -04:00
parent df6fe8ccb7
commit e66985814a

View file

@ -732,6 +732,13 @@ async fn cmd_promote(params : ExecBodyParams) {
*/
let botlock = params.bot.read().await;
let id = botlock.get_identity();
let idlock = id.read().await;
// [x] 1. Get trgusr (regardless of -admin flag)
// let targetusr = if arg1 == Some("-admin") { arg2 } else { arg1 };
@ -742,16 +749,22 @@ async fn cmd_promote(params : ExecBodyParams) {
|| arg1 == Some("-m")
|| arg1 == Some("-mod")
{ arg2 }
else if let Some(a) = arg1 {
if a.starts_with("-") {
botlock.botmgrs.chat.send_botmsg(
super::chat::BotMsgType::Notif(
"Invalid Argument Flag".to_string()
),
params.clone(),
).await;
return
} else { arg1 }
}
else { arg1 };
// [x] 2. promote trguser
// [x] Get a required lock first
let botlock = params.bot.read().await;
let id = botlock.get_identity();
let idlock = id.read().await;
let rslt = match targetusr {
Some(targetusr) => {
botlog::debug(
@ -934,6 +947,15 @@ async fn cmd_demote(params : ExecBodyParams) {
*/
// [x] Get a required lock first
let botlock = params.bot.read().await;
let id = botlock.get_identity();
let idlock = id.read().await;
let sendername = params.msg.clone().sender.name;
let mut sender_badge_mut: Option<ChatBadge> = None;
@ -961,6 +983,17 @@ async fn cmd_demote(params : ExecBodyParams) {
|| arg1 == Some("-m")
|| arg1 == Some("-mod")
{ arg2 }
else if let Some(a) = arg1 {
if a.starts_with("-") {
botlock.botmgrs.chat.send_botmsg(
super::chat::BotMsgType::Notif(
"Invalid Argument Flag".to_string()
),
params.clone(),
).await;
return
} else { arg1 }
}
else { arg1 };
// Note : At the moment, no handling of -admin
@ -983,12 +1016,6 @@ async fn cmd_demote(params : ExecBodyParams) {
*/
// [x] Get a required lock first
let botlock = params.bot.read().await;
let id = botlock.get_identity();
let idlock = id.read().await;
let rslt = match targetusr {
Some(targetusr) => {
botlog::debug(