Custom this BotCommand #48

Merged
modulatingforce merged 12 commits from say-this-guy into master 2024-04-09 15:49:58 -04:00
Showing only changes of commit fda7afb191 - Show all commits

View file

@ -1,25 +1,25 @@
use crate::core::botmodules::{ BotActionTrait, BotCommand, BotModule, Listener, ModulesManager};
use crate::core::identity::UserRole::*;
use crate::core::bot_actions::*;
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 std::sync::Arc;
use tokio::time::{sleep, Duration};
//use rand::Rng;
async fn tsg(params: ExecBodyParams){
if params.msg.sender.name.to_lowercase() == "haruyuumei".to_lowercase()
|| params.msg.sender.name.to_lowercase() == "ModulatingForce".to_lowercase()
async fn tsg(params: ExecBodyParams) {
if params.msg.message_text == String::from("anime")
|| params.msg.message_text == String::from("Anime")
{
let phrases: [String;5] = [
"Aware Weebs...".to_string(),
"AYAYA I love anime Girls!!".to_string(),
"I love 2d Girls ILOST".to_string(),
"UOOHHHHH!!! Anime Girlssss".to_string(),
"Anime girls u say? peepoShy".to_string(),
let phrases: [String; 5] = [
"Aware oh no! Weebs...".to_string(),
"AYAYA I love anime Girls!!".to_string(),
"I love 2d Girls ILOST ".to_string(),
"UOOHHHHH!!! Anime Girlssss".to_string(),
"Anime girls u say? peepoShy ".to_string(),
];
let r = rand::thread_rng().gen_range(0..=4);
let a = phrases[r].clone();
@ -33,40 +33,39 @@ async fn tsg(params: ExecBodyParams){
// uses chat.say_in_reply_to() for the bot controls for messages
botlock
.botmgrs
.chat
.say_in_reply_to(
&params.msg,
a,
params.clone()
).await;
.botmgrs
.chat
modulatingforce marked this conversation as resolved
Review

We're getting an error here in ci/cd

error[E0061]: this method takes 4 arguments but 3 arguments were supplied
   --> src\custom\thisguy.rs:37:10
    |
37  |         .say_in_reply_to(&params.msg, a, params.clone())
    |          ^^^^^^^^^^^^^^^ -----------     -------------- an argument of type `std::string::String` is missing
    |                          |
    |                          expected `Channel`, found `&PrivmsgMessage`
    |
note: method defined here
   --> src\core\chat.rs:415:18
    |
415 |     pub async fn say_in_reply_to(
    |                  ^^^^^^^^^^^^^^^
416 |         &self,
417 |         destination_channel : Channel ,
    |         -----------------------------
418 |         reply_message_id : String ,
    |         -------------------------
419 |         outmsg: String ,
    |         --------------
420 |         params : ExecBodyParams)
    |         -----------------------
help: provide the argument
    |
37  |         .say_in_reply_to(/* core::botinstance::Channel */, a, /* std::string::String */, params.clone())
    |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Recommend this be adjusted to

.say_in_reply_to(&params.msg.channel_login(), &params.msg.message_id(),a, params.clone())
We're getting an error here in ci/cd ``` error[E0061]: this method takes 4 arguments but 3 arguments were supplied --> src\custom\thisguy.rs:37:10 | 37 | .say_in_reply_to(&params.msg, a, params.clone()) | ^^^^^^^^^^^^^^^ ----------- -------------- an argument of type `std::string::String` is missing | | | expected `Channel`, found `&PrivmsgMessage` | note: method defined here --> src\core\chat.rs:415:18 | 415 | pub async fn say_in_reply_to( | ^^^^^^^^^^^^^^^ 416 | &self, 417 | destination_channel : Channel , | ----------------------------- 418 | reply_message_id : String , | ------------------------- 419 | outmsg: String , | -------------- 420 | params : ExecBodyParams) | ----------------------- help: provide the argument | 37 | .say_in_reply_to(/* core::botinstance::Channel */, a, /* std::string::String */, params.clone()) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` --- Recommend this be adjusted to ```rust .say_in_reply_to(&params.msg.channel_login(), &params.msg.message_id(),a, params.clone()) ```
.say_in_reply_to(&params.msg, a, params.clone())
.await;
sleep(Duration::from_secs_f64(0.5)).await;
}else {
}
}
pub async fn init(mgr:&Arc<ModulesManager>){
BotCommand{
module:BotModule(String::from("thisguy")),
pub async fn init(mgr: &Arc<ModulesManager>) {
BotCommand {
module: BotModule(String::from("thisguy")),
command: String::from("anime"),
alias: vec![String::from("Anime")],
exec_body: actions_util::asyncbox(tesst),
help: String::from("test"),
required_roles: vec![
BotAdmin,
],
}.add_to_modmgr(Arc::clone(&mgr)).await;
required_roles: vec![BotAdmin],
}
.add_to_modmgr(Arc::clone(&mgr))
.await;
Listener {
module: BotModule(String::from("thisguy")),
name: String::from("This Guy Listener"),
exec_body: actions_util::asyncbox(tsg),
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
botlog::debug(
"tesst triggered!",