10 $Data::Dumper::Indent = 1;
12 use vars qw($VERSION %IRSSI);
14 $VERSION = "2.3.3beta";
16 authors => 'Dan Boger',
17 contact => 'zigdon@gmail.com',
19 description => 'Send twitter updates using /tweet. '
20 . 'Can optionally set your bitlbee /away message to same',
21 license => 'GNU GPL v2',
22 url => 'http://twirssi.com',
23 changed => '$Date: 2009-08-07 01:24:53 -0700 (Fri, 07 Aug 2009) $',
33 my $last_friends_poll = 0;
41 my %fix_replies_index;
43 my %irssi_to_mirc_colors = (
63 my ( $data, $server, $win ) = @_;
65 return unless &logged_in($twit);
67 my ( $target, $text ) = split ' ', $data, 2;
68 unless ( $target and $text ) {
69 ¬ice("Usage: /dm <nick> <message>");
73 &cmd_direct_as( "$user $data", $server, $win );
77 my ( $data, $server, $win ) = @_;
79 return unless &logged_in($twit);
81 my ( $username, $target, $text ) = split ' ', $data, 3;
82 unless ( $username and $target and $text ) {
83 ¬ice("Usage: /dm_as <username> <nick> <message>");
87 return unless $username = &valid_username($username);
90 if ( $twits{$username}
91 ->new_direct_message( { user => $target, text => $text } ) )
93 ¬ice("DM sent to $target: $text");
94 $nicks{$target} = time;
98 $error = JSON::Any->jsonToObj( $twits{$username}->get_error() );
99 $error = $error->{error};
101 die $error if $error;
102 ¬ice("DM to $target failed");
107 ¬ice("DM caused an error: $@");
113 my ( $data, $server, $win ) = @_;
115 return unless &logged_in($twit);
117 $data =~ s/^\s+|\s+$//;
119 ¬ice("Usage: /retweet <nick[:num]> [comment]");
123 my ( $id, $data ) = split ' ', $data, 2;
125 &cmd_retweet_as( "$user $id $data", $server, $win );
129 my ( $data, $server, $win ) = @_;
131 unless ( Irssi::settings_get_bool("twirssi_track_replies") ) {
132 ¬ice("twirssi_track_replies is required in order to reteet.");
136 return unless &logged_in($twit);
138 $data =~ s/^\s+|\s+$//;
139 my ( $username, $id, $data ) = split ' ', $data, 3;
142 ¬ice("Usage: /retweet_as <username> <nick[:num]> [comment]");
146 return unless $username = &valid_username($username);
149 $id =~ s/[^\w\d\-:]+//g;
150 ( $nick, $id ) = split /:/, $id;
151 unless ( exists $id_map{ lc $nick } ) {
152 ¬ice("Can't find a tweet from $nick to retweet!");
156 $id = $id_map{__indexes}{$nick} unless $id;
157 unless ( $id_map{ lc $nick }[$id] ) {
158 ¬ice("Can't find a tweet numbered $id from $nick to retweet!");
162 unless ( $id_map{__tweets}{ lc $nick }[$id] ) {
163 ¬ice("The text of this tweet isn't saved, sorry!");
167 # Irssi::settings_add_str( "twirssi", "twirssi_retweet_format", 'RT $n: $t ${-- $c$}' );
168 my $text = Irssi::settings_get_str("twirssi_retweet_format");
169 $text =~ s/\$n/\@$nick/g;
171 $text =~ s/\${|\$}//g;
172 $text =~ s/\$c/$data/;
174 $text =~ s/\${.*?\$}//;
176 $text =~ s/\$t/$id_map{__tweets}{ lc $nick }[$id]/;
178 my $modified = $data;
179 $data = &shorten($text);
181 return if &too_long($data);
186 $success = $twits{$username}->update(
190 # in_reply_to_status_id => $id_map{ lc $nick }[$id]
194 $success = $twits{$username}->retweet(
196 id => $id_map{ lc $nick }[$id]
200 ¬ice("Update failed") unless $success;
202 return unless $success;
205 ¬ice("Update caused an error: $@. Aborted");
209 foreach ( $data =~ /@([-\w]+)/ ) {
213 ¬ice("Retweet sent");
217 my ( $data, $server, $win ) = @_;
219 return unless &logged_in($twit);
221 $data =~ s/^\s+|\s+$//;
223 ¬ice("Usage: /tweet <update>");
227 &cmd_tweet_as( "$user\@$defservice $data", $server, $win );
231 my ( $data, $server, $win ) = @_;
233 return unless &logged_in($twit);
235 $data =~ s/^\s+|\s+$//;
236 $data =~ s/\s\s+/ /g;
237 my ( $username, $data ) = split ' ', $data, 2;
239 unless ( $username and $data ) {
240 ¬ice("Usage: /tweet_as <username> <update>");
244 return unless $username = &valid_username($username);
246 $data = &shorten($data);
248 return if &too_long($data);
252 unless ( $twits{$username}->update($data) )
254 ¬ice("Update failed");
258 return unless $success;
261 ¬ice("Update caused an error: $@. Aborted.");
265 foreach ( $data =~ /@([-\w]+)/ ) {
269 my $away = &update_away($data);
271 ¬ice( "Update sent" . ( $away ? " (and away msg set)" : "" ) );
275 my ( $data, $server, $win ) = @_;
277 return unless &logged_in($twit);
279 $data =~ s/^\s+|\s+$//;
281 ¬ice("Usage: /reply <nick[:num]> <update>");
285 my ( $id, $data ) = split ' ', $data, 2;
286 unless ( $id and $data ) {
287 ¬ice("Usage: /reply <nick[:num]> <update>");
291 &cmd_reply_as( "$user $id $data", $server, $win );
295 my ( $data, $server, $win ) = @_;
297 unless ( Irssi::settings_get_bool("twirssi_track_replies") ) {
298 ¬ice("twirssi_track_replies is required in order to reply to "
299 . "specific tweets. Either enable it, or just use /tweet "
300 . "\@username <text>." );
304 return unless &logged_in($twit);
306 $data =~ s/^\s+|\s+$//;
307 my ( $username, $id, $data ) = split ' ', $data, 3;
309 unless ( $username and $data ) {
310 ¬ice("Usage: /reply_as <username> <nick[:num]> <update>");
314 return unless $username = &valid_username($username);
317 $id =~ s/[^\w\d\-:]+//g;
318 ( $nick, $id ) = split /:/, $id;
319 unless ( exists $id_map{ lc $nick } ) {
320 ¬ice("Can't find a tweet from $nick to reply to!");
324 $id = $id_map{__indexes}{$nick} unless $id;
325 unless ( $id_map{ lc $nick }[$id] ) {
326 ¬ice("Can't find a tweet numbered $id from $nick to reply to!");
330 if ( Irssi::settings_get_bool("twirssi_replies_autonick") ) {
332 # remove any @nick at the beginning of the reply, as we'll add it anyway
333 $data =~ s/^\s*\@?$nick\s*//;
334 $data = "\@$nick " . $data;
337 $data = &shorten($data);
339 return if &too_long($data);
344 $twits{$username}->update(
347 in_reply_to_status_id => $id_map{ lc $nick }[$id]
352 ¬ice("Update failed");
356 return unless $success;
359 ¬ice("Update caused an error: $@. Aborted");
363 foreach ( $data =~ /@([-\w]+)/ ) {
367 my $away = &update_away($data);
369 ¬ice( "Update sent" . ( $away ? " (and away msg set)" : "" ) );
373 my ( $usage_str, $api_name, $post_ref ) = @_;
376 my ( $data, $server, $win ) = @_;
378 return unless &logged_in($twit);
380 $data =~ s/^\s+|\s+$//;
382 ¬ice("Usage: $usage_str");
388 unless ( $twit->$api_name($data) )
390 ¬ice("$api_name failed");
394 return unless $success;
397 ¬ice("$api_name caused an error. Aborted.");
401 &$post_ref($data) if $post_ref;
406 my ( $data, $server, $win ) = @_;
408 $data =~ s/^\s+|\s+$//g;
409 $data = &normalize_username($data);
410 if ( exists $twits{$data} ) {
411 ¬ice("Switching to $data");
412 $twit = $twits{$data};
413 if ( $data =~ /(.*)\@(.*)/ ) {
417 ¬ice("Couldn't figure out what service '$data' is on");
420 ¬ice("Unknown user $data");
425 my ( $data, $server, $win ) = @_;
427 $data =~ s/^\s+|\s+$//g;
428 $data = $user unless $data;
429 return unless $data = &valid_username($data);
431 ¬ice("Logging out $data...");
432 $twits{$data}->end_session();
433 delete $twits{$data};
436 &cmd_switch( ( keys %twits )[0], $server, $win );
438 Irssi::timeout_remove($poll) if $poll;
444 my ( $data, $server, $win ) = @_;
447 ( $user, $pass ) = split ' ', $data, 2;
449 ¬ice("usage: /twitter_login <username>[\@<service>] <password>");
452 } elsif ( my $autouser = Irssi::settings_get_str("twitter_usernames")
453 and my $autopass = Irssi::settings_get_str("twitter_passwords") )
455 my @user = split /\s*,\s*/, $autouser;
456 my @pass = split /\s*,\s*/, $autopass;
458 # if a password ends with a '\', it was meant to escape the comma, and
459 # it should be concatinated with the next one
463 while ( $p =~ /\\$/ and @pass ) {
464 $p .= "," . shift @pass;
469 if ( @user != @unescaped ) {
470 ¬ice("Number of usernames doesn't match "
471 . "the number of passwords - auto-login failed" );
474 while ( @user and @unescaped ) {
476 $p = shift @unescaped;
482 ¬ice("/twitter_login requires either a username and password "
483 . "or twitter_usernames and twitter_passwords to be set." );
487 %friends = %nicks = ();
490 if ( $user =~ /^(.*)@(twitter|identica)$/ ) {
491 ( $user, $service ) = ( $1, $2 );
493 $service = Irssi::settings_get_str("twirssi_default_service");
495 $defservice = $service = ucfirst lc $service;
497 eval "use Net::$service 3.0";
500 "Failed to load Net::$service when trying to log in as $user: $@");
504 $twit = "Net::$service"->new(
508 ssl => Irssi::settings_get_bool("twirssi_avoid_ssl") ? 0 : 1,
512 ¬ice("Failed to create Net::$service object! Aborting.");
516 if ( my $timeout = Irssi::settings_get_int("twitter_timeout")
517 and $twit->can('ua') )
519 $twit->ua->timeout($timeout);
520 ¬ice("Twitter timeout set to $timeout");
523 unless ( $twit->verify_credentials() ) {
524 ¬ice("Login as $user\@$service failed");
526 if ( not Irssi::settings_get_bool("twirssi_avoid_ssl") ) {
528 "It's possible you're missing one of the modules required for "
529 . "SSL logins. Try setting twirssi_avoid_ssl to on. See "
530 . "http://cpansearch.perl.org/src/GAAS/libwww-perl-5.831/README.SSL "
531 . "for the detailed requirements." );
536 &cmd_switch( ( keys %twits )[0], $server, $win );
542 my $rate_limit = $twit->rate_limit_status();
543 if ( $rate_limit and $rate_limit->{remaining_hits} < 1 ) {
545 "Rate limit exceeded, try again after $rate_limit->{reset_time}"
551 $twits{"$user\@$service"} = $twit;
552 Irssi::timeout_remove($poll) if $poll;
553 $poll = Irssi::timeout_add( &get_poll_time * 1000, \&get_updates, "" );
554 ¬ice("Logged in as $user\@$service, loading friends list...");
556 ¬ice( "loaded friends: ", scalar keys %friends );
557 if ( Irssi::settings_get_bool("twirssi_first_run") ) {
558 Irssi::settings_set_bool( "twirssi_first_run", 0 );
564 ¬ice("Login failed");
569 my ( $data, $server, $win ) = @_;
572 ¬ice("Usage: /twitter_add_follow_extra <username>");
576 $data =~ s/^\s+|\s+$//;
580 if ( exists $id_map{__fixreplies}{"$user\@$defservice"}{$data} ) {
581 ¬ice("Already following all replies by \@$data");
585 $id_map{__fixreplies}{"$user\@$defservice"}{$data} = 1;
586 ¬ice("Will now follow all replies by \@$data");
590 my ( $data, $server, $win ) = @_;
593 ¬ice("Usage: /twitter_del_follow_extra <username>");
597 $data =~ s/^\s+|\s+$//;
601 unless ( exists $id_map{__fixreplies}{"$user\@$defservice"}{$data} ) {
602 ¬ice("Wasn't following all replies by \@$data");
606 delete $id_map{__fixreplies}{"$user\@$defservice"}{$data};
607 ¬ice("Will no longer follow all replies by \@$data");
610 sub cmd_list_follow {
611 my ( $data, $server, $win ) = @_;
614 foreach my $suser ( sort keys %{ $id_map{__fixreplies} } ) {
616 foreach my $fruser ( sort keys %{ $id_map{__fixreplies}{$suser} } ) {
617 $frusers = $frusers ? "$frusers, $fruser" : $fruser;
621 ¬ice("Following all replies as \@$suser: $frusers");
626 ¬ice("Not following all replies by anyone");
631 my ( $data, $server, $win ) = @_;
633 unless ( $twit and $twit->can('search') ) {
634 ¬ice("ERROR: Your version of Net::Twitter ($Net::Twitter::VERSION) "
635 . "doesn't support searches." );
639 $data =~ s/^\s+|\s+$//;
643 ¬ice("Usage: /twitter_subscribe <topic>");
647 if ( exists $id_map{__searches}{"$user\@$defservice"}{$data} ) {
648 ¬ice("Already had a subscription for '$data'");
652 $id_map{__searches}{"$user\@$defservice"}{$data} = 1;
653 ¬ice("Added subscription for '$data'");
657 my ( $data, $server, $win ) = @_;
659 unless ( $twit and $twit->can('search') ) {
660 ¬ice("ERROR: Your version of Net::Twitter ($Net::Twitter::VERSION) "
661 . "doesn't support searches." );
664 $data =~ s/^\s+|\s+$//;
668 ¬ice("Usage: /twitter_unsubscribe <topic>");
672 unless ( exists $id_map{__searches}{"$user\@$defservice"}{$data} ) {
673 ¬ice("No subscription found for '$data'");
677 delete $id_map{__searches}{"$user\@$defservice"}{$data};
678 ¬ice("Removed subscription for '$data'");
681 sub cmd_list_search {
682 my ( $data, $server, $win ) = @_;
685 foreach my $suser ( sort keys %{ $id_map{__searches} } ) {
687 foreach my $topic ( sort keys %{ $id_map{__searches}{$suser} } ) {
688 $topics = $topics ? "$topics, $topic" : $topic;
692 ¬ice("Search subscriptions for \@$suser: $topics");
697 ¬ice("No search subscriptions set up");
702 my ( $data, $server, $win ) = @_;
704 my $loc = Irssi::settings_get_str("twirssi_location");
706 ¬ice("$loc isn't writable, can't upgrade."
707 . " Perhaps you need to /set twirssi_location?" );
712 unless ( $data or Irssi::settings_get_bool("twirssi_upgrade_beta") ) {
713 eval { use Digest::MD5; };
716 ¬ice("Failed to load Digest::MD5."
717 . " Try '/twirssi_upgrade nomd5' to skip MD5 verification" );
721 $md5 = get("http://twirssi.com/md5sum");
725 ¬ice("Failed to download md5sum from peeron! Aborting.");
729 unless ( open( CUR, $loc ) ) {
730 ¬ice("Failed to read $loc."
731 . " Check that /set twirssi_location is set to the correct location."
736 my $cur_md5 = Digest::MD5::md5_hex(<CUR>);
739 if ( $cur_md5 eq $md5 ) {
740 ¬ice("Current twirssi seems to be up to date.");
746 Irssi::settings_get_bool("twirssi_upgrade_beta")
747 ? "http://github.com/zigdon/twirssi/raw/master/twirssi.pl"
748 : "http://twirssi.com/twirssi.pl";
749 ¬ice("Downloading twirssi from $URL");
750 LWP::Simple::getstore( $URL, "$loc.upgrade" );
752 unless ( -s "$loc.upgrade" ) {
753 ¬ice("Failed to save $loc.upgrade."
754 . " Check that /set twirssi_location is set to the correct location."
759 unless ( $data or Irssi::settings_get_bool("twirssi_upgrade_beta") ) {
760 unless ( open( NEW, "$loc.upgrade" ) ) {
761 ¬ice("Failed to read $loc.upgrade."
762 . " Check that /set twirssi_location is set to the correct location."
767 my $new_md5 = Digest::MD5::md5_hex(<NEW>);
770 if ( $new_md5 ne $md5 ) {
771 ¬ice("MD5 verification failed. expected $md5, got $new_md5");
776 rename $loc, "$loc.backup"
777 or ¬ice("Failed to back up $loc: $!. Aborting")
779 rename "$loc.upgrade", $loc
780 or ¬ice("Failed to rename $loc.upgrade: $!. Aborting")
783 my ( $dir, $file ) = ( $loc =~ m{(.*)/([^/]+)$} );
784 if ( -e "$dir/autorun/$file" ) {
785 ¬ice("Updating $dir/autorun/$file");
786 unlink "$dir/autorun/$file"
787 or ¬ice("Failed to remove old $file from autorun: $!");
788 symlink "../$file", "$dir/autorun/$file"
789 or ¬ice("Failed to create symlink in autorun directory: $!");
792 ¬ice("Download complete. Reload twirssi with /script load $file");
801 while ( $page < 11 and $cursor ne "0" )
803 print $fh "type:debug Loading friends page $page...\n"
804 if ( $fh and &debug );
806 if ( ref $twit =~ /^Net::Twitter/ ) {
807 $friends = $twit->friends( { cursor => $cursor } );
808 last unless $friends;
809 $cursor = $friends->{next_cursor};
810 $friends = $friends->{users};
812 $friends = $twit->friends( { page => $page } );
813 last unless $friends;
815 $new_friends{ $_->{screen_name} } = time foreach @$friends;
821 print $fh "type:debug Error during friends list update. Aborted.\n";
825 my ( $added, $removed ) = ( 0, 0 );
826 print $fh "type:debug Scanning for new friends...\n" if ( $fh and &debug );
827 foreach ( keys %new_friends ) {
828 next if exists $friends{$_};
833 print $fh "type:debug Scanning for removed friends...\n"
834 if ( $fh and &debug );
835 foreach ( keys %friends ) {
836 next if exists $new_friends{$_};
841 return ( $added, $removed );
845 print scalar localtime, " - get_updates starting" if &debug;
848 Irssi::window_find_name( Irssi::settings_get_str('twitter_window') );
851 ->print( "Can't find a window named '"
852 . Irssi::settings_get_str('twitter_window')
853 . "'. Create it or change the value of twitter_window" );
856 return unless &logged_in($twit);
858 my ( $fh, $filename ) = File::Temp::tempfile();
859 binmode( $fh, ":utf8" );
862 if ($child_pid) { # parent
863 Irssi::timeout_add_once( 5000, 'monitor_child',
864 [ "$filename.done", 0 ] );
865 Irssi::pidwait_add($child_pid);
866 } elsif ( defined $child_pid ) { # child
875 foreach ( keys %twits ) {
876 $error++ unless &do_updates( $fh, $_, $twits{$_}, \%context_cache );
878 if ( $id_map{__fixreplies}{$_} ) {
879 my @frusers = sort keys %{ $id_map{__fixreplies}{$_} };
882 unless &get_timeline( $fh, $frusers[ $fix_replies_index{$_} ],
883 $_, $twits{$_}, \%context_cache );
885 $fix_replies_index{$_}++;
886 $fix_replies_index{$_} = 0
887 if $fix_replies_index{$_} >= @frusers;
888 print $fh "id:$fix_replies_index{$_} ",
889 "account:$_ type:fix_replies_index\n";
893 print $fh "__friends__\n";
895 time - $last_friends_poll >
896 Irssi::settings_get_int('twitter_friends_poll') )
898 print $fh "__updated ", time, "\n";
899 my ( $added, $removed ) = &load_friends($fh);
900 if ( $added + $removed ) {
901 print $fh "type:debug %R***%n Friends list updated: ",
903 sprintf( "%d added", $added ),
904 sprintf( "%d removed", $removed ) ),
909 foreach ( sort keys %friends ) {
910 print $fh "$_ $friends{$_}\n";
914 print $fh "type:debug Update encountered errors. Aborted\n";
915 print $fh "-- $last_poll";
917 print $fh "-- $new_poll";
920 rename $filename, "$filename.done";
923 &ccrap("Failed to fork for updating: $!");
925 print scalar localtime, " - get_updates ends" if &debug;
929 my ( $fh, $username, $obj, $cache ) = @_;
931 my $rate_limit = $obj->rate_limit_status();
932 if ( $rate_limit and $rate_limit->{remaining_hits} < 1 ) {
933 ¬ice("Rate limit exceeded for $username");
937 print scalar localtime, " - Polling for updates for $username" if &debug;
941 if ( $id_map{__last_id}{$username}{timeline} )
943 $tweets = $obj->home_timeline( { count => 100 } );
945 $tweets = $obj->home_timeline();
950 print $fh "type:debug Error during home_timeline call: Aborted.\n";
951 print $fh "type:debug : $_\n" foreach split /\n/, Dumper($@);
955 unless ( ref $tweets ) {
956 if ( $obj->can("get_error") ) {
957 my $error = "Unknown error";
958 eval { $error = JSON::Any->jsonToObj( $obj->get_error() ) };
959 unless ($@) { $error = $obj->get_error() }
961 "type:debug API Error during home_timeline call: Aborted\n";
962 print $fh "type:debug : $_\n" foreach split /\n/, Dumper($error);
966 "type:debug API Error during home_timeline call. Aborted.\n";
971 foreach my $t ( reverse @$tweets ) {
972 my $text = decode_entities( $t->{text} );
973 $text =~ s/[\n\r]/ /g;
975 if ( Irssi::settings_get_bool("show_reply_context")
976 and $t->{in_reply_to_screen_name} ne $username
977 and $t->{in_reply_to_screen_name}
978 and not exists $friends{ $t->{in_reply_to_screen_name} } )
980 $nicks{ $t->{in_reply_to_screen_name} } = time;
982 unless ( $cache->{ $t->{in_reply_to_status_id} } ) {
984 $cache->{ $t->{in_reply_to_status_id} } =
985 $obj->show_status( $t->{in_reply_to_status_id} );
989 $context = $cache->{ $t->{in_reply_to_status_id} };
992 my $ctext = decode_entities( $context->{text} );
993 $ctext =~ s/[\n\r]/ /g;
994 if ( $context->{truncated} and ref($obj) ne 'Net::Identica' ) {
996 " -- http://twitter.com/$context->{user}{screen_name}"
997 . "/status/$context->{id}";
999 printf $fh "id:%s account:%s nick:%s type:tweet %s\n",
1000 $context->{id}, $username,
1001 $context->{user}{screen_name}, $ctext;
1006 if $t->{user}{screen_name} eq $username
1007 and not Irssi::settings_get_bool("show_own_tweets");
1008 if ( $t->{truncated} and ref($obj) ne 'Net::Identica' ) {
1009 $text .= " -- http://twitter.com/$t->{user}{screen_name}"
1010 . "/status/$t->{id}";
1012 printf $fh "id:%s account:%s nick:%s type:%s %s\n",
1013 $t->{id}, $username, $t->{user}{screen_name}, $reply, $text;
1014 $new_poll_id = $t->{id} if $new_poll_id < $t->{id};
1016 printf $fh "id:%s account:%s type:last_id timeline\n",
1017 $new_poll_id, $username;
1019 print scalar localtime, " - Polling for replies since ",
1020 $id_map{__last_id}{$username}{reply}
1024 if ( $id_map{__last_id}{$username}{reply} )
1026 $tweets = $obj->replies(
1027 { since_id => $id_map{__last_id}{$username}{reply} } )
1030 $tweets = $obj->replies() || [];
1035 print $fh "type:debug Error during replies call. Aborted.\n";
1039 foreach my $t ( reverse @$tweets ) {
1041 if exists $friends{ $t->{user}{screen_name} };
1043 my $text = decode_entities( $t->{text} );
1044 $text =~ s/[\n\r]/ /g;
1045 if ( $t->{truncated} ) {
1046 $text .= " -- http://twitter.com/$t->{user}{screen_name}"
1047 . "/status/$t->{id}";
1049 printf $fh "id:%s account:%s nick:%s type:tweet %s\n",
1050 $t->{id}, $username, $t->{user}{screen_name}, $text;
1051 $new_poll_id = $t->{id} if $new_poll_id < $t->{id};
1053 printf $fh "id:%s account:%s type:last_id reply\n", $new_poll_id, $username;
1055 print scalar localtime, " - Polling for DMs" if &debug;
1058 if ( $id_map{__last_id}{$username}{dm} )
1060 $tweets = $obj->direct_messages(
1061 { since_id => $id_map{__last_id}{$username}{dm} } )
1064 $tweets = $obj->direct_messages() || [];
1069 print $fh "type:debug Error during direct_messages call. Aborted.\n";
1073 foreach my $t ( reverse @$tweets ) {
1074 my $text = decode_entities( $t->{text} );
1075 $text =~ s/[\n\r]/ /g;
1076 printf $fh "id:%s account:%s nick:%s type:dm %s\n",
1077 $t->{id}, $username, $t->{sender_screen_name}, $text;
1078 $new_poll_id = $t->{id} if $new_poll_id < $t->{id};
1080 printf $fh "id:%s account:%s type:last_id dm\n", $new_poll_id, $username;
1082 print scalar localtime, " - Polling for subscriptions" if &debug;
1083 if ( $obj->can('search') and $id_map{__searches}{$username} ) {
1085 foreach my $topic ( sort keys %{ $id_map{__searches}{$username} } ) {
1086 print $fh "type:debug searching for $topic since ",
1087 "$id_map{__searches}{$username}{$topic}\n";
1089 $search = $obj->search(
1092 since_id => $id_map{__searches}{$username}{$topic}
1099 "type:debug Error during search($topic) call. Aborted.\n";
1103 unless ( $search->{max_id} ) {
1104 print $fh "type:debug Invalid search results when searching",
1105 " for $topic. Aborted.\n";
1109 $id_map{__searches}{$username}{$topic} = $search->{max_id};
1110 printf $fh "id:%s account:%s type:searchid topic:%s\n",
1111 $search->{max_id}, $username, $topic;
1113 foreach my $t ( reverse @{ $search->{results} } ) {
1114 my $text = decode_entities( $t->{text} );
1115 $text =~ s/[\n\r]/ /g;
1116 printf $fh "id:%s account:%s nick:%s type:search topic:%s %s\n",
1117 $t->{id}, $username, $t->{from_user}, $topic, $text;
1118 $new_poll_id = $t->{id}
1120 or $t->{id} < $new_poll_id;
1125 print scalar localtime, " - Done" if &debug;
1131 my ( $fh, $target, $username, $obj, $cache ) = @_;
1133 my $last_id = $id_map{__last_id}{$username}{$target};
1135 print $fh "type:debug get_timeline("
1136 . "$fix_replies_index{$username}=$target > $last_id) started."
1137 . " username = $username\n";
1139 $tweets = $obj->user_timeline(
1142 ( $last_id ? ( since_id => $last_id ) : () ),
1149 "type:debug Error during user_timeline($target) call: Aborted.\n";
1150 print $fh "type:debug : $_\n" foreach split /\n/, Dumper($@);
1156 "type:debug user_timeline($target) call returned undef! Aborted\n";
1160 foreach my $t ( reverse @$tweets ) {
1161 my $text = decode_entities( $t->{text} );
1162 $text =~ s/[\n\r]/ /g;
1163 my $reply = "tweet";
1164 if ( Irssi::settings_get_bool("show_reply_context")
1165 and $t->{in_reply_to_screen_name} ne $username
1166 and $t->{in_reply_to_screen_name}
1167 and not exists $friends{ $t->{in_reply_to_screen_name} } )
1169 $nicks{ $t->{in_reply_to_screen_name} } = time;
1171 unless ( $cache->{ $t->{in_reply_to_status_id} } ) {
1173 $cache->{ $t->{in_reply_to_status_id} } =
1174 $obj->show_status( $t->{in_reply_to_status_id} );
1178 $context = $cache->{ $t->{in_reply_to_status_id} };
1181 my $ctext = decode_entities( $context->{text} );
1182 $ctext =~ s/[\n\r]/ /g;
1183 if ( $context->{truncated} and ref($obj) ne 'Net::Identica' ) {
1185 " -- http://twitter.com/$context->{user}{screen_name}"
1186 . "/status/$context->{id}";
1188 printf $fh "id:%s account:%s nick:%s type:tweet %s\n",
1189 $context->{id}, $username,
1190 $context->{user}{screen_name}, $ctext;
1194 if ( $t->{truncated} and ref($obj) ne 'Net::Identica' ) {
1195 $text .= " -- http://twitter.com/$t->{user}{screen_name}"
1196 . "/status/$t->{id}";
1198 printf $fh "id:%s account:%s nick:%s type:%s %s\n",
1199 $t->{id}, $username, $t->{user}{screen_name}, $reply, $text;
1200 $last_id = $t->{id} if $last_id < $t->{id};
1202 printf $fh "id:%s account:%s type:last_id_fixreplies %s\n",
1203 $last_id, $username, $target;
1210 my $filename = $data->[0];
1211 my $attempt = $data->[1];
1213 print scalar localtime, " - checking child log at $filename ($attempt)"
1215 my ($new_last_poll);
1217 # first time we run we don't want to print out *everything*, so we just
1220 if ( open FILE, $filename ) {
1221 binmode FILE, ":utf8";
1225 last if /^__friends__/;
1226 unless (/\n$/) { # skip partial lines
1227 # print "Skipping partial line: $_" if &debug;
1234 foreach my $key (qw/id account nick type topic/) {
1235 if (s/^$key:(\S+)\s*//) {
1240 if ( $meta{type} and $meta{type} eq 'fix_replies_index' ) {
1241 $fix_replies_index{ $meta{account} } = $meta{id};
1242 print "fix_replies_index for $meta{account} set to $meta{id}"
1247 if ( not $meta{type} or $meta{type} !~ /searchid|last_id/ ) {
1248 if ( exists $meta{id} and exists $new_cache{ $meta{id} } ) {
1252 $new_cache{ $meta{id} } = time;
1254 if ( exists $meta{id} and exists $tweet_cache{ $meta{id} } ) {
1260 $meta{account} =~ s/\@(\w+)$//;
1261 $meta{service} = $1;
1263 lc $meta{service} eq
1264 lc Irssi::settings_get_str("twirssi_default_service") )
1266 $account = "$meta{account}: "
1267 if lc "$meta{account}\@$meta{service}" ne lc
1268 "$user\@$defservice";
1270 $account = "$meta{account}\@$meta{service}: ";
1274 if ( $meta{type} ne 'dm'
1275 and Irssi::settings_get_bool("twirssi_track_replies")
1279 $marker = ( $id_map{__indexes}{ $meta{nick} } + 1 ) % 100;
1280 $id_map{ lc $meta{nick} }[$marker] = $meta{id};
1281 $id_map{__indexes}{ $meta{nick} } = $marker;
1282 $id_map{__tweets}{ lc $meta{nick} }[$marker] = $_;
1283 $marker = ":$marker";
1287 $irssi_to_mirc_colors{ Irssi::settings_get_str("hilight_color") };
1288 my $nick = "\@$meta{account}";
1289 if ( $_ =~ /\Q$nick\E(?:\W|$)/i
1290 and Irssi::settings_get_bool("twirssi_hilights") )
1292 $meta{nick} = "\cC$hilight_color$meta{nick}\cO";
1293 $hilight = MSGLEVEL_HILIGHT;
1296 if ( $meta{type} =~ /tweet|reply/ ) {
1299 ( MSGLEVEL_PUBLIC | $hilight ),
1300 $meta{type}, $account, $meta{nick}, $marker, $_
1302 } elsif ( $meta{type} eq 'search' ) {
1305 ( MSGLEVEL_PUBLIC | $hilight ),
1306 $meta{type}, $account, $meta{topic},
1307 $meta{nick}, $marker, $_
1310 exists $id_map{__searches}{ $meta{account} }{ $meta{topic} }
1312 $id_map{__searches}{ $meta{account} }{ $meta{topic} } )
1314 $id_map{__searches}{ $meta{account} }{ $meta{topic} } =
1317 } elsif ( $meta{type} eq 'dm' ) {
1320 ( MSGLEVEL_MSGS | $hilight ),
1321 $meta{type}, $account, $meta{nick}, $_
1323 } elsif ( $meta{type} eq 'searchid' ) {
1324 print "Search '$meta{topic}' returned id $meta{id}" if &debug;
1327 exists $id_map{__searches}{ $meta{account} }{ $meta{topic} }
1329 $id_map{__searches}{ $meta{account} }{ $meta{topic} } )
1331 $id_map{__searches}{ $meta{account} }{ $meta{topic} } =
1334 print "Search '$meta{topic}' returned invalid id $meta{id}";
1336 } elsif ( $meta{type} eq 'last_id' ) {
1337 $id_map{__last_id}{"$meta{account}\@$meta{service}"}{$_} =
1339 if $id_map{__last_id}{"$meta{account}\@$meta{service}"}{$_} <
1341 } elsif ( $meta{type} eq 'last_id_fixreplies' ) {
1342 $id_map{__last_id}{"$meta{account}\@$meta{service}"}{$_} =
1344 if $id_map{__last_id}{"$meta{account}\@$meta{service}"}{$_} <
1346 } elsif ( $meta{type} eq 'error' ) {
1347 push @lines, [ MSGLEVEL_MSGS, $_ ];
1348 } elsif ( $meta{type} eq 'debug' ) {
1349 print "$_" if &debug,;
1351 print "Unknown line type $meta{type}: $_" if &debug,;
1357 if (/^__updated (\d+)$/) {
1358 $last_friends_poll = $1;
1359 print "Friend list updated" if &debug;
1364 $new_last_poll = $1;
1365 if ( $new_last_poll >= $last_poll ) {
1368 print "Impossible! ",
1369 "new_last_poll=$new_last_poll < last_poll=$last_poll!"
1371 undef $new_last_poll;
1375 my ( $f, $t ) = split ' ', $_;
1376 $nicks{$f} = $friends{$f} = $t;
1379 if ($new_last_poll) {
1380 print "new last_poll = $new_last_poll" if &debug;
1381 print "new last_poll_id = ", Dumper( $id_map{__last_id} ) if &debug;
1383 print "First call, not printing updates" if &debug;
1385 foreach my $line (@lines) {
1386 $window->printformat(
1388 "twirssi_" . $line->[1],
1389 @$line[ 2 .. $#$line - 1 ],
1390 &hilight( $line->[-1] )
1397 or warn "Failed to remove $filename: $!"
1400 # commit the pending cache lines to the actual cache, now that
1401 # we've printed our output
1402 %tweet_cache = ( %tweet_cache, %new_cache );
1404 # keep enough cached tweets, to make sure we don't show duplicates.
1405 foreach ( keys %tweet_cache ) {
1406 next if $tweet_cache{$_} >= $last_poll - 3600;
1407 delete $tweet_cache{$_};
1409 $last_poll = $new_last_poll;
1411 # make sure the pid is removed from the waitpid list
1412 Irssi::pidwait_remove($child_pid);
1414 # and that we don't leave any zombies behind, somehow
1420 Irssi::settings_get_str("twirssi_replies_store") )
1422 if ( open JSON, ">$file" ) {
1423 print JSON JSON::Any->objToJson( \%id_map );
1426 &ccrap("Failed to write replies to $file: $!");
1437 if ( $attempt < 24 ) {
1438 Irssi::timeout_add_once( 5000, 'monitor_child',
1439 [ $filename, $attempt + 1 ] );
1441 print "Giving up on polling $filename" if &debug;
1442 Irssi::pidwait_remove($child_pid);
1444 unlink $filename unless &debug;
1446 return unless Irssi::settings_get_bool("twirssi_notify_timeouts");
1449 my @time = localtime($last_poll);
1450 if ( time - $last_poll < 24 * 60 * 60 ) {
1451 $since = sprintf( "%d:%02d", @time[ 2, 1 ] );
1453 $since = scalar localtime($last_poll);
1456 if ( not $failwhale and time - $last_poll > 60 * 60 ) {
1461 q{ .--./ / | _.---.| },
1473 if ( time - $last_poll < 600 ) {
1474 &ccrap("Haven't been able to get updated tweets since $since");
1480 return Irssi::settings_get_bool("twirssi_debug");
1484 $window->print( "%R***%n @_", MSGLEVEL_PUBLIC );
1488 $window->print( "%R***%n @_", MSGLEVEL_CLIENTCRAP );
1494 if ( Irssi::settings_get_bool("tweet_to_away")
1496 and $data !~ /^[dD] / )
1499 Irssi::server_find_tag( Irssi::settings_get_str("bitlbee_server") );
1501 $server->send_raw("away :$data");
1504 &ccrap( "Can't find bitlbee server.",
1505 "Update bitlbee_server or disable tweet_to_away" );
1515 my $noalert = shift;
1517 if ( length $data > 140 ) {
1518 ¬ice( "Tweet too long (" . length($data) . " characters) - aborted" )
1526 sub valid_username {
1527 my $username = shift;
1529 $username = &normalize_username($username);
1531 unless ( exists $twits{$username} ) {
1532 ¬ice("Unknown username $username");
1542 ¬ice("Not logged in! Use /twitter_login username pass!");
1550 my ( $complist, $window, $word, $linestart, $want_space ) = @_;
1553 $linestart =~ /^\/(?:retweet|twitter_reply)(?:_as)?\s*$/
1554 or ( Irssi::settings_get_bool("twirssi_use_reply_aliases")
1555 and $linestart =~ /^\/reply(?:_as)?\s*$/ )
1557 { # /twitter_reply gets a nick:num
1559 @$complist = map { "$_:$id_map{__indexes}{$_}" }
1560 sort { $nicks{$b} <=> $nicks{$a} }
1562 keys %{ $id_map{__indexes} };
1566 /^\/(twitter_unfriend|twitter_add_follow_extra|twitter_del_follow_extra)\s*$/
1568 { # /twitter_unfriend gets a nick
1570 push @$complist, grep /^\Q$word/i,
1571 sort { $nicks{$b} <=> $nicks{$a} } keys %nicks;
1574 # /tweet, /tweet_as, /dm, /dm_as - complete @nicks (and nicks as the first
1576 if ( $linestart =~ /^\/(?:tweet|dm)/ ) {
1577 my $prefix = $word =~ s/^@//;
1578 $prefix = 0 if $linestart eq '/dm' or $linestart eq '/dm_as';
1579 push @$complist, grep /^\Q$word/i,
1580 sort { $nicks{$b} <=> $nicks{$a} } keys %nicks;
1581 @$complist = map { "\@$_" } @$complist if $prefix;
1585 sub event_send_text {
1586 my ( $line, $server, $win ) = @_;
1587 my $awin = Irssi::active_win();
1589 # if the window where we got our text was the twitter window, and the user
1590 # wants to be lazy, tweet away!
1591 if ( ( $awin->get_active_name() eq $window->{name} )
1592 and Irssi::settings_get_bool("tweet_window_input") )
1594 &cmd_tweet( $line, $server, $win );
1599 my $poll = Irssi::settings_get_int("twitter_poll_interval");
1600 return $poll if $poll >= 60;
1607 if ( Irssi::settings_get_str("twirssi_nick_color") ) {
1608 my $c = Irssi::settings_get_str("twirssi_nick_color");
1609 $c = $irssi_to_mirc_colors{$c};
1610 $text =~ s/(^|\W)\@(\w+)/$1\cC$c\@$2\cO/g if $c;
1612 if ( Irssi::settings_get_str("twirssi_topic_color") ) {
1613 my $c = Irssi::settings_get_str("twirssi_topic_color");
1614 $c = $irssi_to_mirc_colors{$c};
1615 $text =~ s/(^|\W)(\#|\!)([-\w]+)/$1\cC$c$2$3\cO/g if $c;
1617 $text =~ s/[\n\r]/ /g;
1625 my $provider = Irssi::settings_get_str("short_url_provider");
1628 Irssi::settings_get_bool("twirssi_always_shorten")
1629 or &too_long( $data, 1 )
1635 if ( $provider eq 'Bitly' ) {
1636 @args[ 1, 2 ] = split ',',
1637 Irssi::settings_get_str("short_url_args"), 2;
1638 unless ( @args == 3 ) {
1640 "WWW::Shorten::Bitly requires a username and API key.",
1641 "Set short_url_args to username,API_key or change your",
1642 "short_url_provider."
1644 return decode "utf8", $data;
1648 foreach my $url ( $data =~ /(https?:\/\/\S+[\w\/])/g ) {
1651 my $short = makeashorterlink(@args);
1653 $data =~ s/\Q$url/$short/g;
1655 ¬ice("Failed to shorten $url!");
1661 return decode "utf8", $data;
1664 sub normalize_username {
1667 my ( $username, $service ) = split /\@/, $user, 2;
1669 $service = ucfirst lc $service;
1672 ucfirst lc Irssi::settings_get_str("twirssi_default_service");
1673 unless ( exists $twits{"$username\@$service"} ) {
1675 foreach my $t ( sort keys %twits ) {
1676 next unless $t =~ /^\Q$username\E\@(Twitter|Identica)/;
1682 ¬ice("Can't find a logged in user '$user'");
1687 return "$username\@$service";
1690 Irssi::signal_add( "send text", "event_send_text" );
1692 Irssi::theme_register(
1694 'twirssi_tweet', '[$0%B@$1%n$2] $3',
1695 'twirssi_search', '[$0%r$1%n:%B@$2%n$3] $4',
1696 'twirssi_reply', '[$0\--> %B@$1%n$2] $3',
1697 'twirssi_dm', '[$0%r@$1%n (%WDM%n)] $2',
1698 'twirssi_error', 'ERROR: $0',
1702 Irssi::settings_add_int( "twirssi", "twitter_poll_interval", 300 );
1703 Irssi::settings_add_str( "twirssi", "twitter_window", "twitter" );
1704 Irssi::settings_add_str( "twirssi", "bitlbee_server", "bitlbee" );
1705 Irssi::settings_add_str( "twirssi", "short_url_provider", "TinyURL" );
1706 Irssi::settings_add_str( "twirssi", "short_url_args", undef );
1707 Irssi::settings_add_str( "twirssi", "twitter_usernames", undef );
1708 Irssi::settings_add_str( "twirssi", "twitter_passwords", undef );
1709 Irssi::settings_add_str( "twirssi", "twirssi_default_service", "Twitter" );
1710 Irssi::settings_add_str( "twirssi", "twirssi_nick_color", "%B" );
1711 Irssi::settings_add_str( "twirssi", "twirssi_topic_color", "%r" );
1712 Irssi::settings_add_str( "twirssi", "twirssi_retweet_format",
1713 'RT $n: "$t" ${-- $c$}' );
1714 Irssi::settings_add_str( "twirssi", "twirssi_location",
1715 ".irssi/scripts/twirssi.pl" );
1716 Irssi::settings_add_str( "twirssi", "twirssi_replies_store",
1717 ".irssi/scripts/twirssi.json" );
1719 Irssi::settings_add_int( "twirssi", "twitter_friends_poll", 600 );
1720 Irssi::settings_add_int( "twirssi", "twitter_timeout", 30 );
1722 Irssi::settings_add_bool( "twirssi", "twirssi_upgrade_beta", 0 );
1723 Irssi::settings_add_bool( "twirssi", "tweet_to_away", 0 );
1724 Irssi::settings_add_bool( "twirssi", "show_reply_context", 0 );
1725 Irssi::settings_add_bool( "twirssi", "show_own_tweets", 1 );
1726 Irssi::settings_add_bool( "twirssi", "twirssi_debug", 0 );
1727 Irssi::settings_add_bool( "twirssi", "twirssi_first_run", 1 );
1728 Irssi::settings_add_bool( "twirssi", "twirssi_track_replies", 1 );
1729 Irssi::settings_add_bool( "twirssi", "twirssi_replies_autonick", 1 );
1730 Irssi::settings_add_bool( "twirssi", "twirssi_use_reply_aliases", 0 );
1731 Irssi::settings_add_bool( "twirssi", "twirssi_notify_timeouts", 1 );
1732 Irssi::settings_add_bool( "twirssi", "twirssi_hilights", 1 );
1733 Irssi::settings_add_bool( "twirssi", "twirssi_always_shorten", 0 );
1734 Irssi::settings_add_bool( "twirssi", "tweet_window_input", 0 );
1735 Irssi::settings_add_bool( "twirssi", "twirssi_avoid_ssl", 0 );
1737 $last_poll = time - &get_poll_time;
1738 $window = Irssi::window_find_name( Irssi::settings_get_str('twitter_window') );
1741 ->print( "Couldn't find a window named '"
1742 . Irssi::settings_get_str('twitter_window')
1743 . "', trying to create it." );
1745 Irssi::Windowitem::window_create(
1746 Irssi::settings_get_str('twitter_window'), 1 );
1747 $window->set_name( Irssi::settings_get_str('twitter_window') );
1751 Irssi::command_bind( "dm", "cmd_direct" );
1752 Irssi::command_bind( "dm_as", "cmd_direct_as" );
1753 Irssi::command_bind( "tweet", "cmd_tweet" );
1754 Irssi::command_bind( "tweet_as", "cmd_tweet_as" );
1755 Irssi::command_bind( "retweet", "cmd_retweet" );
1756 Irssi::command_bind( "retweet_as", "cmd_retweet_as" );
1757 Irssi::command_bind( "twitter_reply", "cmd_reply" );
1758 Irssi::command_bind( "twitter_reply_as", "cmd_reply_as" );
1759 Irssi::command_bind( "twitter_login", "cmd_login" );
1760 Irssi::command_bind( "twitter_logout", "cmd_logout" );
1761 Irssi::command_bind( "twitter_switch", "cmd_switch" );
1762 Irssi::command_bind( "twitter_subscribe", "cmd_add_search" );
1763 Irssi::command_bind( "twitter_unsubscribe", "cmd_del_search" );
1764 Irssi::command_bind( "twitter_list_subscriptions", "cmd_list_search" );
1765 Irssi::command_bind( "twirssi_upgrade", "cmd_upgrade" );
1766 Irssi::command_bind( "twitter_updates", "get_updates" );
1767 Irssi::command_bind( "twitter_add_follow_extra", "cmd_add_follow" );
1768 Irssi::command_bind( "twitter_del_follow_extra", "cmd_del_follow" );
1769 Irssi::command_bind( "twitter_list_follow_extra", "cmd_list_follow" );
1770 Irssi::command_bind( "bitlbee_away", "update_away" );
1771 if ( Irssi::settings_get_bool("twirssi_use_reply_aliases") ) {
1772 Irssi::command_bind( "reply", "cmd_reply" );
1773 Irssi::command_bind( "reply_as", "cmd_reply_as" );
1775 Irssi::command_bind(
1778 print "twits: ", join ", ",
1779 map { "u: $_->{username}\@" . ref($_) } values %twits;
1780 print "selected: $user\@$defservice";
1781 print "friends: ", join ", ", sort keys %friends;
1782 print "nicks: ", join ", ", sort keys %nicks;
1783 print "searches: ", Dumper \%{ $id_map{__searches} };
1784 print "last poll: $last_poll";
1785 if ( open DUMP, ">/tmp/twirssi.cache.txt" ) {
1786 print DUMP Dumper \%tweet_cache;
1788 print "cache written out to /tmp/twirssi.cache.txt";
1792 Irssi::command_bind(
1796 "Twirssi v$VERSION; "
1798 $Net::Twitter::VERSION
1799 ? "Net::Twitter v$Net::Twitter::VERSION. "
1803 $Net::Identica::VERSION
1804 ? "Net::Identica v$Net::Identica::VERSION. "
1808 . JSON::Any::handler()
1809 . ". See details at http://twirssi.com/"
1813 Irssi::command_bind(
1816 "/twitter_follow <username>",
1818 sub { ¬ice("Following $_[0]"); $nicks{ $_[0] } = time; }
1821 Irssi::command_bind(
1824 "/twitter_unfriend <username>",
1826 sub { ¬ice("Stopped following $_[0]"); delete $nicks{ $_[0] }; }
1829 Irssi::command_bind(
1830 "twitter_device_updates",
1832 "/twitter_device_updates none|im|sms",
1833 "update_delivery_device",
1834 sub { ¬ice("Device updated to $_[0]"); }
1837 Irssi::command_bind(
1840 "/twitter_block <username>",
1842 sub { ¬ice("Blocked $_[0]"); }
1845 Irssi::command_bind(
1848 "/twitter_unblock <username>",
1850 sub { ¬ice("Unblock $_[0]"); }
1853 Irssi::signal_add_last( 'complete word' => \&sig_complete );
1855 ¬ice(" %Y<%C(%B^%C)%N TWIRSSI v%R$VERSION%N");
1856 ¬ice(" %C(_(\\%N http://twirssi.com/ for full docs");
1858 " %Y||%C `%N Log in with /twitter_login, send updates with /tweet");
1860 my $file = Irssi::settings_get_str("twirssi_replies_store");
1861 if ( $file and -r $file ) {
1862 if ( open( JSON, $file ) ) {
1867 my $ref = JSON::Any->jsonToObj($json);
1869 my $num = keys %{ $id_map{__indexes} };
1870 ¬ice( sprintf "Loaded old replies from %d contact%s.",
1871 $num, ( $num == 1 ? "" : "s" ) );
1876 ¬ice("Failed to load old replies from $file: $!");
1880 if ( my $provider = Irssi::settings_get_str("short_url_provider") ) {
1881 ¬ice("Loading WWW::Shorten::$provider...");
1882 eval "use WWW::Shorten::$provider;";
1886 "Failed to load WWW::Shorten::$provider - either clear",
1887 "short_url_provider or install the CPAN module"
1892 if ( my $autouser = Irssi::settings_get_str("twitter_usernames")
1893 and my $autopass = Irssi::settings_get_str("twitter_passwords") )
1901 ->print( "Create a window named "
1902 . Irssi::settings_get_str('twitter_window')
1903 . " or change the value of twitter_window. Then, reload twirssi." );
1906 # vim: set sts=4 expandtab: