smol
This commit is contained in:
parent
f6ee3aae25
commit
d8c187d53a
1 changed files with 141 additions and 23 deletions
|
@ -4,6 +4,7 @@ use twitch_irc::login::StaticLoginCredentials;
|
|||
use twitch_irc::ClientConfig;
|
||||
use twitch_irc::SecureTCPTransport;
|
||||
use twitch_irc::TwitchIRCClient;
|
||||
use twitch_irc::message::PrivmsgMessage;
|
||||
use twitch_irc::message::ServerMessage;
|
||||
use twitch_irc::transport::tcp::TCPTransport;
|
||||
use twitch_irc::transport::tcp::TLS;
|
||||
|
@ -43,9 +44,9 @@ pub struct BotInstance {
|
|||
// identity : identitymodule,
|
||||
}
|
||||
|
||||
|
||||
impl BotInstance {
|
||||
|
||||
|
||||
pub fn init() -> BotInstance {
|
||||
dotenv().ok();
|
||||
|
||||
|
@ -130,30 +131,40 @@ impl BotInstance {
|
|||
println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text);
|
||||
|
||||
|
||||
// let contextratelimiter = ratelimiters.get_mut(&msg.channel_login).expect("ERROR: Issue with Rate limiters");
|
||||
let contextratelimiter = self.ratelimiters.get_mut(&msg.channel_login).expect("ERROR: Issue with Rate limiters");
|
||||
// // let contextratelimiter = ratelimiters.get_mut(&msg.channel_login).expect("ERROR: Issue with Rate limiters");
|
||||
// let contextratelimiter = self.ratelimiters.get_mut(&msg.channel_login).expect("ERROR: Issue with Rate limiters");
|
||||
|
||||
match contextratelimiter.check_limiter() {
|
||||
ratelimiter::LimiterResp::Allow => {
|
||||
let maxblanks = rand::thread_rng().gen_range(1..=20);
|
||||
//let mut outmsg = "GotTrolled ".to_owned();
|
||||
let mut outmsg = "annytfLurk ".to_owned();
|
||||
// match contextratelimiter.check_limiter() {
|
||||
// ratelimiter::LimiterResp::Allow => {
|
||||
// let maxblanks = rand::thread_rng().gen_range(1..=20);
|
||||
// //let mut outmsg = "GotTrolled ".to_owned();
|
||||
// let mut outmsg = "annytfLurk ".to_owned();
|
||||
|
||||
for _i in 1..maxblanks {
|
||||
let blankspace: &str = "";
|
||||
outmsg.push_str(blankspace);
|
||||
}
|
||||
// for _i in 1..maxblanks {
|
||||
// let blankspace: &str = "";
|
||||
// outmsg.push_str(blankspace);
|
||||
// }
|
||||
|
||||
// // client.say_in_reply_to(&msg,outmsg).await.unwrap();
|
||||
// self.client.say_in_reply_to(&msg,outmsg).await.unwrap();
|
||||
// println!("(#{}) > {}", msg.channel_login, "rate limit counter increase");
|
||||
// contextratelimiter.increment_counter();
|
||||
// println!("{:?}",self.ratelimiters);
|
||||
// },
|
||||
// ratelimiter::LimiterResp::Skip => {
|
||||
// (); // do nothing otherwise
|
||||
// }
|
||||
// }
|
||||
|
||||
// BotInstance::listener_main_prvmsg(msg);
|
||||
//let botref = *self;
|
||||
// BotInstance::listener_main_prvmsg(botref,msg).await();
|
||||
//self.listener_main_prvmsg(&msg);
|
||||
|
||||
println!("Something");
|
||||
|
||||
self.listener_main_prvmsg();
|
||||
|
||||
// client.say_in_reply_to(&msg,outmsg).await.unwrap();
|
||||
self.client.say_in_reply_to(&msg,outmsg).await.unwrap();
|
||||
println!("(#{}) > {}", msg.channel_login, "rate limit counter increase");
|
||||
contextratelimiter.increment_counter();
|
||||
println!("{:?}",self.ratelimiters);
|
||||
},
|
||||
ratelimiter::LimiterResp::Skip => {
|
||||
(); // do nothing otherwise
|
||||
}
|
||||
}
|
||||
},
|
||||
ServerMessage::Whisper(msg) => {
|
||||
println!("(w) {}: {}", msg.sender.name, msg.message_text);
|
||||
|
@ -176,4 +187,111 @@ impl BotInstance {
|
|||
join_handle.await.unwrap();
|
||||
}
|
||||
|
||||
|
||||
// -----------------
|
||||
// PRIVATE FUNCTIONS
|
||||
|
||||
// async fn listener_main_prvmsg(bot:BotInstance,msg:PrivmsgMessage) -> () {
|
||||
|
||||
// println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text);
|
||||
|
||||
|
||||
// // let contextratelimiter = ratelimiters.get_mut(&msg.channel_login).expect("ERROR: Issue with Rate limiters");
|
||||
// let contextratelimiter = bot.ratelimiters.get_mut(&msg.channel_login).expect("ERROR: Issue with Rate limiters");
|
||||
|
||||
// match contextratelimiter.check_limiter() {
|
||||
// ratelimiter::LimiterResp::Allow => {
|
||||
// let maxblanks = rand::thread_rng().gen_range(1..=20);
|
||||
// //let mut outmsg = "GotTrolled ".to_owned();
|
||||
// let mut outmsg = "annytfLurk ".to_owned();
|
||||
|
||||
// for _i in 1..maxblanks {
|
||||
// let blankspace: &str = "";
|
||||
// outmsg.push_str(blankspace);
|
||||
// }
|
||||
|
||||
// // client.say_in_reply_to(&msg,outmsg).await.unwrap();
|
||||
// bot.client.say_in_reply_to(&msg,outmsg).await.unwrap();
|
||||
// println!("(#{}) > {}", msg.channel_login, "rate limit counter increase");
|
||||
// contextratelimiter.increment_counter();
|
||||
// println!("{:?}",bot.ratelimiters);
|
||||
// },
|
||||
// ratelimiter::LimiterResp::Skip => {
|
||||
// (); // do nothing otherwise
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// async fn listener_main_prvmsg(mut self,msg:& PrivmsgMessage) -> () {
|
||||
|
||||
// println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text);
|
||||
|
||||
|
||||
// // let contextratelimiter = ratelimiters.get_mut(&msg.channel_login).expect("ERROR: Issue with Rate limiters");
|
||||
// let contextratelimiter = self.ratelimiters.get_mut(&msg.channel_login).expect("ERROR: Issue with Rate limiters");
|
||||
|
||||
// match contextratelimiter.check_limiter() {
|
||||
// ratelimiter::LimiterResp::Allow => {
|
||||
// let maxblanks = rand::thread_rng().gen_range(1..=20);
|
||||
// //let mut outmsg = "GotTrolled ".to_owned();
|
||||
// let mut outmsg = "annytfLurk ".to_owned();
|
||||
|
||||
// for _i in 1..maxblanks {
|
||||
// let blankspace: &str = "";
|
||||
// outmsg.push_str(blankspace);
|
||||
// }
|
||||
|
||||
// // client.say_in_reply_to(&msg,outmsg).await.unwrap();
|
||||
// self.client.say_in_reply_to(msg,outmsg).await.unwrap();
|
||||
// println!("(#{}) > {}", msg.channel_login, "rate limit counter increase");
|
||||
// contextratelimiter.increment_counter();
|
||||
// println!("{:?}",self.ratelimiters);
|
||||
// },
|
||||
// ratelimiter::LimiterResp::Skip => {
|
||||
// (); // do nothing otherwise
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
|
||||
async fn listener_main_prvmsg(self) -> () {
|
||||
|
||||
// println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text);
|
||||
|
||||
|
||||
// // let contextratelimiter = ratelimiters.get_mut(&msg.channel_login).expect("ERROR: Issue with Rate limiters");
|
||||
// let contextratelimiter = self.ratelimiters.get_mut(&msg.channel_login).expect("ERROR: Issue with Rate limiters");
|
||||
|
||||
// match contextratelimiter.check_limiter() {
|
||||
// ratelimiter::LimiterResp::Allow => {
|
||||
// let maxblanks = rand::thread_rng().gen_range(1..=20);
|
||||
// //let mut outmsg = "GotTrolled ".to_owned();
|
||||
// let mut outmsg = "annytfLurk ".to_owned();
|
||||
|
||||
// for _i in 1..maxblanks {
|
||||
// let blankspace: &str = "";
|
||||
// outmsg.push_str(blankspace);
|
||||
// }
|
||||
|
||||
// // client.say_in_reply_to(&msg,outmsg).await.unwrap();
|
||||
// self.client.say_in_reply_to(msg,outmsg).await.unwrap();
|
||||
// println!("(#{}) > {}", msg.channel_login, "rate limit counter increase");
|
||||
// contextratelimiter.increment_counter();
|
||||
// println!("{:?}",self.ratelimiters);
|
||||
// },
|
||||
// ratelimiter::LimiterResp::Skip => {
|
||||
// (); // do nothing otherwise
|
||||
// }
|
||||
// }
|
||||
|
||||
println!("Something");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue