cargo-fmt
This commit is contained in:
parent
8eaa56dd0c
commit
cd69a35ec1
22 changed files with 1140 additions and 1075 deletions
simple_command_bot/src
|
@ -1,43 +1,46 @@
|
|||
//! Bot with custom example commands that responds to caller if allowed
|
||||
//!
|
||||
//!
|
||||
//! Commands that are passed a blank prefix will use the bot prefix
|
||||
//!
|
||||
//! 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>
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use forcebot_core::execution_async;
|
||||
use forcebot_core::Badge;
|
||||
use forcebot_core::Bot;
|
||||
use forcebot_core::execution_async;
|
||||
use forcebot_core::Command;
|
||||
use twitch_irc::message::ServerMessage;
|
||||
|
||||
|
||||
#[tokio::main]
|
||||
pub async fn main() {
|
||||
|
||||
/* Create the bot using env */
|
||||
let bot = Bot::new().await;
|
||||
|
||||
/* 1. Create a new blank 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 an async fn callback execution */
|
||||
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, String::from("test success")).await;
|
||||
return Result::Ok("Success".to_string()) ;
|
||||
let _ = bot
|
||||
.chat
|
||||
.lock()
|
||||
.await
|
||||
.say_in_reply_to(&msg, String::from("test success"))
|
||||
.await;
|
||||
return Result::Ok("Success".to_string());
|
||||
}
|
||||
Result::Err("Not Valid message type".to_string())
|
||||
Result::Err("Not Valid message type".to_string())
|
||||
}
|
||||
|
||||
/* 3. Set and Store the execution body using `execution_async()` */
|
||||
|
@ -54,5 +57,4 @@ pub async fn main() {
|
|||
|
||||
/* Run the bot */
|
||||
bot.run().await;
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue