Compare commits
29 commits
Refactor-c
...
master
Author | SHA1 | Date | |
---|---|---|---|
e1021c269d | |||
e41f7b0524 | |||
55aeaa7fc1 | |||
93768de4dc | |||
b8c33d2339 | |||
7f49693a94 | |||
b949c70fa8 | |||
018e8306e4 | |||
764a912122 | |||
f86f48178d | |||
35247ac5ba | |||
4b849cfed6 | |||
dfb37717b3 | |||
16c6b0eebb | |||
74d938751f | |||
2bf0e0e738 | |||
dd2670c766 | |||
b43d6f8159 | |||
7e04699b67 | |||
d972eb7726 | |||
72d4cf6d70 | |||
a6ae5b3c47 | |||
fda7afb191 | |||
3ec51d66e5 | |||
f8de595290 | |||
95a9962721 | |||
f7881fa07d | |||
5fb373c522 | |||
fb1617d6d9 |
9 changed files with 181 additions and 34 deletions
|
@ -1,5 +1,5 @@
|
|||
when:
|
||||
branch: main
|
||||
branch: master
|
||||
event: [push, pull_request]
|
||||
path:
|
||||
include:
|
||||
|
|
|
@ -37,7 +37,7 @@ steps:
|
|||
owner: ${CI_REPO_OWNER}
|
||||
repo: ${CI_REPO_NAME}
|
||||
branch: flake-lock-update
|
||||
base_branch: main
|
||||
base_branch: master
|
||||
pr_title: "flake.lock: update"
|
||||
pr_body: PR automatically created by Woodpecker CI
|
||||
close_pr_if_empty: true
|
||||
|
|
|
@ -9,9 +9,10 @@ test ModulatingForceBot
|
|||
|
||||
```
|
||||
login_name = <botname>
|
||||
access_token = <oath token>
|
||||
access_token = <oauth token>
|
||||
bot_channels = <chnl1>,<chnl2>
|
||||
prefix = <prefix>
|
||||
bot_admins = <admins>
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -109,11 +109,11 @@
|
|||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1712543224,
|
||||
"narHash": "sha256-9RSfZL1TKYdGxZwgDxwtBtsKMGR4Zgn+DAnF9s71/lU=",
|
||||
"lastModified": 1712573573,
|
||||
"narHash": "sha256-xxon7WwNm4/EadMKg1eF40/5s0O78nXUy2ILZt6vT7E=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "b0dab7cc34ef4d8a1b2de36178da801090bcb271",
|
||||
"rev": "0d28066770464d19d637f6e8e42e8688420b6ac6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -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;
|
||||
|
@ -17,12 +18,20 @@ use crate::core::bot_actions::ExecBodyParams;
|
|||
use crate::core::botinstance::{Channel,ChangeResult};
|
||||
use crate::core::botlog;
|
||||
use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, ModulesManager};
|
||||
|
||||
use dotenv::dotenv;
|
||||
use std::env;
|
||||
|
||||
fn adminvector() -> Vec<String> {
|
||||
vec![String::from("ModulatingForce")]
|
||||
dotenv().ok();
|
||||
let mut admins = Vec::new();
|
||||
|
||||
if let Ok(value) = env::var("bot_admins") {
|
||||
for admin in value.split(',') {
|
||||
admins.push(String::from(admin))
|
||||
}
|
||||
}
|
||||
|
||||
admins
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,7 +68,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 +176,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 +214,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 +234,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 +328,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 +564,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 +616,8 @@ async fn getroles(params : ExecBodyParams) {
|
|||
|
||||
*/
|
||||
|
||||
let sendername = params.msg.clone().sender.name;
|
||||
|
||||
|
||||
let mut argv = params.msg.message_text.split(' ');
|
||||
|
||||
|
@ -549,11 +625,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 +719,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 +730,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(
|
||||
|
|
|
@ -13,6 +13,7 @@ pub use crate::core::botmodules::ModulesManager;
|
|||
|
||||
// mod experiments;
|
||||
mod experimental;
|
||||
mod thisguy;
|
||||
|
||||
// [ ] init() function that accepts bot instance - this is passed to init() on submodules
|
||||
|
||||
|
@ -21,5 +22,6 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
|||
// this is achieved by calling submodules that also have fn init() defined
|
||||
|
||||
// experiments::init(mgr).await
|
||||
experimental::init(mgr).await;
|
||||
experimental::init(mgr.clone()).await;
|
||||
thisguy::init(&mgr).await;
|
||||
}
|
||||
|
|
|
@ -163,6 +163,7 @@ async fn good_girl(params : ExecBodyParams) {
|
|||
|
||||
if params.msg.sender.name.to_lowercase() == "ModulatingForce".to_lowercase()
|
||||
|| params.msg.sender.name.to_lowercase() == "mzNToRi".to_lowercase()
|
||||
|| params.msg.sender.name.to_lowercase() == "haruyuumei".to_lowercase()
|
||||
{
|
||||
botlog::debug(
|
||||
"Good Girl Detected > Pausechamp",
|
||||
|
@ -180,8 +181,6 @@ async fn good_girl(params : ExecBodyParams) {
|
|||
);
|
||||
|
||||
let bot = Arc::clone(¶ms.bot);
|
||||
|
||||
|
||||
let botlock = bot.read().await;
|
||||
|
||||
// uses chat.say_in_reply_to() for the bot controls for messages
|
||||
|
@ -194,8 +193,6 @@ async fn good_girl(params : ExecBodyParams) {
|
|||
String::from("GoodGirl xdd "),
|
||||
params.clone()
|
||||
).await;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
62
src/custom/thisguy.rs
Normal file
62
src/custom/thisguy.rs
Normal file
|
@ -0,0 +1,62 @@
|
|||
use crate::core::bot_actions::*;
|
||||
use crate::core::botinstance::Channel;
|
||||
use crate::core::botlog;
|
||||
use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, ModulesManager};
|
||||
use crate::core::identity::UserRole::*;
|
||||
use rand::Rng;
|
||||
use twitch_irc::message::ReplyToMessage;
|
||||
use std::sync::Arc;
|
||||
use tokio::time::{sleep, Duration};
|
||||
const OF_CMD_CHANNEL:Channel = Channel(String::new());
|
||||
|
||||
async fn tsg(params: ExecBodyParams) {
|
||||
|
||||
let phrases: [String; 6] = [
|
||||
"Clueless ".to_string(),
|
||||
"ICANT This guy....".to_string(),
|
||||
"He is right tho".to_string(),
|
||||
"KEKW true!".to_string(),
|
||||
"OMEGALUL wth man...".to_string(),
|
||||
"PepeLaugh El no sabe".to_string(),
|
||||
];
|
||||
|
||||
let r = rand::thread_rng().gen_range(0..=4);
|
||||
let a = phrases[r].clone();
|
||||
|
||||
botlog::debug(
|
||||
"This guy works!",
|
||||
Some("modules > thisguy()".to_string()),
|
||||
Some(¶ms.msg),
|
||||
);
|
||||
let bot = Arc::clone(¶ms.bot);
|
||||
let botlock = bot.read().await;
|
||||
|
||||
// uses chat.say_in_reply_to() for the bot controls for messages
|
||||
botlock
|
||||
.botmgrs
|
||||
.chat
|
||||
.say_in_reply(
|
||||
Channel(params.clone().msg.channel_login().to_string()),
|
||||
a,
|
||||
params.clone()
|
||||
)
|
||||
.await;
|
||||
sleep(Duration::from_secs_f64(0.5)).await;
|
||||
}
|
||||
|
||||
pub async fn init(mgr: &Arc<ModulesManager>) {
|
||||
BotCommand {
|
||||
module: BotModule(String::from("thisguy")),
|
||||
command: String::from("thisguy"),
|
||||
alias: vec![String::from("Thisguy")],
|
||||
exec_body: actions_util::asyncbox(tsg),
|
||||
help: String::from("test"),
|
||||
required_roles: vec![
|
||||
BotAdmin,
|
||||
Mod(OF_CMD_CHANNEL),
|
||||
Broadcaster
|
||||
],
|
||||
}
|
||||
.add_to_modmgr(Arc::clone(mgr))
|
||||
.await;
|
||||
}
|
Loading…
Reference in a new issue