fun_bot init

This commit is contained in:
modulatingforce 2025-01-28 11:43:57 -05:00
parent db93067903
commit 3e4584c39f
2 changed files with 58 additions and 1 deletions

View file

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

49
src/bin/fun_bot.rs Normal file
View file

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