cont reorg botinstance

This commit is contained in:
ModulatingForce 2023-12-19 21:08:48 -05:00
commit 39791b20a7
4 changed files with 48 additions and 18 deletions

View file

@ -10,13 +10,24 @@ use twitch_irc::transport::tcp::TLS;
use std::env;
use dotenv::dotenv;
use std::collections::HashMap;
//mod sub::ratelimiter;
use crate::core::ratelimiter::RateLimiter;
// use crate::core::ratelimiter;
struct Channel(String);
pub struct BotInstance {
prefix : char,
bot_channel : String,
pub client : TwitchIRCClient<TCPTransport<TLS>,StaticLoginCredentials>,
pub incoming_messages : UnboundedReceiver<ServerMessage>,
// ratelimiters : HashMap<Channel(String),Ratelimiter>, // used to limit messages sent per channel
pub ratelimiters : HashMap<String,RateLimiter>, // used to limit messages sent per channel
// botmodules : Hashmap<botmodule(String),Vec[Enabled(Channel(String)))]>,
twitch_oauth : String,
pub bot_channels : Vec<String>,
@ -60,13 +71,15 @@ impl BotInstance {
//client.say(chnl.to_owned(), "annytfLurk".to_owned()).await.unwrap();
}
BotInstance {
let mut b = BotInstance {
prefix : '>',
bot_channel : login_name ,
// tclient : TwitchClient { incoming_messages , client },
incoming_messages,
client,
// ratelimiters : HashMap<Channel(String),Ratelimiter>, // used to limit messages sent per channel
incoming_messages : incoming_messages,
client : client,
ratelimiters : HashMap::new(), // used to limit messages sent per channel
// botmodules : Hashmap<botmodule(String),Vec[Enabled(Channel(String)))]>,
twitch_oauth : oauth_token,
bot_channels : botchannels,
@ -75,7 +88,20 @@ impl BotInstance {
bot_routines : Vec[Routine],*/
// botactionsdb : botactionsdb:botactions,
// identity : identitymodule,
};
// ratelimiters are a hashmap of channel and a corresponding rate limiter
// let mut ratelimiters:HashMap<String,RateLimiter> = HashMap::new();
for chnl in &b.bot_channels {
let n = RateLimiter::new();
b.ratelimiters.insert(chnl.to_owned(),n);
}
println!("{:?}",b.ratelimiters);
b
}
}