$VERSION = "1.2"; - r310 - Add rate limit check on login
authorDan Boger <zigdon@irc.peeron.com>
Thu, 8 Jan 2009 20:47:43 +0000 (12:47 -0800)
committerDan Boger <zigdon@irc.peeron.com>
Thu, 8 Jan 2009 20:47:43 +0000 (12:47 -0800)
twirssi.pl

index 83f1fe0e4af05b2568645e89a1152f08bcd97863..a7f8c4d66055123b14649dc8fb0d78d7b393f1ab 100644 (file)
@@ -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 ) {
+            &notice("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, "" );
         &notice("Logged in as $user, loading friends list...");
         &load_friends;
-        &notice( "loaded friends: ", scalar keys %nicks );
+        &notice( "loaded friends: ", scalar keys %friends );
         %nicks = %friends;
         $nicks{$user} = 0;
         &get_updates;