2024.01.29 - Latest Compiles without issues
This commit is contained in:
parent
b9ea781ed8
commit
25b73c41cc
5 changed files with 229 additions and 85 deletions
|
@ -145,10 +145,13 @@ impl Chat {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pub struct BotInstance<F>
|
// pub struct BotInstance<F>
|
||||||
where
|
// where
|
||||||
// F: std::future::Future + ?Sized,
|
// // F: std::future::Future + ?Sized,
|
||||||
F: std::future::Future
|
// // F: std::future::Future,
|
||||||
|
// //F: std::future::Future + Send,
|
||||||
|
// F: Send + ?Sized,
|
||||||
|
pub struct BotInstance
|
||||||
{
|
{
|
||||||
prefix : char,
|
prefix : char,
|
||||||
bot_channel : ChType,
|
bot_channel : ChType,
|
||||||
|
@ -157,7 +160,9 @@ where
|
||||||
// pub ratelimiters : HashMap<ChType,RateLimiter>, // used to limit messages sent per channel
|
// pub ratelimiters : HashMap<ChType,RateLimiter>, // used to limit messages sent per channel
|
||||||
pub chat : Chat,
|
pub chat : Chat,
|
||||||
// botmodules : HashMap<ModType,Vec<EnType>>,
|
// botmodules : HashMap<ModType,Vec<EnType>>,
|
||||||
pub botmodules : ModulesManager<F>,
|
// pub botmodules : ModulesManager<F>,
|
||||||
|
pub botmodules : ModulesManager,
|
||||||
|
//pub botmodules : &'static mut ModulesManager,
|
||||||
twitch_oauth : String,
|
twitch_oauth : String,
|
||||||
pub bot_channels : Vec<ChType>,
|
pub bot_channels : Vec<ChType>,
|
||||||
/*bot_commands : Vec[BotCommand],
|
/*bot_commands : Vec[BotCommand],
|
||||||
|
@ -169,16 +174,20 @@ where
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
impl<F> BotInstance<F>
|
// impl<F> BotInstance<F>
|
||||||
where
|
// where
|
||||||
F: std::future::Future + 'static,
|
// // F: std::future::Future + 'static,
|
||||||
//F: 'static,
|
// //F: 'static,
|
||||||
|
// //F: std::future::Future + Send + ?Sized 'static,
|
||||||
|
// F: Send + ?Sized + 'static,
|
||||||
|
impl BotInstance
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
pub fn init() -> BotInstance<F>
|
// pub fn init() -> BotInstance<F>
|
||||||
where
|
// where
|
||||||
F: std::future::Future + 'static,
|
// F: std::future::Future + 'static,
|
||||||
|
pub fn init() -> BotInstance
|
||||||
{
|
{
|
||||||
dotenv().ok();
|
dotenv().ok();
|
||||||
|
|
||||||
|
@ -220,6 +229,8 @@ where
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// let bm = &mut ModulesManager::init();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let b = BotInstance {
|
let b = BotInstance {
|
||||||
|
@ -234,6 +245,7 @@ where
|
||||||
// ratelimiters : ratelimiters, // used to limit messages sent per channel
|
// ratelimiters : ratelimiters, // used to limit messages sent per channel
|
||||||
// botmodules : HashMap::new(),
|
// botmodules : HashMap::new(),
|
||||||
botmodules : ModulesManager::init(),
|
botmodules : ModulesManager::init(),
|
||||||
|
//botmodules : bm,
|
||||||
twitch_oauth : oauth_token,
|
twitch_oauth : oauth_token,
|
||||||
bot_channels : botchannels,
|
bot_channels : botchannels,
|
||||||
/*bot_commands : Vec[BotCommand],
|
/*bot_commands : Vec[BotCommand],
|
||||||
|
|
|
@ -59,24 +59,37 @@ pub enum ModStatusType {
|
||||||
// pub use EnType::Enabled;
|
// pub use EnType::Enabled;
|
||||||
|
|
||||||
//#[derive(Debug)]
|
//#[derive(Debug)]
|
||||||
pub enum BotAction<F>
|
// pub enum BotAction<F>
|
||||||
// where
|
// where
|
||||||
// F: std::future::Future + ?Sized,
|
// //F: std::future::Future + ?Sized,
|
||||||
|
// // F: std::future::Future,
|
||||||
|
// //F: std::future::Future + Send,
|
||||||
|
// // F: Send,
|
||||||
|
// F: Send + ?Sized,
|
||||||
|
pub enum BotAction
|
||||||
{
|
{
|
||||||
//C(BotCommand),
|
//C(BotCommand),
|
||||||
L(Listener<F>),
|
// L(Listener<F>),
|
||||||
|
L(Listener),
|
||||||
R(Routine),
|
R(Routine),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub trait BotActionTrait<F>
|
// pub trait BotActionTrait<F>
|
||||||
where
|
// where
|
||||||
F: std::future::Future,
|
// // F: std::future::Future,
|
||||||
|
// //F: std::future::Future + ?Sized,
|
||||||
|
// //: std::future::Future + Send,
|
||||||
|
// // F: Send,
|
||||||
|
// F : Send + ?Sized
|
||||||
|
pub trait BotActionTrait
|
||||||
{
|
{
|
||||||
// async fn execute(&self,m:&mut BotInstance,n:&PrivmsgMessage);
|
// async fn execute(&self,m:&mut BotInstance,n:&PrivmsgMessage);
|
||||||
// fn add_to_bot(self, bot:BotInstance) -> Result<String,Box<dyn Error>>;
|
// fn add_to_bot(self, bot:BotInstance) -> Result<String,Box<dyn Error>>;
|
||||||
fn add_to_bot(self, bot:BotInstance<F>);
|
fn add_to_bot(self, bot:BotInstance);
|
||||||
fn add_to_modmgr(self, modmgr:ModulesManager<F>) -> ModulesManager<F>;
|
//fn add_to_modmgr(self, modmgr:ModulesManager<F>) -> ModulesManager<F>;
|
||||||
|
//fn add_to_modmgr(self,modmgr:&mut ModulesManager<F>) -> ModulesManager<F>;
|
||||||
|
fn add_to_modmgr(self,modmgr:&mut ModulesManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -185,12 +198,26 @@ pub mod bot_actions {
|
||||||
use crate::core::botinstance::Chat;
|
use crate::core::botinstance::Chat;
|
||||||
use twitch_irc::message::PrivmsgMessage;
|
use twitch_irc::message::PrivmsgMessage;
|
||||||
|
|
||||||
pub type ExecBody<F> = Box<dyn Fn(Chat,PrivmsgMessage) -> Pin<Box<dyn Future<Output = F>>>>;
|
// pub type ExecBody<F> = Box<dyn Fn(Chat,PrivmsgMessage) -> Pin<Box<dyn Future<Output = F>>>>;
|
||||||
|
|
||||||
|
// pub type ExecBody<F> = Box<dyn Fn(Chat,PrivmsgMessage) -> Pin<Box<dyn Future<Output=F> + Send>> + Send + Sync>;
|
||||||
|
pub type ExecBody = Box<dyn Fn(Chat,PrivmsgMessage) -> Pin<Box<dyn Future<Output=()> + Send>> + Send + Sync>;
|
||||||
|
|
||||||
pub fn asyncbox<F, T>(f: fn(Chat,PrivmsgMessage) -> T) -> ExecBody<F>
|
// pub fn asyncbox<F, T>(f: fn(Chat,PrivmsgMessage) -> T) -> ExecBody<F>
|
||||||
|
// where
|
||||||
|
// //T: Future<Output = F> + 'static,
|
||||||
|
// //T: Future<Output = F> ,
|
||||||
|
// T: Future<Output=F> + Send + 'static,
|
||||||
|
// {
|
||||||
|
// Box::new(move |a,b| Box::pin(f(a,b)))
|
||||||
|
// }
|
||||||
|
|
||||||
|
pub fn asyncbox<T>(f: fn(Chat,PrivmsgMessage) -> T) -> ExecBody
|
||||||
where
|
where
|
||||||
T: Future<Output = F> + 'static,
|
//T: Future<Output = F> + 'static,
|
||||||
//T: Future<Output = F> ,
|
//T: Future<Output = F> ,
|
||||||
|
// T: Future<Output=F> + Send + 'static,
|
||||||
|
T: Future<Output=()> + Send + 'static,
|
||||||
{
|
{
|
||||||
Box::new(move |a,b| Box::pin(f(a,b)))
|
Box::new(move |a,b| Box::pin(f(a,b)))
|
||||||
}
|
}
|
||||||
|
@ -210,9 +237,14 @@ pub mod bot_actions {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// #[derive(Debug)]
|
// #[derive(Debug)]
|
||||||
pub struct Listener<F>
|
// pub struct Listener<F>
|
||||||
|
pub struct Listener
|
||||||
// where
|
// where
|
||||||
// F: std::future::Future + ?Sized,
|
// // F: std::future::Future + ?Sized,
|
||||||
|
// //F: std::future::Future,
|
||||||
|
// //F: std::future::Future + ?Sized + Send,
|
||||||
|
// //F: Send,
|
||||||
|
// F: Send + ?Sized,
|
||||||
{
|
{
|
||||||
pub module : ModType,
|
pub module : ModType,
|
||||||
pub name : String,
|
pub name : String,
|
||||||
|
@ -221,13 +253,17 @@ pub struct Listener<F>
|
||||||
//pub exec_body : fn(&mut botinstance::Chat,&PrivmsgMessage) -> F ,
|
//pub exec_body : fn(&mut botinstance::Chat,&PrivmsgMessage) -> F ,
|
||||||
// pub exec_body : fn(botinstance::Chat,PrivmsgMessage) -> F ,
|
// pub exec_body : fn(botinstance::Chat,PrivmsgMessage) -> F ,
|
||||||
//pub exec_body : fn(String,&PrivmsgMessage) -> F ,
|
//pub exec_body : fn(String,&PrivmsgMessage) -> F ,
|
||||||
pub exec_body : bot_actions::actions_util::ExecBody<F>,
|
//pub exec_body : bot_actions::actions_util::ExecBody<F>,
|
||||||
|
pub exec_body : bot_actions::actions_util::ExecBody,
|
||||||
pub help : String
|
pub help : String
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F> Listener<F>
|
// impl<F> Listener<F>
|
||||||
// where
|
// where
|
||||||
// F: std::future::Future,
|
// // F: std::future::Future,
|
||||||
|
// //F: std::future::Future + Sized,
|
||||||
|
// F: std::future::Future + Sized + Send,
|
||||||
|
impl Listener
|
||||||
{
|
{
|
||||||
|
|
||||||
// async fn execute(&self,m:&mut Box<BotInstance<F>>,n:&PrivmsgMessage){
|
// async fn execute(&self,m:&mut Box<BotInstance<F>>,n:&PrivmsgMessage){
|
||||||
|
@ -241,29 +277,37 @@ impl<F> Listener<F>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F> BotActionTrait<F> for Listener<F>
|
// impl<F> BotActionTrait<F> for Listener<F>
|
||||||
where
|
// where
|
||||||
F: std::future::Future,
|
// //F: std::future::Future,
|
||||||
|
// //F: std::future::Future + Sized,
|
||||||
|
// // F: std::future::Future + Send,
|
||||||
|
// // F : Send,
|
||||||
|
// F : Send + ?Sized,
|
||||||
|
impl BotActionTrait for Listener
|
||||||
{
|
{
|
||||||
// fn add_to_bot(&self) -> Result<String,Box<dyn Error>> {
|
// fn add_to_bot(&self) -> Result<String,Box<dyn Error>> {
|
||||||
// println!("Calling Add to Bot");
|
// println!("Calling Add to Bot");
|
||||||
// Ok(String::from("Hello"))
|
// Ok(String::from("Hello"))
|
||||||
// }
|
// }
|
||||||
|
|
||||||
fn add_to_bot(self, bot:BotInstance<F>) {
|
// fn add_to_bot(self, mut bot:BotInstance<F>) {
|
||||||
|
fn add_to_bot(self, mut bot:BotInstance) {
|
||||||
// let mut mgr = bot.botmodules;
|
// let mut mgr = bot.botmodules;
|
||||||
// let nmod = self.module.clone();
|
// let nmod = self.module.clone();
|
||||||
// mgr.add_botaction(nmod, BotAction::C(self));
|
// mgr.add_botaction(nmod, BotAction::C(self));
|
||||||
let mgr = bot.botmodules;
|
//let mgr = &mut bot.botmodules;
|
||||||
//let nmod = self.module.clone();
|
//let nmod = self.module.clone();
|
||||||
// mgr.add_botaction(self.module.clone(), BotAction::C(self));
|
// mgr.add_botaction(self.module.clone(), BotAction::C(self));
|
||||||
|
|
||||||
|
let mgr = &mut bot.botmodules;
|
||||||
|
|
||||||
self.add_to_modmgr(mgr);
|
self.add_to_modmgr(mgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn add_to_modmgr(self, modmgr:&mut ModulesManager<F>) {
|
//fn add_to_modmgr(self, modmgr:&mut ModulesManager<F>) -> ModulesManager<F> {
|
||||||
//fn add_to_modmgr(self, mut modmgr:ModulesManager) {
|
fn add_to_modmgr(self, modmgr:&mut ModulesManager) {
|
||||||
fn add_to_modmgr(self, mut modmgr:ModulesManager<F>) -> ModulesManager<F> {
|
//fn add_to_modmgr(self, mut modmgr:ModulesManager<F>) -> ModulesManager<F> {
|
||||||
// // let mut mgr = bot.botmodules;
|
// // let mut mgr = bot.botmodules;
|
||||||
// // let nmod = self.module.clone();
|
// // let nmod = self.module.clone();
|
||||||
// // mgr.add_botaction(nmod, BotAction::C(self));
|
// // mgr.add_botaction(nmod, BotAction::C(self));
|
||||||
|
@ -308,22 +352,33 @@ struct Routine {}
|
||||||
|
|
||||||
|
|
||||||
//#[derive(Debug)]
|
//#[derive(Debug)]
|
||||||
pub struct ModulesManager<F>
|
// pub struct ModulesManager<F>
|
||||||
// where
|
// where
|
||||||
// F: std::future::Future + ?Sized,
|
// //F: std::future::Future + ?Sized,
|
||||||
|
// // F: std::future::Future,
|
||||||
|
// //F: std::future::Future + Send,
|
||||||
|
// // F: Send,
|
||||||
|
// // F: Send + ?Sized,
|
||||||
|
pub struct ModulesManager
|
||||||
{
|
{
|
||||||
statusdb: HashMap<ModType,Vec<ModStatusType>>,
|
statusdb: HashMap<ModType,Vec<ModStatusType>>,
|
||||||
botactions: HashMap<ModType,Vec<BotAction<F>>>,
|
botactions: HashMap<ModType,Vec<BotAction>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F> ModulesManager<F>
|
// impl<F> ModulesManager<F>
|
||||||
// where
|
// where
|
||||||
// F: std::future::Future,
|
// // F: std::future::Future,
|
||||||
|
// //F: std::future::Future + Send,
|
||||||
|
// // F : Send,
|
||||||
|
// F : Send + ?Sized,
|
||||||
|
impl ModulesManager
|
||||||
{
|
{
|
||||||
|
|
||||||
pub fn init() -> ModulesManager<F>
|
// pub fn init() -> ModulesManager<F>
|
||||||
// where
|
// where
|
||||||
// F: std::future::Future ,
|
// F: std::future::Future ,
|
||||||
|
// pub fn init() -> &'static mut ModulesManager
|
||||||
|
pub fn init() -> ModulesManager
|
||||||
{
|
{
|
||||||
|
|
||||||
// initializes the modulers manager
|
// initializes the modulers manager
|
||||||
|
@ -358,7 +413,11 @@ impl<F> ModulesManager<F>
|
||||||
// modactions.push(BotAction::L(newlistener));
|
// modactions.push(BotAction::L(newlistener));
|
||||||
|
|
||||||
|
|
||||||
let mgr = ModulesManager {
|
// let mgr = &mut ModulesManager {
|
||||||
|
// statusdb : m,
|
||||||
|
// botactions : act,
|
||||||
|
// };
|
||||||
|
let mut mgr = ModulesManager {
|
||||||
statusdb : m,
|
statusdb : m,
|
||||||
botactions : act,
|
botactions : act,
|
||||||
};
|
};
|
||||||
|
@ -416,14 +475,16 @@ impl<F> ModulesManager<F>
|
||||||
// crate::core::init(); // works
|
// crate::core::init(); // works
|
||||||
//crate::submods::
|
//crate::submods::
|
||||||
//crate::arbfile;
|
//crate::arbfile;
|
||||||
let mgr = crate::modules::init(mgr);
|
crate::modules::init(&mut mgr);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
println!(">> Modules Manager : End of Init");
|
println!(">> Modules Manager : End of Init");
|
||||||
//println!(">> Modules Manager : {:?}",mgr);
|
//println!(">> Modules Manager : {:?}",mgr);
|
||||||
|
|
||||||
mgr
|
// let &mut mgr = mgr;
|
||||||
|
// &mgr
|
||||||
|
mgr
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn modstatus(&self, _:ModType, _:ChType) -> ModStatusType {
|
pub fn modstatus(&self, _:ModType, _:ChType) -> ModStatusType {
|
||||||
|
@ -450,8 +511,10 @@ impl<F> ModulesManager<F>
|
||||||
Ok("")
|
Ok("")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_botaction(mut self, in_module:ModType, in_action:BotAction<F> ) -> ModulesManager<F> {
|
//pub fn add_botaction(mut self, in_module:ModType, in_action:BotAction ) -> ModulesManager {
|
||||||
|
// pub fn add_botaction(mut self, in_module:ModType, in_action:BotAction<F> ) -> ModulesManager<F> {
|
||||||
//pub fn add_botaction(&mut self, in_module:ModType, in_action:BotAction ) -> () {
|
//pub fn add_botaction(&mut self, in_module:ModType, in_action:BotAction ) -> () {
|
||||||
|
pub fn add_botaction(&mut self, in_module:ModType, in_action:BotAction ) {
|
||||||
/*
|
/*
|
||||||
adds a BotAction to the Modules Manager - This will require a BotModule passed as well
|
adds a BotAction to the Modules Manager - This will require a BotModule passed as well
|
||||||
This will including the logic of a valid add
|
This will including the logic of a valid add
|
||||||
|
@ -479,9 +542,13 @@ impl<F> ModulesManager<F>
|
||||||
// - If BotAction to Add is a BotCommand , In Module Manager DB (botactions),
|
// - If BotAction to Add is a BotCommand , In Module Manager DB (botactions),
|
||||||
// Check All Other BotAction Command Names & Aliases to ensure they don't conflict
|
// Check All Other BotAction Command Names & Aliases to ensure they don't conflict
|
||||||
|
|
||||||
fn find_conflict_module<F>(mgr:& ModulesManager<F>, act:& BotAction<F>) -> Option<ModType>
|
// fn find_conflict_module<F>(mgr:& ModulesManager<F>, act:& BotAction<F>) -> Option<ModType>
|
||||||
// where
|
// where
|
||||||
// F: std::future::Future,
|
// // F: std::future::Future,
|
||||||
|
// // F: std::future::Future + Send,
|
||||||
|
// // F : Send,
|
||||||
|
// F : Send + ?Sized,
|
||||||
|
fn find_conflict_module(mgr:& ModulesManager, act:& BotAction) -> Option<ModType>
|
||||||
{
|
{
|
||||||
|
|
||||||
// Some(BotModule(String::from("GambaCore")))
|
// Some(BotModule(String::from("GambaCore")))
|
||||||
|
@ -599,7 +666,7 @@ impl<F> ModulesManager<F>
|
||||||
|
|
||||||
//mgr
|
//mgr
|
||||||
|
|
||||||
self
|
//self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ pub async fn main() {
|
||||||
|
|
||||||
//let bot:BotInstance<dyn std::future::Future<Output = ()>> = BotInstance::init();
|
//let bot:BotInstance<dyn std::future::Future<Output = ()>> = BotInstance::init();
|
||||||
|
|
||||||
|
//let bot:BotInstance<dyn Send + std::future::Future<Output = ()>> = BotInstance::init();
|
||||||
|
//let bot:BotInstance<std::future::Future<Output = ()> + Sized> = BotInstance::init();
|
||||||
let bot = BotInstance::init();
|
let bot = BotInstance::init();
|
||||||
|
|
||||||
bot.runner().await;
|
bot.runner().await;
|
||||||
|
|
|
@ -19,9 +19,13 @@ mod experiments;
|
||||||
|
|
||||||
// [ ] init() function that accepts bot instance - this is passed to init() on submodules
|
// [ ] init() function that accepts bot instance - this is passed to init() on submodules
|
||||||
|
|
||||||
pub fn init<F>(mgr:ModulesManager<F>) -> ModulesManager<F>
|
// pub fn init<F>(mgr:ModulesManager<F>) -> ModulesManager<F>
|
||||||
|
// pub fn init<F>(mgr:ModulesManager<F>)
|
||||||
// where
|
// where
|
||||||
// F: std::future::Future,
|
// // F: std::future::Future + Send,
|
||||||
|
// // F : Send,
|
||||||
|
// F : Send + ?Sized,
|
||||||
|
pub fn init(mgr:&mut ModulesManager)
|
||||||
{
|
{
|
||||||
// Modules initializer loads modules into the bot
|
// Modules initializer loads modules into the bot
|
||||||
// this is achieved by calling submodules that also have fn init() defined
|
// this is achieved by calling submodules that also have fn init() defined
|
||||||
|
|
|
@ -12,14 +12,21 @@
|
||||||
// mod crate::modules;
|
// mod crate::modules;
|
||||||
//use crate::modules;
|
//use crate::modules;
|
||||||
|
|
||||||
|
use std::future::Future;
|
||||||
|
|
||||||
use crate::core::botmodules::{ModulesManager,Listener,BotModule,BotActionTrait, self};
|
use crate::core::botmodules::{ModulesManager,Listener,BotModule,BotActionTrait, self};
|
||||||
|
use crate::core::botmodules::bot_actions::actions_util;
|
||||||
|
|
||||||
use crate::core::botinstance::{self};
|
use crate::core::botinstance::{self};
|
||||||
use twitch_irc::message::PrivmsgMessage;
|
use twitch_irc::message::PrivmsgMessage;
|
||||||
|
|
||||||
pub fn init<F>(mgr:ModulesManager<F>) -> ModulesManager<F>
|
// pub fn init<F>(mgr:ModulesManager<F>) -> ModulesManager<F>
|
||||||
|
// pub fn init<F>(mgr:ModulesManager<F>)
|
||||||
// where
|
// where
|
||||||
// F: std::future::Future,
|
// // F: std::future::Future + Send,
|
||||||
|
// // F : Send,
|
||||||
|
// F : Send + ?Sized,
|
||||||
|
pub fn init(mgr:&mut ModulesManager)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,15 +40,64 @@ pub fn init<F>(mgr:ModulesManager<F>) -> ModulesManager<F>
|
||||||
// }.add_to_modmgr(mgr);
|
// }.add_to_modmgr(mgr);
|
||||||
|
|
||||||
|
|
||||||
let list1 = Listener {
|
// let list1 = Listener::<dyn std::future::Future<Output = ()>> {
|
||||||
module : BotModule(String::from("experiments 004")),
|
// //let list1 = Listener {
|
||||||
name : String::from("GoodGirl Listener"),
|
// module : BotModule(String::from("experiments 004")),
|
||||||
// exec_body : good_girl::<dyn std::future::Future<Output = ()>> ,
|
// name : String::from("GoodGirl Listener"),
|
||||||
// exec_body : good_girl ,
|
// // exec_body : good_girl::<dyn std::future::Future<Output = ()>> ,
|
||||||
help : String::from("")
|
// // exec_body : good_girl ,
|
||||||
|
// exec_body : actions_util::asyncbox(good_girl),
|
||||||
|
// //exec_body : actions_util::asyncbox(good_girl::<dyn std::future::Future<Output = ()>>) ,
|
||||||
|
// //exec_body : actions_util::asyncbox(good_girl::<dyn std::future::Future<Output = ()>>),
|
||||||
|
|
||||||
|
// help : String::from("")
|
||||||
|
// };
|
||||||
|
|
||||||
|
// let list1 = Listener::<dyn std::future::Future<Output = ()>> {
|
||||||
|
// //let list1 = Listener {
|
||||||
|
// module : BotModule(String::from("experiments 004")),
|
||||||
|
// name : String::from("GoodGirl Listener"),
|
||||||
|
// // exec_body : good_girl::<dyn std::future::Future<Output = ()>> ,
|
||||||
|
// // exec_body : good_girl ,
|
||||||
|
// exec_body : actions_util::asyncbox(good_girl),
|
||||||
|
// //exec_body : actions_util::asyncbox(good_girl::<dyn std::future::Future<Output = ()>>) ,
|
||||||
|
// //exec_body : actions_util::asyncbox(good_girl::<dyn std::future::Future<Output = ()>>),
|
||||||
|
|
||||||
|
// help : String::from("")
|
||||||
|
// };
|
||||||
|
|
||||||
|
//let list1 = Listener::<dyn Send + std::future::Future<Output = ()>> {
|
||||||
|
let list1 = Listener {
|
||||||
|
module : BotModule(String::from("experiments 004")),
|
||||||
|
name : String::from("GoodGirl Listener"),
|
||||||
|
// exec_body : good_girl::<dyn std::future::Future<Output = ()>> ,
|
||||||
|
//exec_body : good_girl ,
|
||||||
|
//exec_body : actions_util::asyncbox(good_girl),
|
||||||
|
exec_body : actions_util::asyncbox(good_girl) ,
|
||||||
|
//exec_body : actions_util::asyncbox(good_girl::<dyn std::future::Future<Output = ()>>),
|
||||||
|
//exec_body : actions_util::asyncbox(good_girl::<dyn std::future::Future<Output = dyn Future<Output = ()>>>),
|
||||||
|
|
||||||
|
help : String::from("")
|
||||||
};
|
};
|
||||||
|
|
||||||
let mgr = list1.add_to_modmgr(mgr);
|
|
||||||
|
// let list1 = Listener::<> {
|
||||||
|
// //let list1 = Listener {
|
||||||
|
// module : BotModule(String::from("experiments 004")),
|
||||||
|
// name : String::from("GoodGirl Listener"),
|
||||||
|
// // exec_body : good_girl::<dyn std::future::Future<Output = ()>> ,
|
||||||
|
// //exec_body : good_girl ,
|
||||||
|
// //exec_body : actions_util::asyncbox(good_girl),
|
||||||
|
// exec_body : actions_util::asyncbox(good_girl) ,
|
||||||
|
// //exec_body : actions_util::asyncbox(good_girl::<dyn std::future::Future<Output = ()>>),
|
||||||
|
|
||||||
|
// help : String::from("")
|
||||||
|
// };
|
||||||
|
|
||||||
|
list1.add_to_modmgr(mgr);
|
||||||
|
|
||||||
|
|
||||||
|
// let mgr = list1.add_to_modmgr(mgr);
|
||||||
|
|
||||||
// Listener {
|
// Listener {
|
||||||
// module : BotModule(String::from("experiments 004")),
|
// module : BotModule(String::from("experiments 004")),
|
||||||
|
@ -68,27 +124,27 @@ pub fn init<F>(mgr:ModulesManager<F>) -> ModulesManager<F>
|
||||||
// help : String::from("")
|
// help : String::from("")
|
||||||
// };
|
// };
|
||||||
|
|
||||||
println!("At Experiments module");
|
// println!("At Experiments module");
|
||||||
|
|
||||||
|
|
||||||
//();
|
// //();
|
||||||
mgr
|
// mgr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub struct Listener2<F>
|
// pub struct Listener2<F>
|
||||||
// where
|
// // where
|
||||||
// F: std::future::Future + ?Sized,
|
// // F: std::future::Future + ?Sized,
|
||||||
{
|
// {
|
||||||
pub module : botmodules::ModType,
|
// pub module : botmodules::ModType,
|
||||||
pub name : String,
|
// pub name : String,
|
||||||
//pub exec_body : fn(&mut BotInstance,&PrivmsgMessage) ,
|
// //pub exec_body : fn(&mut BotInstance,&PrivmsgMessage) ,
|
||||||
// pub exec_body : fn(&mut Box<BotInstance<F>>,&PrivmsgMessage) -> F ,
|
// // pub exec_body : fn(&mut Box<BotInstance<F>>,&PrivmsgMessage) -> F ,
|
||||||
//pub exec_body : fn(&mut botinstance::Chat,&PrivmsgMessage) -> dyn std::future::Future<Output = ()> ,
|
// //pub exec_body : fn(&mut botinstance::Chat,&PrivmsgMessage) -> dyn std::future::Future<Output = ()> ,
|
||||||
pub exec_body : fn(&mut botinstance::Chat,&PrivmsgMessage) -> F ,
|
// pub exec_body : fn(&mut botinstance::Chat,&PrivmsgMessage) -> F ,
|
||||||
//pub exec_body : fn(String,&PrivmsgMessage) -> F ,
|
// //pub exec_body : fn(String,&PrivmsgMessage) -> F ,
|
||||||
pub help : String
|
// pub help : String
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
// pub struct Listener3<F>
|
// pub struct Listener3<F>
|
||||||
|
@ -107,12 +163,12 @@ pub struct Listener2<F>
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
async fn testfn2(mut _chat:botinstance::Chat,_msg:PrivmsgMessage)
|
// async fn testfn2(mut _chat:botinstance::Chat,_msg:PrivmsgMessage)
|
||||||
// where
|
// // where
|
||||||
// F : std::future::Future + ?Sized,
|
// // F : std::future::Future + ?Sized,
|
||||||
{
|
// {
|
||||||
println!("testfn2");
|
// println!("testfn2");
|
||||||
}
|
// }
|
||||||
|
|
||||||
// async fn good_girl(bot:&mut BotInstance,msg:&PrivmsgMessage) {
|
// async fn good_girl(bot:&mut BotInstance,msg:&PrivmsgMessage) {
|
||||||
// println!("In GoodGirl()");
|
// println!("In GoodGirl()");
|
||||||
|
@ -142,9 +198,12 @@ async fn testfn2(mut _chat:botinstance::Chat,_msg:PrivmsgMessage)
|
||||||
//async fn good_girl<F>(bot:&mut Box<BotInstance<F>>,msg:&PrivmsgMessage)
|
//async fn good_girl<F>(bot:&mut Box<BotInstance<F>>,msg:&PrivmsgMessage)
|
||||||
//async fn good_girl<F>(chat:&mut botinstance::Chat,msg:&PrivmsgMessage)
|
//async fn good_girl<F>(chat:&mut botinstance::Chat,msg:&PrivmsgMessage)
|
||||||
// async fn good_girl(chat:&mut botinstance::Chat,msg:&PrivmsgMessage)
|
// async fn good_girl(chat:&mut botinstance::Chat,msg:&PrivmsgMessage)
|
||||||
async fn good_girl(mut chat:botinstance::Chat,msg:PrivmsgMessage)
|
async fn good_girl(mut chat:botinstance::Chat,msg:PrivmsgMessage)
|
||||||
// where
|
//async fn good_girl<F>(mut chat:botinstance::Chat,msg:PrivmsgMessage)
|
||||||
// F: std::future::Future + ?Sized,
|
// where
|
||||||
|
// //F: std::future::Future + ?Sized,
|
||||||
|
// //F: std::future::Future,
|
||||||
|
// F: std::future::Future + Sized + Send,
|
||||||
{
|
{
|
||||||
println!("In GoodGirl()");
|
println!("In GoodGirl()");
|
||||||
println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text);
|
println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text);
|
||||||
|
|
Loading…
Reference in a new issue