From c5ff366631163fbacdf85823021898c300ba29a1 Mon Sep 17 00:00:00 2001 From: HaruYuumei <luzivotto.erick@gmail.com> Date: Thu, 30 Jan 2025 13:08:33 -0300 Subject: [PATCH 1/2] magic module test --- src/bin/magic.rs | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/bin/magic.rs diff --git a/src/bin/magic.rs b/src/bin/magic.rs new file mode 100644 index 0000000..c49348e --- /dev/null +++ b/src/bin/magic.rs @@ -0,0 +1,80 @@ +use forcebot_rs_v2::Bot; + +#[tokio::main] +pub async fn main() { + + /* 1. Create the bot using env */ + let mut bot = Bot::new(); + + bot.load_module(magic::new()); + + /* 2. Run the bot */ + bot.run().await; + +} + +pub mod magic{ + use std::sync::Arc; + + use forcebot_rs_v2::{asyncfn_box, Badge, Bot, Command, Module}; + use twitch_irc::message::ServerMessage; + + + /// Module with a loaded command + pub fn new() -> Module { + /* 1. Create a new module */ + let mut _magic = Module::new("curse".to_string(),"".to_string()); + let mut magic = Module::new("clean".to_string(),"".to_string()); + + /* 2. Load the cmd into a new module */ + magic.load_command(curse_fn()); + magic.load_command(clean_fn()); + + magic + + } + + pub fn curse_fn() -> Command { + /* 1. Create a new cmd */ + let mut cmd = Command::new("curse".to_string(),"".to_string()); + + /* 2. Define exec callback */ + async fn execbody(bot:Arc<Bot>,message:ServerMessage) -> Result<String,String> { + if let ServerMessage::Privmsg(msg) = message { + let _= bot.client.say_in_reply_to( + &msg, " ⁽⁽(੭ꐦ •̀Д•́ )੭*⁾⁾ ☥C☥U☥R☥S☥E ☥O☥F☥ ☥R☥A☥!!".to_string()).await; + } + Result::Err("Not Valid message type".to_string()) + } + + /* 3. Set Command flags */ + cmd.set_exec_fn(asyncfn_box(execbody)); + cmd.set_admin_only(false); + cmd.set_min_badge(Badge::Moderator); + + cmd + } + + + pub fn clean_fn() -> Command { + /* 1. Create a new cmd */ + let mut cmd = Command::new("clean".to_string(),"".to_string()); + + /* 2. Define exec callback */ + async fn execbody(bot:Arc<Bot>,message:ServerMessage) -> Result<String,String> { + if let ServerMessage::Privmsg(msg) = message { + let _= bot.client.say_in_reply_to( + &msg, "(๑'ᵕ'๑)⸝*。⋆°You are clean now!".to_string()).await; + } + Result::Err("Not Valid message type".to_string()) + } + + /* 3. Set Command flags */ + cmd.set_exec_fn(asyncfn_box(execbody)); + cmd.set_admin_only(false); + cmd.set_min_badge(Badge::Moderator); + + cmd + } + +} \ No newline at end of file From e3bef5af6d3716effc63bb0816c61eceef81ca98 Mon Sep 17 00:00:00 2001 From: HaruYuumei <luzivotto.erick@gmail.com> Date: Thu, 30 Jan 2025 13:10:02 -0300 Subject: [PATCH 2/2] gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index c77774d..3aaeacd 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ # env .env + +#lazygit +lazygit.exe