Compare commits

...
Sign in to create a new pull request.

2 commits

Author SHA1 Message Date
e3bef5af6d gitignore 2025-01-30 13:10:02 -03:00
c5ff366631 magic module test 2025-01-30 13:08:33 -03:00
2 changed files with 83 additions and 0 deletions

3
.gitignore vendored
View file

@ -3,3 +3,6 @@
# env
.env
#lazygit
lazygit.exe

80
src/bin/magic.rs Normal file
View file

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