diff --git a/src/helpers.rs b/src/helpers.rs new file mode 100644 index 0000000..97b5a63 --- /dev/null +++ b/src/helpers.rs @@ -0,0 +1,40 @@ + +use std::time::Instant; +pub struct RateLimiter { + channels_attr: Vec, +} + + +struct RlAttributes { + channel: String, + enabled: bool, + start_time: Instant, + msg_counter: u32, +} + + + +impl RateLimiter { + pub fn new() -> Self { + Self { + channels_attr: vec![], + } + } + + pub fn sending_msg_to(&mut self, channelname: String) -> bool { + self.channels_attr.push(RlAttributes { + channel: channelname, + enabled: true, + start_time: Instant::now(), + msg_counter: 0, + }); + + let chanRateLimiter = self.channels_attr + .into_iter() + .filter(|r| r.channel == "Hello") + .collect(); + + chanRateLimiter.is_empty() + + } +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 9e877ae..5926d6d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ + + use twitch_irc::login::StaticLoginCredentials; use twitch_irc::ClientConfig; use twitch_irc::SecureTCPTransport; @@ -7,6 +9,8 @@ use std::env; use std::time::Instant; use rand::Rng; +// mod helpers; + #[tokio::main] pub async fn main() { let login_name = "modulatingforcebot".to_owned();