X-Git-Url: https://git.sommitrealweird.co.uk/twirssi-net-twitter-lite.git/blobdiff_plain/b8bd67a04b4277e70e18510ab4e055925e1775b3..4c7ce5a9949947f41be83098abea4bf5f5d71862:/twirssi.pl diff --git a/twirssi.pl b/twirssi.pl index 4f4ef64..45faf6f 100644 --- a/twirssi.pl +++ b/twirssi.pl @@ -8,7 +8,7 @@ use LWP::Simple; use Data::Dumper; use Encode; use POSIX qw/:sys_wait_h/; -use Net::Twitter qw/3.05/; +use Net::Twitter::Lite $Data::Dumper::Indent = 1; use vars qw($VERSION %IRSSI); @@ -509,77 +509,10 @@ sub cmd_login { } $defservice = $service = ucfirst lc $service; - if ( $service eq 'Twitter' - and Irssi::settings_get_bool("twirssi_use_oauth") ) - { - print "Attempting OAuth for $user\@$service" if &debug; - eval { - if ( $service eq 'Identica' ) - { - $twit = Net::Twitter->new( - identica => 1, - traits => [ 'API::REST', 'API::Search' ], - source => "twirssi", - ssl => !Irssi::settings_get_bool("twirssi_avoid_ssl"), - ); - } else { - $twit = Net::Twitter->new( - traits => [ 'API::REST', 'OAuth', 'API::Search' ], - consumer_key => 'BZVAvBma4GxdiRwXIvbnw', - consumer_secret => - '0T5kahwLyb34vciGZsgkA9lsjtGCQ05vxVE2APXM', - source => "twirssi", - ssl => !Irssi::settings_get_bool("twirssi_avoid_ssl"), - ); - } - }; - - if ($twit) { - if ( open( OAUTH, Irssi::settings_get_str("twirssi_oauth_store") ) ) - { - while () { - chomp; - next unless m/$user\@$service (\S+) (\S+)/i; - print "Trying cached oauth creds for $user\@$service" - if &debug; - $twit->access_token($1); - $twit->access_token_secret($2); - last; - } - close OAUTH; - } - - unless ( $twit->authorized ) { - my $url; - eval { $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_oauth $user\@$service "); - ¬ice($url); - - $oauth{pending}{"$user\@$service"} = $twit; - return; - } - } - } else { - $twit = Net::Twitter->new( - $service eq 'Identica' ? ( identica => 1 ) : (), - username => $user, - password => $pass, - source => "twirssi", - ssl => Irssi::settings_get_bool("twirssi_avoid_ssl") ? 0 : 1, - ); - } + $twit = Net::Twitter::Lite->new( + username => $user, + password => $pass, + ); unless ($twit) { ¬ice("Failed to create object! Aborting."); @@ -693,7 +626,7 @@ sub verify_twitter_object { $poll = Irssi::timeout_add( &get_poll_time * 1000, \&get_updates, "" ); ¬ice("Logged in as $user\@$service, loading friends list..."); &load_friends(); - ¬ice( "loaded friends: ", scalar keys %friends ); + ¬ice( "loaded friends: ". scalar keys %friends ); if ( Irssi::settings_get_bool("twirssi_first_run") ) { Irssi::settings_set_bool( "twirssi_first_run", 0 ); } @@ -1569,7 +1502,7 @@ sub monitor_child { } if ( not $failwhale and time - $last_poll > 60 * 60 ) { - foreach my $whale ( + &ccrap( q{ v v v}, q{ | | v | v}, q{ | .-, | | |}, @@ -1578,10 +1511,7 @@ sub monitor_child { q{ \\ a |}, q{ ',.__. ,__.-'/}, q{ '--/_.'----'`} - ) - { - &ccrap($whale); - } + ); $failwhale = 1; } @@ -1596,11 +1526,15 @@ sub debug { } sub notice { - $window->print( "%R***%n @_", MSGLEVEL_PUBLIC ); + foreach my $msg (@_) { + $window->print( "%R***%n $msg", MSGLEVEL_PUBLIC ); + } } sub ccrap { - $window->print( "%R***%n @_", MSGLEVEL_CLIENTCRAP ); + foreach my $msg (@_) { + $window->print( "%R***%n $msg", MSGLEVEL_CLIENTCRAP ); + } } sub update_away { @@ -1810,7 +1744,7 @@ sub get_text { if ( exists $tweet->{retweeted_status} ) { $text = "RT \@$tweet->{retweeted_status}{user}{screen_name}: " . "$tweet->{retweeted_status}{text}"; - } elsif ( $object->isa('Net::Twitter') ) { + } elsif ( $object->isa('Net::Twitter::Lite') ) { $text .= " -- http://twitter.com/$tweet->{user}{screen_name}" . "/status/$tweet->{id}"; } @@ -1933,8 +1867,8 @@ if ($window) { ¬ice( "Twirssi v$VERSION; " . ( - $Net::Twitter::VERSION - ? "Net::Twitter v$Net::Twitter::VERSION. " + $Net::Twitter::Lite::VERSION + ? "Net::Twitter v$Net::Twitter::Lite::VERSION. " : "" ) . ( @@ -1990,10 +1924,9 @@ if ($window) { ); Irssi::signal_add_last( 'complete word' => \&sig_complete ); - ¬ice(" %Y<%C(%B^%C)%N TWIRSSI v%R$VERSION%N"); - ¬ice(" %C(_(\\%N http://twirssi.com/ for full docs"); - ¬ice( - " %Y||%C `%N Log in with /twitter_login, send updates with /tweet"); + ¬ice(" %Y<%C(%B^%C)%N TWIRSSI v%R$VERSION%N", + " %C(_(\\%N http://twirssi.com/ for full docs", + " %Y||%C `%N Log in with /twitter_login, send updates with /tweet"); my $file = Irssi::settings_get_str("twirssi_replies_store"); if ( $file and -r $file ) {