Custom this BotCommand #48

Merged
modulatingforce merged 12 commits from say-this-guy into master 2024-04-09 15:49:58 -04:00
6 changed files with 23 additions and 40 deletions
Showing only changes of commit f8de595290 - Show all commits

View file

@ -13,6 +13,7 @@ pub use crate::core::botmodules::ModulesManager;
// mod experiments;
mod experimental;
mod thisguy;
// [ ] init() function that accepts bot instance - this is passed to init() on submodules
@ -21,5 +22,6 @@ pub async fn init(mgr: Arc<ModulesManager>) {
// this is achieved by calling submodules that also have fn init() defined
// experiments::init(mgr).await
experimental::init(mgr).await;
experimental::init(mgr.clone()).await;
thisguy::init(&mgr).await;
}

View file

@ -105,6 +105,7 @@ async fn good_girl(params : ExecBodyParams) {
if params.msg.sender.name.to_lowercase() == "ModulatingForce".to_lowercase()
|| params.msg.sender.name.to_lowercase() == "mzNToRi".to_lowercase()
|| params.msg.sender.name.to_lowercase() == "haruyuumei".to_lowercase()
{
botlog::debug(
"Good Girl Detected > Pausechamp",

View file

@ -3,16 +3,26 @@ use crate::core::identity::UserRole::*;
use crate::core::bot_actions::*;
use crate::core::botlog;
use std::sync::Arc;
use rand::Rng;
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()
|| params.msg.sender.name.to_lowercase() == "ModulatingForce".to_lowercase()
{
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 r = rand::thread_rng().gen_range(0..=4);
let a = phrases[r].clone();
botlog::debug(
"Oh god I love anime Girls!!",
Some("modules > thisguy()".to_string()),
@ -26,8 +36,8 @@ async fn tsg(params: ExecBodyParams){
.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,
String::from("Oh god I love anime Girls!!"),
&params.msg,
a,
params.clone()
).await;
sleep(Duration::from_secs_f64(0.5)).await;
@ -39,16 +49,14 @@ pub async fn init(mgr:&Arc<ModulesManager>){
BotCommand{
module:BotModule(String::from("thisguy")),
command: String::from("this"),
alias: vec![String::from("tsg")],
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;
Listener {
module: BotModule(String::from("thisguy")),

View file

@ -1,3 +1,2 @@
pub mod core;
pub mod custom;
pub mod modules;
pub mod custom;

View file

@ -1,10 +0,0 @@
use std::sync::Arc;
pub use crate::core::botinstance::BotInstance;
pub use crate::core::botmodules::ModulesManager;
mod thisguy;
pub async fn init(mgr:&Arc<ModulesManager>){
thisguy::init(mgr).await;
}

View file

@ -1,17 +0,0 @@
use std::sync::Arc;
// pub use crate::core::botinstance::BotInstance;
pub use crate::core::botmodules::ModulesManager;
// [ ] Load submodules
mod thisguy;
// [ ] init() function that accepts bot instance - this is passed to init() on submodules
pub async fn init(mgr: Arc<ModulesManager>) {
// Modules initializer loads modules into the bot
// this is achieved by calling submodules that also have fn init() defined
thisguy::init(Arc::clone(&mgr)).await;
}