X-Git-Url: https://git.sommitrealweird.co.uk/twirssi-net-twitter-lite.git/blobdiff_plain/e251095e4a33615f0ff99e2f238f9e48814f4950..b7891f5d621a37490844913a219b47b2feb23ea4:/twirssi.pl diff --git a/twirssi.pl b/twirssi.pl index 3ae46d9..5295231 100644 --- a/twirssi.pl +++ b/twirssi.pl @@ -430,7 +430,9 @@ sub cmd_logout { return unless $data = &valid_username($data); ¬ice("Logging out $data..."); - $twits{$data}->end_session(); + eval { + $twits{$data}->end_session(); + }; delete $twits{$data}; undef $twit; if ( keys %twits ) { @@ -541,10 +543,19 @@ sub cmd_login { } unless ( $twit->authorized ) { + eval { + my $url = $twit->get_authorization_url; + }; + + if ($@) { + ¬ice("ERROR: Failed to get OAuth authorization_url. Try again later."); + return; + } + ¬ice("Twirssi not autorized to access $service for $user."); ¬ice("Please authorize at the following url, then enter the pin "); - ¬ice("supplied with /twirssi_oath $user\@$service "); - ¬ice($twit->get_authorization_url); + ¬ice("supplied with /twirssi_oauth $user\@$service "); + ¬ice($url); $oauth{pending}{"$user\@$service"} = $twit; return; @@ -1043,11 +1054,13 @@ sub get_updates { sub do_updates { my ( $fh, $username, $obj, $cache ) = @_; - my $rate_limit = $obj->rate_limit_status(); - if ( $rate_limit and $rate_limit->{remaining_hits} < 1 ) { - ¬ice("Rate limit exceeded for $username"); - return undef; - } + eval { + my $rate_limit = $obj->rate_limit_status(); + if ( $rate_limit and $rate_limit->{remaining_hits} < 1 ) { + ¬ice("Rate limit exceeded for $username"); + return undef; + } + }; print scalar localtime, " - Polling for updates for $username" if &debug; my $tweets; @@ -2002,9 +2015,7 @@ if ($window) { } } - if ( my $autouser = Irssi::settings_get_str("twitter_usernames") - and my $autopass = Irssi::settings_get_str("twitter_passwords") ) - { + if ( my $autouser = Irssi::settings_get_str("twitter_usernames") ) { &cmd_login(); &get_updates; }