From: Dan Boger Date: Thu, 8 Jan 2009 20:47:43 +0000 (-0800) Subject: $VERSION = "1.2"; - r310 - Add rate limit check on login X-Git-Url: https://git.sommitrealweird.co.uk/twirssi-net-twitter-lite.git/commitdiff_plain/2b71a7777141bcc9a4c1681f899d2b86696790b4?ds=inline $VERSION = "1.2"; - r310 - Add rate limit check on login --- 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;