Compare commits

..

36 commits

Author SHA1 Message Date
e1021c269d Merge pull request 'Custom this BotCommand' (#48) from say-this-guy into master
All checks were successful
ci/woodpecker/push/cargo-checks Pipeline was successful
Reviewed-on: #48
2024-04-09 15:49:58 -04:00
e41f7b0524 warning changed
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
2024-04-09 16:44:58 -03:00
55aeaa7fc1 changed reply message on thisguy
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
2024-04-09 16:22:11 -03:00
93768de4dc Merge branch 'master' into say-this-guy
Some checks failed
ci/woodpecker/pr/cargo-checks Pipeline failed
2024-04-09 14:45:27 -04:00
b8c33d2339 Merge pull request 'Bot admins in env file' (#22) from haru_test into master
All checks were successful
ci/woodpecker/push/cargo-checks Pipeline was successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
Reviewed-on: #22
2024-04-09 13:48:55 -04:00
7f49693a94 clippy
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
2024-04-09 13:47:06 -04:00
b949c70fa8 Merge branch 'master' into haru_test
Some checks failed
ci/woodpecker/pr/cargo-checks Pipeline failed
2024-04-09 13:39:57 -04:00
018e8306e4 Merge pull request 'Cucked alt for promote' (#75) from cucked into master
All checks were successful
ci/woodpecker/push/cargo-checks Pipeline was successful
Reviewed-on: #75
2024-04-09 13:39:35 -04:00
764a912122 Merge branch 'master' into cucked
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
2024-04-09 13:37:20 -04:00
f86f48178d
ci: fix branch naming 2024-04-09 13:27:25 -04:00
35247ac5ba Merge branch 'master' into haru_test 2024-04-09 12:56:21 -04:00
4b849cfed6 comments cleanup 2024-04-09 12:51:53 -04:00
dfb37717b3 clippy 2024-04-09 12:36:46 -04:00
16c6b0eebb self-invoking identity methods 2024-04-09 12:32:02 -04:00
74d938751f cucked promote alt 2024-04-09 10:00:01 -04:00
2bf0e0e738 Merge pull request 'flake.lock: update' (#74) from flake-lock-update into master
Reviewed-on: #74
2024-04-09 08:47:36 -04:00
dd2670c766 flake.lock: update 2024-04-09 01:02:55 +00:00
200d2a86d3
nix: add pre-commit-hooks
Some checks failed
ci/woodpecker/pr/cargo-checks Pipeline was successful
ci/woodpecker/cron/flake-update Pipeline failed
2024-04-08 18:45:30 -04:00
926f213923 Merge pull request 'nix-rewrite' (#73) from nix-rewrite into main
good enough for now
2024-04-08 18:05:05 -04:00
604c26647e
nix: read version from cargo.toml
fix spelling error
2024-04-08 18:00:13 -04:00
087e76388d
nix: init rewrite
first pass of my nix rewrite

nix: rename module

nix: update module

nix: update module

nix: update module

nix: refactor

nix: remove package option

nix: fix serviceConfig

nix: add package back to module

nix: update module

nix: update module

nix: update module

nix: update module

remove default.nix
2024-04-08 17:46:08 -04:00
91d62bf0ff Merge pull request 'flake.lock: update' (#72) from flake-lock-update into main
Reviewed-on: #72
2024-04-08 10:00:55 -04:00
78634f3ffe flake.lock: update 2024-04-08 13:59:49 +00:00
e67c8582c1 Merge pull request 'Retrieve Reply information from ExecBodyParams' (#52) from retrieve-reply-details into main
Some checks failed
ci/woodpecker/push/cargo-checks Pipeline was successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
ci/woodpecker/cron/flake-update Pipeline failed
Reviewed-on: #52
2024-04-03 19:51:04 -04:00
b43d6f8159 Rewriten the code
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
working with command instead listener
2024-04-03 10:26:14 -03:00
7e04699b67 making changes 2024-04-03 10:25:24 -03:00
d972eb7726 Thisguy working partially
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
not fully implemented reply to the reply
2024-04-02 20:11:01 -03:00
72d4cf6d70 Small changes on thisguy.rs 2024-03-31 14:37:50 -03:00
a6ae5b3c47 Merge branch 'say-this-guy' of ssh://git.flake.sh:2222/modulatingforce/forcebot_rs into say-this-guy
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
2024-03-28 19:35:25 -03:00
fda7afb191 custom module working 2024-03-28 19:33:06 -03:00
3ec51d66e5 Merge branch 'main' into say-this-guy
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
2024-03-28 17:55:00 -04:00
f8de595290 custom module update
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
2024-03-28 18:50:28 -03:00
95a9962721 new module test
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
trying to add a new module
2024-03-28 15:38:49 -03:00
f7881fa07d adj adminvector()
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
2024-03-17 19:29:22 -04:00
5fb373c522 bot admins change
Some checks failed
ci/woodpecker/pr/cargo-checks Pipeline failed
2024-03-17 19:12:33 -03:00
fb1617d6d9 minor spelling mistake 2024-03-17 18:40:12 -03:00
13 changed files with 444 additions and 76 deletions

6
.gitignore vendored
View file

@ -23,3 +23,9 @@ target/
# debug # debug
.vscode/ .vscode/
# nix
result/
# pre-commit
/.pre-commit-config.yaml

View file

@ -1,5 +1,5 @@
when: when:
branch: main branch: master
event: [push, pull_request] event: [push, pull_request]
path: path:
include: include:

View file

@ -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

View file

@ -9,9 +9,10 @@ test ModulatingForceBot
``` ```
login_name = <botname> login_name = <botname>
access_token = <oath token> access_token = <oauth token>
bot_channels = <chnl1>,<chnl2> bot_channels = <chnl1>,<chnl2>
prefix = <prefix> prefix = <prefix>
bot_admins = <admins>
``` ```

View file

@ -6,11 +6,11 @@
"rust-analyzer-src": "rust-analyzer-src" "rust-analyzer-src": "rust-analyzer-src"
}, },
"locked": { "locked": {
"lastModified": 1706768574, "lastModified": 1711952616,
"narHash": "sha256-4o6TMpzBHO659EiJTzd/EGQGUDdbgwKwhqf3u6b23U8=", "narHash": "sha256-WJvDdOph001fA1Ap3AyaQtz/afJAe7meSG5uJAdSE+A=",
"owner": "nix-community", "owner": "nix-community",
"repo": "fenix", "repo": "fenix",
"rev": "668102037129923cd0fc239d864fce71eabdc6a3", "rev": "209048d7c545905c470f6f8c05c5061f391031a8",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -20,13 +20,68 @@
"type": "github" "type": "github"
} }
}, },
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1706550542, "lastModified": 1711703276,
"narHash": "sha256-UcsnCG6wx++23yeER4Hg18CXWbgNpqNXcHIo5/1Y+hc=", "narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "97b17f32362e475016f942bbdfda4a4a72a8a652", "rev": "d8fe5e6c92d0d190646fb9f1056741a229980089",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -36,36 +91,92 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-stable": {
"locked": {
"lastModified": 1710695816,
"narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "614b4613980a522ba49f0d194531beddbb7220d3",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1708296515, "lastModified": 1712573573,
"narHash": "sha256-FyF489fYNAUy7b6dkYV6rGPyzp+4tThhr80KNAaF/yY=", "narHash": "sha256-xxon7WwNm4/EadMKg1eF40/5s0O78nXUy2ILZt6vT7E=",
"owner": "nixos", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "b98a4e1746acceb92c509bc496ef3d0e5ad8d4aa", "rev": "0d28066770464d19d637f6e8e42e8688420b6ac6",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "owner": "NixOS",
"ref": "nixos-unstable", "ref": "nixpkgs-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
}, },
"nixpkgs_3": {
"locked": {
"lastModified": 1710765496,
"narHash": "sha256-p7ryWEeQfMwTB6E0wIUd5V2cFTgq+DRRBz2hYGnJZyA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e367f7a1fb93137af22a3908f00b9a35e2d286a7",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"gitignore": "gitignore",
"nixpkgs": "nixpkgs_3",
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1712579741,
"narHash": "sha256-igpsH+pa6yFwYOdah3cFciCk8gw+ytniG9quf5f/q84=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "70f504012f0a132ac33e56988e1028d88a48855c",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"fenix": "fenix", "fenix": "fenix",
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2",
"pre-commit-hooks": "pre-commit-hooks",
"systems": "systems_2"
} }
}, },
"rust-analyzer-src": { "rust-analyzer-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1706735270, "lastModified": 1711885694,
"narHash": "sha256-IJk+UitcJsxzMQWm9pa1ZbJBriQ4ginXOlPyVq+Cu40=", "narHash": "sha256-dyezzeSbWMpflma+E9USmvSxuLgGcNGcGw3cOnX36ko=",
"owner": "rust-lang", "owner": "rust-lang",
"repo": "rust-analyzer", "repo": "rust-analyzer",
"rev": "42cb1a2bd79af321b0cc503d2960b73f34e2f92b", "rev": "e4a405f877efd820bef9c0e77a02494e47c17512",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -74,6 +185,36 @@
"repo": "rust-analyzer", "repo": "rust-analyzer",
"type": "github" "type": "github"
} }
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"owner": "nix-systems",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-linux",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -1,26 +1,65 @@
{ {
description = "forcebot_rs flake"; description = "A basic flake";
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; systems.url = "github:nix-systems/default-linux";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
fenix.url = "github:nix-community/fenix/monthly"; fenix.url = "github:nix-community/fenix/monthly";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
}; };
outputs = { outputs = {
self,
systems,
nixpkgs, nixpkgs,
fenix, fenix,
... pre-commit-hooks,
} @ inputs: let }: let
system = "x86_64-linux"; eachSystem = nixpkgs.lib.genAttrs (import systems);
pkgsFor = eachSystem (system:
import nixpkgs {
localSystem.system = system;
overlays = [fenix.overlays.default]; overlays = [fenix.overlays.default];
pkgs = import nixpkgs { });
inherit system overlays;
};
in { in {
devShells.${system}.default = pkgs.mkShell { packages = eachSystem (system: let
name = "forcebot_rs-devenv"; pkgs = nixpkgs.legacyPackages.${system};
nativeBuildInputs = [pkgs.pkg-config]; inherit ((builtins.fromTOML (builtins.readFile ./Cargo.toml)).package) version;
buildInputs = with pkgs; [openssl libiconv]; in {
packages = with pkgs; [ default = pkgsFor.${system}.rustPlatform.buildRustPackage {
pname = "forcebot_rs";
version = "${version}";
src = self;
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = with pkgs; [pkg-config];
buildInputs = with pkgs; [openssl];
doCheck = false;
};
});
checks = eachSystem (system: {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
# rust
rustfmt.enable = true;
clippy.enable = true;
# nix
statix.enable = true;
alejandra.enable = true;
deadnix.enable = true;
};
};
});
devShells = eachSystem (system: {
default = pkgsFor.${system}.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
packages = with pkgsFor.${system}; [
nil nil
alejandra alejandra
rust-analyzer-nightly rust-analyzer-nightly
@ -35,5 +74,7 @@
RUST_BACKTRACE = 1; RUST_BACKTRACE = 1;
RUST_SRC_PATH = "${fenix.packages.${system}.complete.rust-src}/lib/rustlib/src/rust/library"; RUST_SRC_PATH = "${fenix.packages.${system}.complete.rust-src}/lib/rustlib/src/rust/library";
}; };
});
nixosModules.default = import ./nix/module.nix {inherit self;};
}; };
} }

30
nix/module.nix Normal file
View file

@ -0,0 +1,30 @@
{self}: {
pkgs,
config,
lib,
...
}: let
inherit (lib) types;
inherit (lib.modules) mkIf;
inherit (lib.options) mkOption mkEnableOption;
inherit (pkgs.stdenv.hostPlatform) system;
cfg = config.services.forcebot_rs;
in {
options.services.forcebot_rs = {
enable = mkEnableOption ''
Enable forcebot
'';
package = mkOption {
type = types.package;
inherit (self.packages.${system}) default;
};
};
config = mkIf cfg.enable {
systemd.services.forcebot_rs = {
wantedBy = ["multi-user.target"];
serviceConfig.ExecStart = "${cfg.package}/bin/forcebot_rs";
};
};
}

View file

@ -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;
@ -17,12 +18,20 @@ use crate::core::bot_actions::ExecBodyParams;
use crate::core::botinstance::{Channel,ChangeResult}; use crate::core::botinstance::{Channel,ChangeResult};
use crate::core::botlog; use crate::core::botlog;
use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, ModulesManager}; use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, ModulesManager};
use dotenv::dotenv; use dotenv::dotenv;
use std::env; use std::env;
fn adminvector() -> Vec<String> { 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 { 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![
@ -164,7 +176,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();
@ -202,7 +214,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")
@ -222,6 +234,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
@ -272,14 +328,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
)
} }
}; };
@ -499,14 +564,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
)
} }
}; };
@ -542,6 +616,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(' ');
@ -549,11 +625,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;
@ -637,7 +719,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(
@ -646,9 +730,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(

View file

@ -13,6 +13,7 @@ pub use crate::core::botmodules::ModulesManager;
// mod experiments; // mod experiments;
mod experimental; mod experimental;
mod thisguy;
// [ ] init() function that accepts bot instance - this is passed to init() on submodules // [ ] 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 // this is achieved by calling submodules that also have fn init() defined
// experiments::init(mgr).await // experiments::init(mgr).await
experimental::init(mgr).await; experimental::init(mgr.clone()).await;
thisguy::init(&mgr).await;
} }

View file

@ -163,6 +163,7 @@ async fn good_girl(params : ExecBodyParams) {
if params.msg.sender.name.to_lowercase() == "ModulatingForce".to_lowercase() 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() == "mzNToRi".to_lowercase()
|| params.msg.sender.name.to_lowercase() == "haruyuumei".to_lowercase()
{ {
botlog::debug( botlog::debug(
"Good Girl Detected > Pausechamp", "Good Girl Detected > Pausechamp",
@ -180,8 +181,6 @@ async fn good_girl(params : ExecBodyParams) {
); );
let bot = Arc::clone(&params.bot); let bot = Arc::clone(&params.bot);
let botlock = bot.read().await; let botlock = bot.read().await;
// uses chat.say_in_reply_to() for the bot controls for messages // 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 "), String::from("GoodGirl xdd "),
params.clone() params.clone()
).await; ).await;
} }
} }
} }

62
src/custom/thisguy.rs Normal file
View 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(&params.msg),
);
let bot = Arc::clone(&params.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;
}

3
statix.toml Normal file
View file

@ -0,0 +1,3 @@
disabled = []
nix_version = '2.4'
ignore = ['.direnv']