- print "Loading Net::$service" if &debug;
- eval "use Net::$service 3.05";
- if ($@) {
- ¬ice(
- "Failed to load Net::$service when trying to log in as $user: $@");
- return;
- }
-
- if ( Irssi::settings_get_bool("twirssi_use_oauth") ) {
- print "Attempting OAuth for $user\@$service" if &debug;
- eval {
- $twit = "Net::$service"->new(
- traits => [ 'API::REST', 'OAuth' ],
- consumer_key => 'BZVAvBma4GxdiRwXIvbnw',
- consumer_secret => '0T5kahwLyb34vciGZsgkA9lsjtGCQ05vxVE2APXM',
- source => "twirssi",
- ssl => Irssi::settings_get_bool("twirssi_avoid_ssl") ? 0 : 1,
- );
- };
-
- if ( $twit ) {
- if (open( OAUTH, Irssi::settings_get_str("twirssi_oauth_store") ) ) {
- while (<OAUTH>) {
- 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 ) {
- ¬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 <pin>");
- ¬ice($twit->get_authorization_url);
-
- $oauth{pending}{"$user\@$service"} = $twit;
- return;
- }
- }
- } else {
- $twit = "Net::$service"->new(
- username => $user,
- password => $pass,
- source => "twirssi",
- ssl => Irssi::settings_get_bool("twirssi_avoid_ssl") ? 0 : 1,
- );
- }