cargo-fmt

This commit is contained in:
modulatingforce 2025-02-06 09:41:54 -05:00
commit cd69a35ec1
22 changed files with 1140 additions and 1075 deletions
simple_module_example/src

View file

@ -1,19 +1,19 @@
//! Simple Module with a Command
//!
//! Adding objects through packages provides controls ,
//!
//! Adding objects through packages provides controls ,
//! such as moderators, and brodcasters can disable or enable mods
//!
//! Here, moderators or above can enable or disable the `test`
//!
//! Here, moderators or above can enable or disable the `test`
//! module with the command `<prefix> disable test`
//!
//! Be sure the followig is defined in `.env`
//!
//! Be sure the followig is defined in `.env`
//! - login_name
//! - access_token
//! - bot_channels
//! - prefix
//! - bot_admins
//!
//! Bot access tokens be generated here -
//!
//! Bot access tokens be generated here -
//! - Get a Bot Chat Token here - <https://twitchtokengenerator.com>
//! - More Info - <https://dev.twitch.tv/docs/authentication>
@ -21,7 +21,6 @@ use forcebot_core::Bot;
#[tokio::main]
pub async fn main() {
/* Create the bot using env */
let bot = Bot::new().await;
@ -30,43 +29,41 @@ pub async fn main() {
/* Run the bot */
bot.run().await;
}
pub mod custom_mod {
use std::sync::Arc;
use forcebot_core::{execution_async, Badge, Bot, Command, Module};
use twitch_irc::message::ServerMessage;
/// Module definition with a loaded command
pub fn new() -> Module {
/* 1. Create a new module */
let mut custom_mod = Module::new(
vec!["test".to_string()],
"".to_string());
let mut custom_mod = Module::new(vec!["test".to_string()], "".to_string());
/* 2. Load the cmd into a new module */
custom_mod.load_command(cmd_test());
custom_mod
}
/// Command definition
/// Command definition
pub fn cmd_test() -> Command {
/* 1. Create a new cmd */
let mut cmd = Command::new(vec!["test".to_string()],"".to_string());
let mut cmd = Command::new(vec!["test".to_string()], "".to_string());
/* 2. Define exec callback */
async fn execbody(bot:Arc<Bot>,message:ServerMessage) -> Result<String,String> {
async fn execbody(bot: Arc<Bot>, message: ServerMessage) -> Result<String, String> {
if let ServerMessage::Privmsg(msg) = message {
let _= bot.chat.lock().await.say_in_reply_to(
&msg, "test return".to_string()).await;
let _ = bot
.chat
.lock()
.await
.say_in_reply_to(&msg, "test return".to_string())
.await;
}
Result::Err("Not Valid message type".to_string())
Result::Err("Not Valid message type".to_string())
}
/* 3. Set Command flags */
@ -76,4 +73,4 @@ pub mod custom_mod {
cmd
}
}
}