custom module working
This commit is contained in:
parent
f8de595290
commit
fda7afb191
1 changed files with 31 additions and 32 deletions
|
@ -1,23 +1,23 @@
|
||||||
use crate::core::botmodules::{ BotActionTrait, BotCommand, BotModule, Listener, ModulesManager};
|
|
||||||
use crate::core::identity::UserRole::*;
|
|
||||||
use crate::core::bot_actions::*;
|
use crate::core::bot_actions::*;
|
||||||
use crate::core::botlog;
|
use crate::core::botlog;
|
||||||
use std::sync::Arc;
|
use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, Listener, ModulesManager};
|
||||||
|
use crate::core::identity::UserRole::*;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
use std::sync::Arc;
|
||||||
use tokio::time::{sleep, Duration};
|
use tokio::time::{sleep, Duration};
|
||||||
|
|
||||||
//use rand::Rng;
|
//use rand::Rng;
|
||||||
|
|
||||||
async fn tsg(params: ExecBodyParams){
|
async fn tsg(params: ExecBodyParams) {
|
||||||
|
if params.msg.message_text == String::from("anime")
|
||||||
if params.msg.sender.name.to_lowercase() == "haruyuumei".to_lowercase()
|
|| params.msg.message_text == String::from("Anime")
|
||||||
|| params.msg.sender.name.to_lowercase() == "ModulatingForce".to_lowercase()
|
|
||||||
{
|
{
|
||||||
let phrases: [String;5] = [
|
let phrases: [String; 5] = [
|
||||||
"Aware Weebs...".to_string(),
|
"Aware oh no! Weebs...".to_string(),
|
||||||
"AYAYA I love anime Girls!!".to_string(),
|
"AYAYA I love anime Girls!!".to_string(),
|
||||||
"I love 2d Girls ILOST".to_string(),
|
"I love 2d Girls ILOST ".to_string(),
|
||||||
"UOOHHHHH!!! Anime Girlssss".to_string(),
|
"UOOHHHHH!!! Anime Girlssss".to_string(),
|
||||||
"Anime girls u say? peepoShy".to_string(),
|
"Anime girls u say? peepoShy ".to_string(),
|
||||||
];
|
];
|
||||||
|
|
||||||
let r = rand::thread_rng().gen_range(0..=4);
|
let r = rand::thread_rng().gen_range(0..=4);
|
||||||
|
@ -33,40 +33,39 @@ async fn tsg(params: ExecBodyParams){
|
||||||
|
|
||||||
// uses chat.say_in_reply_to() for the bot controls for messages
|
// uses chat.say_in_reply_to() for the bot controls for messages
|
||||||
botlock
|
botlock
|
||||||
.botmgrs
|
.botmgrs
|
||||||
.chat
|
.chat
|
||||||
.say_in_reply_to(
|
.say_in_reply_to(¶ms.msg, a, params.clone())
|
||||||
¶ms.msg,
|
.await;
|
||||||
a,
|
|
||||||
params.clone()
|
|
||||||
).await;
|
|
||||||
sleep(Duration::from_secs_f64(0.5)).await;
|
sleep(Duration::from_secs_f64(0.5)).await;
|
||||||
}
|
}else {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn init(mgr:&Arc<ModulesManager>){
|
pub async fn init(mgr: &Arc<ModulesManager>) {
|
||||||
|
BotCommand {
|
||||||
BotCommand{
|
module: BotModule(String::from("thisguy")),
|
||||||
module:BotModule(String::from("thisguy")),
|
|
||||||
command: String::from("anime"),
|
command: String::from("anime"),
|
||||||
alias: vec![String::from("Anime")],
|
alias: vec![String::from("Anime")],
|
||||||
exec_body: actions_util::asyncbox(tesst),
|
exec_body: actions_util::asyncbox(tesst),
|
||||||
help: String::from("test"),
|
help: String::from("test"),
|
||||||
required_roles: vec![
|
required_roles: vec![BotAdmin],
|
||||||
BotAdmin,
|
}
|
||||||
],
|
.add_to_modmgr(Arc::clone(&mgr))
|
||||||
}.add_to_modmgr(Arc::clone(&mgr)).await;
|
.await;
|
||||||
|
|
||||||
Listener {
|
Listener {
|
||||||
module: BotModule(String::from("thisguy")),
|
module: BotModule(String::from("thisguy")),
|
||||||
name: String::from("This Guy Listener"),
|
name: String::from("This Guy Listener"),
|
||||||
exec_body: actions_util::asyncbox(tsg),
|
exec_body: actions_util::asyncbox(tsg),
|
||||||
help: String::from(""),
|
help: String::from(""),
|
||||||
}.add_to_modmgr(Arc::clone(&mgr)).await;
|
}
|
||||||
|
.add_to_modmgr(Arc::clone(&mgr))
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn tesst(params : ExecBodyParams) {
|
async fn tesst(params: ExecBodyParams) {
|
||||||
println!("tesst triggered!"); // NOTE : This test function intends to print (e.g., to stdout) at fn call
|
println!("tesst triggered!"); // NOTE : This test function intends to print (e.g., to stdout) at fn call
|
||||||
botlog::debug(
|
botlog::debug(
|
||||||
"tesst triggered!",
|
"tesst triggered!",
|
||||||
|
|
Loading…
Reference in a new issue