diff --git a/src/core.rs b/src/core.rs index 5e6c370..8917c5d 100644 --- a/src/core.rs +++ b/src/core.rs @@ -1,3 +1,4 @@ +pub mod bot_actions; pub mod botinstance; pub mod botlog; pub mod botmodules; diff --git a/src/core/bot_actions.rs b/src/core/bot_actions.rs new file mode 100644 index 0000000..9e56e07 --- /dev/null +++ b/src/core/bot_actions.rs @@ -0,0 +1,27 @@ +pub mod actions_util { + + use std::boxed::Box; + use std::future::Future; + use std::pin::Pin; + use std::sync::Arc; + + use tokio::sync::{Mutex, RwLock}; + + use twitch_irc::message::PrivmsgMessage; + + use crate::core::botinstance::BotInstance; + + pub type BotAM = Arc>; + pub type BotAR = Arc>; + + pub type ExecBody = Box< + dyn Fn(BotAR, PrivmsgMessage) -> Pin + Send>> + Send + Sync, + >; + + pub fn asyncbox(f: fn(BotAR, PrivmsgMessage) -> T) -> ExecBody + where + T: Future + Send + 'static, + { + Box::new(move |a, b| Box::pin(f(a, b))) + } +} diff --git a/src/core/botmodules.rs b/src/core/botmodules.rs index b7b27fd..b03d122 100644 --- a/src/core/botmodules.rs +++ b/src/core/botmodules.rs @@ -19,11 +19,10 @@ Example */ - use core::panic; -use std::error::Error; use std::collections::HashMap; +use std::error::Error; use std::sync::Arc; use twitch_irc::message::PrivmsgMessage; @@ -32,11 +31,12 @@ use tokio::sync::RwLock; use async_trait::async_trait; -use crate::core::botinstance::{BotInstance,ChType}; +use self::bot_actions::actions_util::BotAR; +use crate::core::botinstance::{BotInstance, ChType}; use crate::core::botlog; use crate::core::identity; -use self::bot_actions::actions_util::BotAR; +pub use crate::core::bot_actions; pub use ChType::Channel; pub use ModType::BotModule; @@ -107,41 +107,6 @@ impl BotActionTrait for BotCommand { } } -pub mod bot_actions { - - pub mod actions_util { - - use std::boxed::Box; - use std::future::Future; - use std::pin::Pin; - - // use std::rc::Rc; - - // use crate::core::botinstance::{BotInstance, BotManagers, Chat}; - use crate::core::botinstance::BotInstance; - // use std::cell::RefCell; - use std::sync::Arc; - use twitch_irc::message::PrivmsgMessage; - // use futures::lock::Mutex; - // Important to use tokios Mutex here since std Mutex doesn't work with async functions - use tokio::sync::{Mutex, RwLock}; - - pub type BotAM = Arc>; - pub type BotAR = Arc>; - - pub type ExecBody = Box< - dyn Fn(BotAR, PrivmsgMessage) -> Pin + Send>> + Send + Sync, - >; - - pub fn asyncbox(f: fn(BotAR, PrivmsgMessage) -> T) -> ExecBody - where - T: Future + Send + 'static, - { - Box::new(move |a, b| Box::pin(f(a, b))) - } - } -} - pub struct Listener { pub module: ModType, pub name: String,