X-Git-Url: https://git.sommitrealweird.co.uk//gitweb/?p=twirssi-net-twitter-lite.git;a=blobdiff_plain;f=twirssi.pl;h=331715ce03737fbfe13a9606df4d34fc16799292;hp=68dfac8d6c3fb2aea85e79d58e4cccb41a85bd34;hb=4edf2cd46af41132f0235069bb4c03b09c1a24ca;hpb=720e93b3ab39eaf2acbb54ec4fd365732f4ed47f diff --git a/twirssi.pl b/twirssi.pl index 68dfac8..331715c 100644 --- a/twirssi.pl +++ b/twirssi.pl @@ -12,7 +12,7 @@ $Data::Dumper::Indent = 1; use vars qw($VERSION %IRSSI); $VERSION = "2.2.5beta"; -my ($REV) = '$Rev: 676 $' =~ /(\d+)/; +my ($REV) = '$Rev: 687 $' =~ /(\d+)/; %IRSSI = ( authors => 'Dan Boger', contact => 'zigdon@gmail.com', @@ -21,7 +21,7 @@ my ($REV) = '$Rev: 676 $' =~ /(\d+)/; . 'Can optionally set your bitlbee /away message to same', license => 'GNU GPL v2', url => 'http://twirssi.com', - changed => '$Date: 2009-07-22 11:05:52 -0700 (Wed, 22 Jul 2009) $', + changed => '$Date: 2009-08-07 01:24:53 -0700 (Fri, 07 Aug 2009) $', ); my $window; @@ -495,9 +495,19 @@ sub cmd_login { $twit = "Net::$service"->new( username => $user, password => $pass, - source => "twirssi" + source => "twirssi", + ssl => Irssi::settings_get_bool("twirssi_avoid_ssl") ? 0 : 1, ); + unless ($twit) { + ¬ice("Failed to create Net::$service object! Aborting."); + return; + } + + if ( my $timeout = Irssi::settings_get_int("twitter_timeout") ) { + $twit->ua->timeout($timeout); + } + unless ( $twit->verify_credentials() ) { ¬ice("Login as $user\@$service failed"); $twit = undef; @@ -909,7 +919,9 @@ sub do_updates { printf $fh "id:%u account:%s type:last_id timeline\n", $new_poll_id, $username; - print scalar localtime, " - Polling for replies" if &debug; + print scalar localtime, " - Polling for replies since ", + $id_map{__last_id}{$username}{reply} + if &debug; $new_poll_id = 0; eval { if ( $id_map{__last_id}{$username}{reply} ) @@ -1031,6 +1043,7 @@ sub monitor_child { # pretend if ( open FILE, $filename ) { + binmode FILE, ":utf8"; my @lines; my %new_cache; while () { @@ -1161,8 +1174,16 @@ sub monitor_child { } if (/^-- (\d+)$/) { - ($new_last_poll) = ($1); - last; + $new_last_poll = $1; + if ( $new_last_poll >= $last_poll ) { + last; + } else { + print "Impossible! ", + "new_last_poll=$new_last_poll < last_poll=$last_poll!" + if &debug; + undef $new_last_poll; + next; + } } my ( $f, $t ) = split ' ', $_; $nicks{$f} = $friends{$f} = $t; @@ -1499,6 +1520,7 @@ Irssi::settings_add_str( "twirssi", "twirssi_replies_store", ".irssi/scripts/twirssi.json" ); Irssi::settings_add_int( "twirssi", "twitter_friends_poll", 600 ); +Irssi::settings_add_int( "twirssi", "twitter_timeout", 30 ); Irssi::settings_add_bool( "twirssi", "twirssi_upgrade_beta", 0 ); Irssi::settings_add_bool( "twirssi", "tweet_to_away", 0 ); @@ -1513,6 +1535,7 @@ Irssi::settings_add_bool( "twirssi", "twirssi_notify_timeouts", 1 ); Irssi::settings_add_bool( "twirssi", "twirssi_hilights", 1 ); Irssi::settings_add_bool( "twirssi", "twirssi_always_shorten", 0 ); Irssi::settings_add_bool( "twirssi", "tweet_window_input", 0 ); +Irssi::settings_add_bool( "twirssi", "twirssi_avoid_ssl", 0 ); $last_poll = time - &get_poll_time; $window = Irssi::window_find_name( Irssi::settings_get_str('twitter_window') );