diff --git a/readme.md b/readme.md index 6671b73..bbd2096 100644 --- a/readme.md +++ b/readme.md @@ -27,13 +27,21 @@ cargo run # Binary Crates -## Simple Bot +## Simple Empty Bot Run a simple bot that logs into chat based on env ``` cargo run --bin simple_bot ``` +## Fun Bot +Run a forcebot with fun catered customizations + +``` +cargo run --bin fun_bot +``` + + ## Simple Bot with Example Custom Listener Run a bot with some custom listeners diff --git a/src/bin/fun_bot.rs b/src/bin/fun_bot.rs new file mode 100644 index 0000000..8469bee --- /dev/null +++ b/src/bin/fun_bot.rs @@ -0,0 +1,49 @@ +//! Fun forcebot with catered customizations #todo +//! +//! Be sure the followig is defined in `.env` +//! - login_name +//! - access_token +//! - bot_channels +//! - prefix +//! - bot_admins +//! +//! Bot access tokens be generated here - +//! - Get a Bot Chat Token here - <https://twitchtokengenerator.com> +//! - More Info - <https://dev.twitch.tv/docs/authentication> + +use std::sync::Arc; + +use forcebot_rs_v2::Bot; +use forcebot_rs_v2::asyncfn_box; +use forcebot_rs_v2::Command; +use twitch_irc::message::ServerMessage; + + +#[tokio::main] +pub async fn main() { + + /* Create the bot using env */ + let mut bot = Bot::new(); + + /* 1. Create a new blank cmd */ + let mut cmd = Command::new("remind besty".to_string(),"annytfYandere ".to_string()); + + /* 2. Define an async fn callback execution */ + async fn execbody(bot:Arc<Bot>,message:ServerMessage) -> Result<String,String> { + if let ServerMessage::Privmsg(msg) = message { + let _n= bot.client.say_in_reply_to( + &msg, "annytfYandere he's mine".to_string()).await; + } + Result::Err("Not Valid message type".to_string()) + } + + /* 3. Set and Store the execution body using `async_box()` */ + cmd.set_exec_fn(asyncfn_box(execbody)); + + /* 4. Load the cmd into the bot */ + bot.load_command(cmd); + + /* Run the bot */ + bot.run().await; + +}