From 2b71a7777141bcc9a4c1681f899d2b86696790b4 Mon Sep 17 00:00:00 2001 From: Dan Boger Date: Thu, 8 Jan 2009 12:47:43 -0800 Subject: [PATCH 1/1] $VERSION = "1.2"; - r310 - Add rate limit check on login --- twirssi.pl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/twirssi.pl b/twirssi.pl index 83f1fe0..a7f8c4d 100644 --- a/twirssi.pl +++ b/twirssi.pl @@ -9,8 +9,8 @@ use File::Temp; use vars qw($VERSION %IRSSI); use constant { DEBUG => 0 }; -$VERSION = "1.1"; -my ($REV) = '$Rev: 309 $' =~ /(\d+)/; +$VERSION = "1.2"; +my ($REV) = '$Rev: 310 $' =~ /(\d+)/; %IRSSI = ( authors => 'Dan Boger', contact => 'zigdon@gmail.com', @@ -231,12 +231,19 @@ sub cmd_login { } if ($twit) { + my $rate_limit = $twit->rate_limit_status(); + if ( $rate_limit and $rate_limit->{remaining_hits} < 1 ) { + ¬ice("Rate limit exceeded, try again later"); + $twit = undef; + return; + } + $twits{$user} = $twit; Irssi::timeout_remove($poll) if $poll; $poll = Irssi::timeout_add( 300 * 1000, \&get_updates, "" ); ¬ice("Logged in as $user, loading friends list..."); &load_friends; - ¬ice( "loaded friends: ", scalar keys %nicks ); + ¬ice( "loaded friends: ", scalar keys %friends ); %nicks = %friends; $nicks{$user} = 0; &get_updates; -- 2.39.5