[INIT] started helper functions (incomplete)

This commit is contained in:
ModulatingForce 2023-11-29 22:11:12 -05:00
parent 5ec7210dc6
commit 27b504012e
2 changed files with 44 additions and 0 deletions

40
src/helpers.rs Normal file
View file

@ -0,0 +1,40 @@
use std::time::Instant;
pub struct RateLimiter {
channels_attr: Vec<RlAttributes>,
}
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()
}
}

View file

@ -1,3 +1,5 @@
use twitch_irc::login::StaticLoginCredentials; use twitch_irc::login::StaticLoginCredentials;
use twitch_irc::ClientConfig; use twitch_irc::ClientConfig;
use twitch_irc::SecureTCPTransport; use twitch_irc::SecureTCPTransport;
@ -7,6 +9,8 @@ use std::env;
use std::time::Instant; use std::time::Instant;
use rand::Rng; use rand::Rng;
// mod helpers;
#[tokio::main] #[tokio::main]
pub async fn main() { pub async fn main() {
let login_name = "modulatingforcebot".to_owned(); let login_name = "modulatingforcebot".to_owned();