10 $Data::Dumper::Indent = 1;
12 use vars qw($VERSION %IRSSI);
14 $VERSION = "2.3.0beta";
15 my ($REV) = '$Rev: 687 $' =~ /(\d+)/;
17 authors => 'Dan Boger',
18 contact => 'zigdon@gmail.com',
20 description => 'Send twitter updates using /tweet. '
21 . 'Can optionally set your bitlbee /away message to same',
22 license => 'GNU GPL v2',
23 url => 'http://twirssi.com',
24 changed => '$Date: 2009-08-07 01:24:53 -0700 (Fri, 07 Aug 2009) $',
34 my $last_friends_poll = 0;
42 my %fix_replies_index;
44 my %irssi_to_mirc_colors = (
64 my ( $data, $server, $win ) = @_;
66 return unless &logged_in($twit);
68 my ( $target, $text ) = split ' ', $data, 2;
69 unless ( $target and $text ) {
70 ¬ice("Usage: /dm <nick> <message>");
74 &cmd_direct_as( "$user $data", $server, $win );
78 my ( $data, $server, $win ) = @_;
80 return unless &logged_in($twit);
82 my ( $username, $target, $text ) = split ' ', $data, 3;
83 unless ( $username and $target and $text ) {
84 ¬ice("Usage: /dm_as <username> <nick> <message>");
88 return unless $username = &valid_username($username);
91 if ( $twits{$username}
92 ->new_direct_message( { user => $target, text => $text } ) )
94 ¬ice("DM sent to $target: $text");
95 $nicks{$target} = time;
99 $error = JSON::Any->jsonToObj( $twits{$username}->get_error() );
100 $error = $error->{error};
102 die $error if $error;
103 ¬ice("DM to $target failed");
108 ¬ice("DM caused an error: $@");
114 my ( $data, $server, $win ) = @_;
116 return unless &logged_in($twit);
118 $data =~ s/^\s+|\s+$//;
120 ¬ice("Usage: /retweet <nick[:num]> [comment]");
124 my ( $id, $data ) = split ' ', $data, 2;
126 &cmd_retweet_as( "$user $id $data", $server, $win );
130 my ( $data, $server, $win ) = @_;
132 unless ( Irssi::settings_get_bool("twirssi_track_replies") ) {
133 ¬ice("twirssi_track_replies is required in order to reteet.");
137 return unless &logged_in($twit);
139 $data =~ s/^\s+|\s+$//;
140 my ( $username, $id, $data ) = split ' ', $data, 3;
143 ¬ice("Usage: /retweet_as <username> <nick[:num]> [comment]");
147 return unless $username = &valid_username($username);
150 $id =~ s/[^\w\d\-:]+//g;
151 ( $nick, $id ) = split /:/, $id;
152 unless ( exists $id_map{ lc $nick } ) {
153 ¬ice("Can't find a tweet from $nick to retweet!");
157 $id = $id_map{__indexes}{$nick} unless $id;
158 unless ( $id_map{ lc $nick }[$id] ) {
159 ¬ice("Can't find a tweet numbered $id from $nick to retweet!");
163 unless ( $id_map{__tweets}{ lc $nick }[$id] ) {
164 ¬ice("The text of this tweet isn't saved, sorry!");
168 # Irssi::settings_add_str( "twirssi", "twirssi_retweet_format", 'RT $n: $t ${-- $c$}' );
169 my $text = Irssi::settings_get_str("twirssi_retweet_format");
170 $text =~ s/\$n/\@$nick/g;
172 $text =~ s/\${|\$}//g;
173 $text =~ s/\$c/$data/;
175 $text =~ s/\${.*?\$}//;
177 $text =~ s/\$t/$id_map{__tweets}{ lc $nick }[$id]/;
179 $data = &shorten($text);
181 return if &too_long($data);
186 $twits{$username}->update(
190 # in_reply_to_status_id => $id_map{ lc $nick }[$id]
195 ¬ice("Update failed");
199 return unless $success;
202 ¬ice("Update caused an error: $@. Aborted");
206 foreach ( $data =~ /@([-\w]+)/ ) {
210 ¬ice("Retweet sent");
214 my ( $data, $server, $win ) = @_;
216 return unless &logged_in($twit);
218 $data =~ s/^\s+|\s+$//;
220 ¬ice("Usage: /tweet <update>");
224 &cmd_tweet_as( "$user\@$defservice $data", $server, $win );
228 my ( $data, $server, $win ) = @_;
230 return unless &logged_in($twit);
232 $data =~ s/^\s+|\s+$//;
233 $data =~ s/\s\s+/ /g;
234 my ( $username, $data ) = split ' ', $data, 2;
236 unless ( $username and $data ) {
237 ¬ice("Usage: /tweet_as <username> <update>");
241 return unless $username = &valid_username($username);
243 $data = &shorten($data);
245 return if &too_long($data);
249 unless ( $twits{$username}->update($data) )
251 ¬ice("Update failed");
255 return unless $success;
258 ¬ice("Update caused an error: $@. Aborted.");
262 foreach ( $data =~ /@([-\w]+)/ ) {
266 my $away = &update_away($data);
268 ¬ice( "Update sent" . ( $away ? " (and away msg set)" : "" ) );
272 my ( $data, $server, $win ) = @_;
274 return unless &logged_in($twit);
276 $data =~ s/^\s+|\s+$//;
278 ¬ice("Usage: /reply <nick[:num]> <update>");
282 my ( $id, $data ) = split ' ', $data, 2;
283 unless ( $id and $data ) {
284 ¬ice("Usage: /reply <nick[:num]> <update>");
288 &cmd_reply_as( "$user $id $data", $server, $win );
292 my ( $data, $server, $win ) = @_;
294 unless ( Irssi::settings_get_bool("twirssi_track_replies") ) {
295 ¬ice("twirssi_track_replies is required in order to reply to "
296 . "specific tweets. Either enable it, or just use /tweet "
297 . "\@username <text>." );
301 return unless &logged_in($twit);
303 $data =~ s/^\s+|\s+$//;
304 my ( $username, $id, $data ) = split ' ', $data, 3;
306 unless ( $username and $data ) {
307 ¬ice("Usage: /reply_as <username> <nick[:num]> <update>");
311 return unless $username = &valid_username($username);
314 $id =~ s/[^\w\d\-:]+//g;
315 ( $nick, $id ) = split /:/, $id;
316 unless ( exists $id_map{ lc $nick } ) {
317 ¬ice("Can't find a tweet from $nick to reply to!");
321 $id = $id_map{__indexes}{$nick} unless $id;
322 unless ( $id_map{ lc $nick }[$id] ) {
323 ¬ice("Can't find a tweet numbered $id from $nick to reply to!");
327 if ( Irssi::settings_get_bool("twirssi_replies_autonick") ) {
329 # remove any @nick at the beginning of the reply, as we'll add it anyway
330 $data =~ s/^\s*\@?$nick\s*//;
331 $data = "\@$nick " . $data;
334 $data = &shorten($data);
336 return if &too_long($data);
341 $twits{$username}->update(
344 in_reply_to_status_id => $id_map{ lc $nick }[$id]
349 ¬ice("Update failed");
353 return unless $success;
356 ¬ice("Update caused an error: $@. Aborted");
360 foreach ( $data =~ /@([-\w]+)/ ) {
364 my $away = &update_away($data);
366 ¬ice( "Update sent" . ( $away ? " (and away msg set)" : "" ) );
370 my ( $usage_str, $api_name, $post_ref ) = @_;
373 my ( $data, $server, $win ) = @_;
375 return unless &logged_in($twit);
377 $data =~ s/^\s+|\s+$//;
379 ¬ice("Usage: $usage_str");
385 unless ( $twit->$api_name($data) )
387 ¬ice("$api_name failed");
391 return unless $success;
394 ¬ice("$api_name caused an error. Aborted.");
398 &$post_ref($data) if $post_ref;
403 my ( $data, $server, $win ) = @_;
405 $data =~ s/^\s+|\s+$//g;
406 $data = &normalize_username($data);
407 if ( exists $twits{$data} ) {
408 ¬ice("Switching to $data");
409 $twit = $twits{$data};
410 if ( $data =~ /(.*)\@(.*)/ ) {
414 ¬ice("Couldn't figure out what service '$data' is on");
417 ¬ice("Unknown user $data");
422 my ( $data, $server, $win ) = @_;
424 $data =~ s/^\s+|\s+$//g;
425 $data = $user unless $data;
426 return unless $data = &valid_username($data);
428 ¬ice("Logging out $data...");
429 $twits{$data}->end_session();
430 delete $twits{$data};
433 &cmd_switch( ( keys %twits )[0], $server, $win );
435 Irssi::timeout_remove($poll) if $poll;
441 my ( $data, $server, $win ) = @_;
444 ( $user, $pass ) = split ' ', $data, 2;
446 ¬ice("usage: /twitter_login <username>[\@<service>] <password>");
449 } elsif ( my $autouser = Irssi::settings_get_str("twitter_usernames")
450 and my $autopass = Irssi::settings_get_str("twitter_passwords") )
452 my @user = split /\s*,\s*/, $autouser;
453 my @pass = split /\s*,\s*/, $autopass;
455 # if a password ends with a '\', it was meant to escape the comma, and
456 # it should be concatinated with the next one
460 while ( $p =~ /\\$/ and @pass ) {
461 $p .= "," . shift @pass;
466 if ( @user != @unescaped ) {
467 ¬ice("Number of usernames doesn't match "
468 . "the number of passwords - auto-login failed" );
471 while ( @user and @unescaped ) {
473 $p = shift @unescaped;
479 ¬ice("/twitter_login requires either a username and password "
480 . "or twitter_usernames and twitter_passwords to be set." );
484 %friends = %nicks = ();
487 if ( $user =~ /^(.*)@(twitter|identica)$/ ) {
488 ( $user, $service ) = ( $1, $2 );
490 $service = Irssi::settings_get_str("twirssi_default_service");
492 $defservice = $service = ucfirst lc $service;
494 eval "use Net::$service";
497 "Failed to load Net::$service when trying to log in as $user: $@");
501 $twit = "Net::$service"->new(
505 ssl => Irssi::settings_get_bool("twirssi_avoid_ssl") ? 0 : 1,
509 ¬ice("Failed to create Net::$service object! Aborting.");
513 if ( my $timeout = Irssi::settings_get_int("twitter_timeout")
514 and $twit->can('ua') )
516 $twit->ua->timeout($timeout);
519 unless ( $twit->verify_credentials() ) {
520 ¬ice("Login as $user\@$service failed");
522 if ( not Irssi::settings_get_bool("twirssi_avoid_ssl") ) {
524 "It's possible you're missing one of the modules required for "
525 . "SSL logins. Try setting twirssi_avoid_ssl to on. See "
526 . "http://cpansearch.perl.org/src/GAAS/libwww-perl-5.831/README.SSL "
527 . "for the detailed requirements." );
532 &cmd_switch( ( keys %twits )[0], $server, $win );
538 my $rate_limit = $twit->rate_limit_status();
539 if ( $rate_limit and $rate_limit->{remaining_hits} < 1 ) {
541 "Rate limit exceeded, try again after $rate_limit->{reset_time}"
547 $twits{"$user\@$service"} = $twit;
548 Irssi::timeout_remove($poll) if $poll;
549 $poll = Irssi::timeout_add( &get_poll_time * 1000, \&get_updates, "" );
550 ¬ice("Logged in as $user\@$service, loading friends list...");
552 ¬ice( "loaded friends: ", scalar keys %friends );
553 if ( Irssi::settings_get_bool("twirssi_first_run") ) {
554 Irssi::settings_set_bool( "twirssi_first_run", 0 );
560 ¬ice("Login failed");
565 my ( $data, $server, $win ) = @_;
568 ¬ice("Usage: /twitter_add_follow_extra <username>");
572 $data =~ s/^\s+|\s+$//;
576 if ( exists $id_map{__fixreplies}{"$user\@$defservice"}{$data} ) {
577 ¬ice("Already following all replies by \@$data");
581 $id_map{__fixreplies}{"$user\@$defservice"}{$data} = 1;
582 ¬ice("Will now follow all replies by \@$data");
586 my ( $data, $server, $win ) = @_;
589 ¬ice("Usage: /twitter_del_follow_extra <username>");
593 $data =~ s/^\s+|\s+$//;
597 unless ( exists $id_map{__fixreplies}{"$user\@$defservice"}{$data} ) {
598 ¬ice("Wasn't following all replies by \@$data");
602 delete $id_map{__fixreplies}{"$user\@$defservice"}{$data};
603 ¬ice("Will no longer follow all replies by \@$data");
606 sub cmd_list_follow {
607 my ( $data, $server, $win ) = @_;
610 foreach my $suser ( sort keys %{ $id_map{__fixreplies} } ) {
612 foreach my $fruser ( sort keys %{ $id_map{__fixreplies}{$suser} } ) {
613 $frusers = $frusers ? "$frusers, $fruser" : $fruser;
617 ¬ice("Following all replies as \@$suser: $frusers");
622 ¬ice("Not following all replies by anyone");
627 my ( $data, $server, $win ) = @_;
629 unless ( $twit and $twit->can('search') ) {
630 ¬ice("ERROR: Your version of Net::Twitter ($Net::Twitter::VERSION) "
631 . "doesn't support searches." );
635 $data =~ s/^\s+|\s+$//;
639 ¬ice("Usage: /twitter_subscribe <topic>");
643 if ( exists $id_map{__searches}{"$user\@$defservice"}{$data} ) {
644 ¬ice("Already had a subscription for '$data'");
648 $id_map{__searches}{"$user\@$defservice"}{$data} = 1;
649 ¬ice("Added subscription for '$data'");
653 my ( $data, $server, $win ) = @_;
655 unless ( $twit and $twit->can('search') ) {
656 ¬ice("ERROR: Your version of Net::Twitter ($Net::Twitter::VERSION) "
657 . "doesn't support searches." );
660 $data =~ s/^\s+|\s+$//;
664 ¬ice("Usage: /twitter_unsubscribe <topic>");
668 unless ( exists $id_map{__searches}{"$user\@$defservice"}{$data} ) {
669 ¬ice("No subscription found for '$data'");
673 delete $id_map{__searches}{"$user\@$defservice"}{$data};
674 ¬ice("Removed subscription for '$data'");
677 sub cmd_list_search {
678 my ( $data, $server, $win ) = @_;
681 foreach my $suser ( sort keys %{ $id_map{__searches} } ) {
683 foreach my $topic ( sort keys %{ $id_map{__searches}{$suser} } ) {
684 $topics = $topics ? "$topics, $topic" : $topic;
688 ¬ice("Search subscriptions for \@$suser: $topics");
693 ¬ice("No search subscriptions set up");
698 my ( $data, $server, $win ) = @_;
700 my $loc = Irssi::settings_get_str("twirssi_location");
702 ¬ice( "$loc isn't writable, can't upgrade." .
703 " Perhaps you need to /set twirssi_location?"
709 unless ( $data or Irssi::settings_get_bool("twirssi_upgrade_beta") ) {
710 eval { use Digest::MD5; };
713 ¬ice( "Failed to load Digest::MD5." .
714 " Try '/twirssi_upgrade nomd5' to skip MD5 verification"
719 $md5 = get("http://twirssi.com/md5sum");
723 ¬ice("Failed to download md5sum from peeron! Aborting.");
727 unless ( open( CUR, $loc ) ) {
728 ¬ice( "Failed to read $loc." .
729 " Check that /set twirssi_location is set to the correct location."
734 my $cur_md5 = Digest::MD5::md5_hex(<CUR>);
737 if ( $cur_md5 eq $md5 ) {
738 ¬ice("Current twirssi seems to be up to date.");
744 Irssi::settings_get_bool("twirssi_upgrade_beta")
745 ? "http://github.com/zigdon/twirssi/raw/master/twirssi.pl"
746 : "http://twirssi.com/twirssi.pl";
747 ¬ice("Downloading twirssi from $URL");
748 LWP::Simple::getstore( $URL, "$loc.upgrade" );
750 unless ( -s "$loc.upgrade" ) {
751 ¬ice("Failed to save $loc.upgrade."
752 . " Check that /set twirssi_location is set to the correct location."
757 unless ( $data or Irssi::settings_get_bool("twirssi_upgrade_beta") ) {
758 unless ( open( NEW, "$loc.upgrade" ) ) {
759 ¬ice("Failed to read $loc.upgrade."
760 . " Check that /set twirssi_location is set to the correct location."
765 my $new_md5 = Digest::MD5::md5_hex(<NEW>);
768 if ( $new_md5 ne $md5 ) {
769 ¬ice("MD5 verification failed. expected $md5, got $new_md5");
774 rename $loc, "$loc.backup"
775 or ¬ice("Failed to back up $loc: $!. Aborting")
777 rename "$loc.upgrade", $loc
778 or ¬ice("Failed to rename $loc.upgrade: $!. Aborting")
781 my ( $dir, $file ) = ( $loc =~ m{(.*)/([^/]+)$} );
782 if ( -e "$dir/autorun/$file" ) {
783 ¬ice("Updating $dir/autorun/$file");
784 unlink "$dir/autorun/$file"
785 or ¬ice("Failed to remove old $file from autorun: $!");
786 symlink "../$file", "$dir/autorun/$file"
787 or ¬ice("Failed to create symlink in autorun directory: $!");
790 ¬ice("Download complete. Reload twirssi with /script load $file");
800 print $fh "type:debug Loading friends page $page...\n"
801 if ( $fh and &debug );
802 my $friends = $twit->friends( { page => $page } );
803 last unless $friends;
804 $new_friends{ $_->{screen_name} } = time foreach @$friends;
806 last if @$friends == 0 or $page == 10;
811 print $fh "type:debug Error during friends list update. Aborted.\n";
815 my ( $added, $removed ) = ( 0, 0 );
816 print $fh "type:debug Scanning for new friends...\n" if ( $fh and &debug );
817 foreach ( keys %new_friends ) {
818 next if exists $friends{$_};
823 print $fh "type:debug Scanning for removed friends...\n"
824 if ( $fh and &debug );
825 foreach ( keys %friends ) {
826 next if exists $new_friends{$_};
831 return ( $added, $removed );
835 print scalar localtime, " - get_updates starting" if &debug;
838 Irssi::window_find_name( Irssi::settings_get_str('twitter_window') );
841 ->print( "Can't find a window named '"
842 . Irssi::settings_get_str('twitter_window')
843 . "'. Create it or change the value of twitter_window" );
846 return unless &logged_in($twit);
848 my ( $fh, $filename ) = File::Temp::tempfile();
849 binmode( $fh, ":utf8" );
852 if ($child_pid) { # parent
853 Irssi::timeout_add_once( 5000, 'monitor_child',
854 [ "$filename.done", 0 ] );
855 Irssi::pidwait_add($child_pid);
856 } elsif ( defined $child_pid ) { # child
865 foreach ( keys %twits ) {
866 $error++ unless &do_updates( $fh, $_, $twits{$_}, \%context_cache );
868 if ( $id_map{__fixreplies}{$_} ) {
869 my @frusers = sort keys %{ $id_map{__fixreplies}{$_} };
872 unless &get_timeline( $fh, $frusers[ $fix_replies_index{$_} ],
873 $_, $twits{$_}, \%context_cache );
875 $fix_replies_index{$_}++;
876 $fix_replies_index{$_} = 0
877 if $fix_replies_index{$_} >= @frusers;
878 print $fh "id:$fix_replies_index{$_} ",
879 "account:$_ type:fix_replies_index\n";
883 print $fh "__friends__\n";
885 time - $last_friends_poll >
886 Irssi::settings_get_int('twitter_friends_poll') )
888 print $fh "__updated ", time, "\n";
889 my ( $added, $removed ) = &load_friends($fh);
890 if ( $added + $removed ) {
891 print $fh "type:debug %R***%n Friends list updated: ",
893 sprintf( "%d added", $added ),
894 sprintf( "%d removed", $removed ) ),
899 foreach ( sort keys %friends ) {
900 print $fh "$_ $friends{$_}\n";
904 print $fh "type:debug Update encountered errors. Aborted\n";
905 print $fh "-- $last_poll";
907 print $fh "-- $new_poll";
910 rename $filename, "$filename.done";
913 &ccrap("Failed to fork for updating: $!");
915 print scalar localtime, " - get_updates ends" if &debug;
919 my ( $fh, $username, $obj, $cache ) = @_;
921 my $rate_limit = $obj->rate_limit_status();
922 if ( $rate_limit and $rate_limit->{remaining_hits} < 1 ) {
923 ¬ice("Rate limit exceeded for $username");
927 print scalar localtime, " - Polling for updates for $username" if &debug;
931 if ( $id_map{__last_id}{$username}{timeline} )
933 $tweets = $obj->friends_timeline( { count => 100 } );
935 $tweets = $obj->friends_timeline();
940 print $fh "type:debug Error during friends_timeline call: Aborted.\n";
941 print $fh "type:debug : $_\n" foreach split /\n/, Dumper($@);
945 unless ( ref $tweets ) {
946 if ( $obj->can("get_error") ) {
947 my $error = "Unknown error";
948 eval { $error = JSON::Any->jsonToObj( $obj->get_error() ) };
949 unless ($@) { $error = $obj->get_error() }
951 "type:debug API Error during friends_timeline call: Aborted\n";
952 print $fh "type:debug : $_\n" foreach split /\n/, Dumper($error);
956 "type:debug API Error during friends_timeline call. Aborted.\n";
961 foreach my $t ( reverse @$tweets ) {
962 my $text = decode_entities( $t->{text} );
963 $text =~ s/[\n\r]/ /g;
965 if ( Irssi::settings_get_bool("show_reply_context")
966 and $t->{in_reply_to_screen_name} ne $username
967 and $t->{in_reply_to_screen_name}
968 and not exists $friends{ $t->{in_reply_to_screen_name} } )
970 $nicks{ $t->{in_reply_to_screen_name} } = time;
972 unless ( $cache->{ $t->{in_reply_to_status_id} } ) {
974 $cache->{ $t->{in_reply_to_status_id} } =
975 $obj->show_status( $t->{in_reply_to_status_id} );
979 $context = $cache->{ $t->{in_reply_to_status_id} };
982 my $ctext = decode_entities( $context->{text} );
983 $ctext =~ s/[\n\r]/ /g;
984 if ( $context->{truncated} and ref($obj) ne 'Net::Identica' ) {
986 " -- http://twitter.com/$context->{user}{screen_name}"
987 . "/status/$context->{id}";
989 printf $fh "id:%s account:%s nick:%s type:tweet %s\n",
990 $context->{id}, $username,
991 $context->{user}{screen_name}, $ctext;
996 if $t->{user}{screen_name} eq $username
997 and not Irssi::settings_get_bool("show_own_tweets");
998 if ( $t->{truncated} and ref($obj) ne 'Net::Identica' ) {
999 $text .= " -- http://twitter.com/$t->{user}{screen_name}"
1000 . "/status/$t->{id}";
1002 printf $fh "id:%s account:%s nick:%s type:%s %s\n",
1003 $t->{id}, $username, $t->{user}{screen_name}, $reply, $text;
1004 $new_poll_id = $t->{id} if $new_poll_id < $t->{id};
1006 printf $fh "id:%s account:%s type:last_id timeline\n",
1007 $new_poll_id, $username;
1009 print scalar localtime, " - Polling for replies since ",
1010 $id_map{__last_id}{$username}{reply}
1014 if ( $id_map{__last_id}{$username}{reply} )
1016 $tweets = $obj->replies(
1017 { since_id => $id_map{__last_id}{$username}{reply} } )
1020 $tweets = $obj->replies() || [];
1025 print $fh "type:debug Error during replies call. Aborted.\n";
1029 foreach my $t ( reverse @$tweets ) {
1031 if exists $friends{ $t->{user}{screen_name} };
1033 my $text = decode_entities( $t->{text} );
1034 $text =~ s/[\n\r]/ /g;
1035 if ( $t->{truncated} ) {
1036 $text .= " -- http://twitter.com/$t->{user}{screen_name}"
1037 . "/status/$t->{id}";
1039 printf $fh "id:%s account:%s nick:%s type:tweet %s\n",
1040 $t->{id}, $username, $t->{user}{screen_name}, $text;
1041 $new_poll_id = $t->{id} if $new_poll_id < $t->{id};
1043 printf $fh "id:%s account:%s type:last_id reply\n", $new_poll_id, $username;
1045 print scalar localtime, " - Polling for DMs" if &debug;
1048 if ( $id_map{__last_id}{$username}{dm} )
1050 $tweets = $obj->direct_messages(
1051 { since_id => $id_map{__last_id}{$username}{dm} } )
1054 $tweets = $obj->direct_messages() || [];
1059 print $fh "type:debug Error during direct_messages call. Aborted.\n";
1063 foreach my $t ( reverse @$tweets ) {
1064 my $text = decode_entities( $t->{text} );
1065 $text =~ s/[\n\r]/ /g;
1066 printf $fh "id:%s account:%s nick:%s type:dm %s\n",
1067 $t->{id}, $username, $t->{sender_screen_name}, $text;
1068 $new_poll_id = $t->{id} if $new_poll_id < $t->{id};
1070 printf $fh "id:%s account:%s type:last_id dm\n", $new_poll_id, $username;
1072 print scalar localtime, " - Polling for subscriptions" if &debug;
1073 if ( $obj->can('search') and $id_map{__searches}{$username} ) {
1075 foreach my $topic ( sort keys %{ $id_map{__searches}{$username} } ) {
1076 print $fh "type:debug searching for $topic since ",
1077 "$id_map{__searches}{$username}{$topic}\n";
1079 $search = $obj->search(
1082 since_id => $id_map{__searches}{$username}{$topic}
1089 "type:debug Error during search($topic) call. Aborted.\n";
1093 unless ( $search->{max_id} ) {
1094 print $fh "type:debug Invalid search results when searching",
1095 " for $topic. Aborted.\n";
1099 $id_map{__searches}{$username}{$topic} = $search->{max_id};
1100 printf $fh "id:%s account:%s type:searchid topic:%s\n",
1101 $search->{max_id}, $username, $topic;
1103 foreach my $t ( reverse @{ $search->{results} } ) {
1104 my $text = decode_entities( $t->{text} );
1105 $text =~ s/[\n\r]/ /g;
1106 printf $fh "id:%s account:%s nick:%s type:search topic:%s %s\n",
1107 $t->{id}, $username, $t->{from_user}, $topic, $text;
1108 $new_poll_id = $t->{id}
1110 or $t->{id} < $new_poll_id;
1115 print scalar localtime, " - Done" if &debug;
1121 my ( $fh, $target, $username, $obj, $cache ) = @_;
1123 my $last_id = $id_map{__last_id}{$username}{$target};
1125 print $fh "type:debug get_timeline(" .
1126 "$fix_replies_index{$username}=$target > $last_id) started." .
1127 " username = $username\n";
1129 $tweets = $obj->user_timeline(
1133 $last_id ? (since_id => $last_id) : ()
1141 "type:debug Error during user_timeline($target) call: Aborted.\n";
1142 print $fh "type:debug : $_\n" foreach split /\n/, Dumper($@);
1148 "type:debug user_timeline($target) call returned undef! Aborted\n";
1152 foreach my $t ( reverse @$tweets ) {
1153 my $text = decode_entities( $t->{text} );
1154 $text =~ s/[\n\r]/ /g;
1155 my $reply = "tweet";
1156 if ( Irssi::settings_get_bool("show_reply_context")
1157 and $t->{in_reply_to_screen_name} ne $username
1158 and $t->{in_reply_to_screen_name}
1159 and not exists $friends{ $t->{in_reply_to_screen_name} } )
1161 $nicks{ $t->{in_reply_to_screen_name} } = time;
1163 unless ( $cache->{ $t->{in_reply_to_status_id} } ) {
1165 $cache->{ $t->{in_reply_to_status_id} } =
1166 $obj->show_status( $t->{in_reply_to_status_id} );
1170 $context = $cache->{ $t->{in_reply_to_status_id} };
1173 my $ctext = decode_entities( $context->{text} );
1174 $ctext =~ s/[\n\r]/ /g;
1175 if ( $context->{truncated} and ref($obj) ne 'Net::Identica' ) {
1177 " -- http://twitter.com/$context->{user}{screen_name}"
1178 . "/status/$context->{id}";
1180 printf $fh "id:%s account:%s nick:%s type:tweet %s\n",
1181 $context->{id}, $username,
1182 $context->{user}{screen_name}, $ctext;
1186 if ( $t->{truncated} and ref($obj) ne 'Net::Identica' ) {
1187 $text .= " -- http://twitter.com/$t->{user}{screen_name}"
1188 . "/status/$t->{id}";
1190 printf $fh "id:%s account:%s nick:%s type:%s %s\n",
1191 $t->{id}, $username, $t->{user}{screen_name}, $reply, $text;
1192 $last_id = $t->{id} if $last_id < $t->{id};
1194 printf $fh "id:%s account:%s type:last_id_fixreplies %s\n",
1195 $last_id, $username, $target;
1202 my $filename = $data->[0];
1203 my $attempt = $data->[1];
1205 print scalar localtime, " - checking child log at $filename ($attempt)"
1207 my ($new_last_poll);
1209 # first time we run we don't want to print out *everything*, so we just
1212 if ( open FILE, $filename ) {
1213 binmode FILE, ":utf8";
1217 last if /^__friends__/;
1218 unless (/\n$/) { # skip partial lines
1219 # print "Skipping partial line: $_" if &debug;
1226 foreach my $key (qw/id account nick type topic/) {
1227 if (s/^$key:(\S+)\s*//) {
1232 if ( $meta{type} and $meta{type} eq 'fix_replies_index' ) {
1233 $fix_replies_index{ $meta{account} } = $meta{id};
1234 print "fix_replies_index for $meta{account} set to $meta{id}"
1239 if ( not $meta{type} or $meta{type} !~ /searchid|last_id/ ) {
1240 if ( exists $meta{id} and exists $new_cache{ $meta{id} } ) {
1244 $new_cache{ $meta{id} } = time;
1246 if ( exists $meta{id} and exists $tweet_cache{ $meta{id} } ) {
1252 $meta{account} =~ s/\@(\w+)$//;
1253 $meta{service} = $1;
1255 lc $meta{service} eq
1256 lc Irssi::settings_get_str("twirssi_default_service") )
1258 $account = "$meta{account}: "
1259 if lc "$meta{account}\@$meta{service}" ne lc
1260 "$user\@$defservice";
1262 $account = "$meta{account}\@$meta{service}: ";
1266 if ( $meta{type} ne 'dm'
1267 and Irssi::settings_get_bool("twirssi_track_replies")
1271 $marker = ( $id_map{__indexes}{ $meta{nick} } + 1 ) % 100;
1272 $id_map{ lc $meta{nick} }[$marker] = $meta{id};
1273 $id_map{__indexes}{ $meta{nick} } = $marker;
1274 $id_map{__tweets}{ lc $meta{nick} }[$marker] = $_;
1275 $marker = ":$marker";
1279 $irssi_to_mirc_colors{ Irssi::settings_get_str("hilight_color") };
1280 my $nick = "\@$meta{account}";
1281 if ( $_ =~ /\Q$nick\E(?:\W|$)/i
1282 and Irssi::settings_get_bool("twirssi_hilights") )
1284 $meta{nick} = "\cC$hilight_color$meta{nick}\cO";
1285 $hilight = MSGLEVEL_HILIGHT;
1288 if ( $meta{type} =~ /tweet|reply/ ) {
1291 ( MSGLEVEL_PUBLIC | $hilight ),
1292 $meta{type}, $account, $meta{nick}, $marker, $_
1294 } elsif ( $meta{type} eq 'search' ) {
1297 ( MSGLEVEL_PUBLIC | $hilight ),
1298 $meta{type}, $account, $meta{topic},
1299 $meta{nick}, $marker, $_
1302 exists $id_map{__searches}{ $meta{account} }{ $meta{topic} }
1304 $id_map{__searches}{ $meta{account} }{ $meta{topic} } )
1306 $id_map{__searches}{ $meta{account} }{ $meta{topic} } =
1309 } elsif ( $meta{type} eq 'dm' ) {
1312 ( MSGLEVEL_MSGS | $hilight ),
1313 $meta{type}, $account, $meta{nick}, $_
1315 } elsif ( $meta{type} eq 'searchid' ) {
1316 print "Search '$meta{topic}' returned id $meta{id}" if &debug;
1319 exists $id_map{__searches}{ $meta{account} }{ $meta{topic} }
1321 $id_map{__searches}{ $meta{account} }{ $meta{topic} } )
1323 $id_map{__searches}{ $meta{account} }{ $meta{topic} } =
1326 print "Search '$meta{topic}' returned invalid id $meta{id}";
1328 } elsif ( $meta{type} eq 'last_id' ) {
1329 $id_map{__last_id}{"$meta{account}\@$meta{service}"}{$_} =
1331 if $id_map{__last_id}{"$meta{account}\@$meta{service}"}{$_} <
1333 } elsif ( $meta{type} eq 'last_id_fixreplies' ) {
1334 $id_map{__last_id}{"$meta{account}\@$meta{service}"}{$_} =
1336 if $id_map{__last_id}{"$meta{account}\@$meta{service}"}{$_} <
1338 } elsif ( $meta{type} eq 'error' ) {
1339 push @lines, [ MSGLEVEL_MSGS, $_ ];
1340 } elsif ( $meta{type} eq 'debug' ) {
1341 print "$_" if &debug,;
1343 print "Unknown line type $meta{type}: $_" if &debug,;
1349 if (/^__updated (\d+)$/) {
1350 $last_friends_poll = $1;
1351 print "Friend list updated" if &debug;
1356 $new_last_poll = $1;
1357 if ( $new_last_poll >= $last_poll ) {
1360 print "Impossible! ",
1361 "new_last_poll=$new_last_poll < last_poll=$last_poll!"
1363 undef $new_last_poll;
1367 my ( $f, $t ) = split ' ', $_;
1368 $nicks{$f} = $friends{$f} = $t;
1371 if ($new_last_poll) {
1372 print "new last_poll = $new_last_poll" if &debug;
1373 print "new last_poll_id = ", Dumper( $id_map{__last_id} ) if &debug;
1375 print "First call, not printing updates" if &debug;
1377 foreach my $line (@lines) {
1378 $window->printformat(
1380 "twirssi_" . $line->[1],
1381 @$line[ 2 .. $#$line - 1 ],
1382 &hilight( $line->[-1] )
1389 or warn "Failed to remove $filename: $!"
1392 # commit the pending cache lines to the actual cache, now that
1393 # we've printed our output
1394 %tweet_cache = ( %tweet_cache, %new_cache );
1396 # keep enough cached tweets, to make sure we don't show duplicates.
1397 foreach ( keys %tweet_cache ) {
1398 next if $tweet_cache{$_} >= $last_poll - 3600;
1399 delete $tweet_cache{$_};
1401 $last_poll = $new_last_poll;
1403 # make sure the pid is removed from the waitpid list
1404 Irssi::pidwait_remove($child_pid);
1406 # and that we don't leave any zombies behind, somehow
1412 Irssi::settings_get_str("twirssi_replies_store") )
1414 if ( open JSON, ">$file" ) {
1415 print JSON JSON::Any->objToJson( \%id_map );
1418 &ccrap("Failed to write replies to $file: $!");
1429 if ( $attempt < 24 ) {
1430 Irssi::timeout_add_once( 5000, 'monitor_child',
1431 [ $filename, $attempt + 1 ] );
1433 print "Giving up on polling $filename" if &debug;
1434 Irssi::pidwait_remove($child_pid);
1436 unlink $filename unless &debug;
1438 return unless Irssi::settings_get_bool("twirssi_notify_timeouts");
1441 my @time = localtime($last_poll);
1442 if ( time - $last_poll < 24 * 60 * 60 ) {
1443 $since = sprintf( "%d:%02d", @time[ 2, 1 ] );
1445 $since = scalar localtime($last_poll);
1448 if ( not $failwhale and time - $last_poll > 60 * 60 ) {
1453 q{ .--./ / | _.---.| },
1465 if ( time - $last_poll < 600 ) {
1466 &ccrap("Haven't been able to get updated tweets since $since");
1472 return Irssi::settings_get_bool("twirssi_debug");
1476 $window->print( "%R***%n @_", MSGLEVEL_PUBLIC );
1480 $window->print( "%R***%n @_", MSGLEVEL_CLIENTCRAP );
1486 if ( Irssi::settings_get_bool("tweet_to_away")
1488 and $data !~ /^[dD] / )
1491 Irssi::server_find_tag( Irssi::settings_get_str("bitlbee_server") );
1493 $server->send_raw("away :$data");
1496 &ccrap( "Can't find bitlbee server.",
1497 "Update bitlbee_server or disable tweet_to_away" );
1507 my $noalert = shift;
1509 if ( length $data > 140 ) {
1510 ¬ice( "Tweet too long (" . length($data) . " characters) - aborted" )
1518 sub valid_username {
1519 my $username = shift;
1521 $username = &normalize_username($username);
1523 unless ( exists $twits{$username} ) {
1524 ¬ice("Unknown username $username");
1534 ¬ice("Not logged in! Use /twitter_login username pass!");
1542 my ( $complist, $window, $word, $linestart, $want_space ) = @_;
1545 $linestart =~ /^\/(?:retweet|twitter_reply)(?:_as)?\s*$/
1546 or ( Irssi::settings_get_bool("twirssi_use_reply_aliases")
1547 and $linestart =~ /^\/reply(?:_as)?\s*$/ )
1549 { # /twitter_reply gets a nick:num
1551 @$complist = map { "$_:$id_map{__indexes}{$_}" }
1552 sort { $nicks{$b} <=> $nicks{$a} }
1554 keys %{ $id_map{__indexes} };
1557 if ( $linestart =~ /^\/(twitter_unfriend|twitter_add_follow_extra|twitter_del_follow_extra)\s*$/ )
1558 { # /twitter_unfriend gets a nick
1560 push @$complist, grep /^\Q$word/i,
1561 sort { $nicks{$b} <=> $nicks{$a} } keys %nicks;
1564 # /tweet, /tweet_as, /dm, /dm_as - complete @nicks (and nicks as the first
1566 if ( $linestart =~ /^\/(?:tweet|dm)/ ) {
1567 my $prefix = $word =~ s/^@//;
1568 $prefix = 0 if $linestart eq '/dm' or $linestart eq '/dm_as';
1569 push @$complist, grep /^\Q$word/i,
1570 sort { $nicks{$b} <=> $nicks{$a} } keys %nicks;
1571 @$complist = map { "\@$_" } @$complist if $prefix;
1575 sub event_send_text {
1576 my ( $line, $server, $win ) = @_;
1577 my $awin = Irssi::active_win();
1579 # if the window where we got our text was the twitter window, and the user
1580 # wants to be lazy, tweet away!
1581 if ( ( $awin->get_active_name() eq $window->{name} )
1582 and Irssi::settings_get_bool("tweet_window_input") )
1584 &cmd_tweet( $line, $server, $win );
1589 my $poll = Irssi::settings_get_int("twitter_poll_interval");
1590 return $poll if $poll >= 60;
1597 if ( Irssi::settings_get_str("twirssi_nick_color") ) {
1598 my $c = Irssi::settings_get_str("twirssi_nick_color");
1599 $c = $irssi_to_mirc_colors{$c};
1600 $text =~ s/(^|\W)\@([-\w]+)/$1\cC$c\@$2\cO/g if $c;
1602 if ( Irssi::settings_get_str("twirssi_topic_color") ) {
1603 my $c = Irssi::settings_get_str("twirssi_topic_color");
1604 $c = $irssi_to_mirc_colors{$c};
1605 $text =~ s/(^|\W)(\#|\!)([-\w]+)/$1\cC$c$2$3\cO/g if $c;
1607 $text =~ s/[\n\r]/ /g;
1615 my $provider = Irssi::settings_get_str("short_url_provider");
1618 Irssi::settings_get_bool("twirssi_always_shorten")
1619 or &too_long( $data, 1 )
1625 if ( $provider eq 'Bitly' ) {
1626 @args[ 1, 2 ] = split ',',
1627 Irssi::settings_get_str("short_url_args"), 2;
1628 unless ( @args == 3 ) {
1630 "WWW::Shorten::Bitly requires a username and API key.",
1631 "Set short_url_args to username,API_key or change your",
1632 "short_url_provider."
1634 return decode "utf8", $data;
1638 foreach my $url ( $data =~ /(https?:\/\/\S+[\w\/])/g ) {
1641 my $short = makeashorterlink(@args);
1643 $data =~ s/\Q$url/$short/g;
1645 ¬ice("Failed to shorten $url!");
1651 return decode "utf8", $data;
1654 sub normalize_username {
1657 my ( $username, $service ) = split /\@/, $user, 2;
1659 $service = ucfirst lc $service;
1662 ucfirst lc Irssi::settings_get_str("twirssi_default_service");
1663 unless ( exists $twits{"$username\@$service"} ) {
1665 foreach my $t ( sort keys %twits ) {
1666 next unless $t =~ /^\Q$username\E\@(Twitter|Identica)/;
1672 ¬ice("Can't find a logged in user '$user'");
1677 return "$username\@$service";
1680 Irssi::signal_add( "send text", "event_send_text" );
1682 Irssi::theme_register(
1684 'twirssi_tweet', '[$0%B@$1%n$2] $3',
1685 'twirssi_search', '[$0%r$1%n:%B@$2%n$3] $4',
1686 'twirssi_reply', '[$0\--> %B@$1%n$2] $3',
1687 'twirssi_dm', '[$0%r@$1%n (%WDM%n)] $2',
1688 'twirssi_error', 'ERROR: $0',
1692 Irssi::settings_add_int( "twirssi", "twitter_poll_interval", 300 );
1693 Irssi::settings_add_str( "twirssi", "twitter_window", "twitter" );
1694 Irssi::settings_add_str( "twirssi", "bitlbee_server", "bitlbee" );
1695 Irssi::settings_add_str( "twirssi", "short_url_provider", "TinyURL" );
1696 Irssi::settings_add_str( "twirssi", "short_url_args", undef );
1697 Irssi::settings_add_str( "twirssi", "twitter_usernames", undef );
1698 Irssi::settings_add_str( "twirssi", "twitter_passwords", undef );
1699 Irssi::settings_add_str( "twirssi", "twirssi_default_service", "Twitter" );
1700 Irssi::settings_add_str( "twirssi", "twirssi_nick_color", "%B" );
1701 Irssi::settings_add_str( "twirssi", "twirssi_topic_color", "%r" );
1702 Irssi::settings_add_str( "twirssi", "twirssi_retweet_format",
1703 'RT $n: "$t" ${-- $c$}' );
1704 Irssi::settings_add_str( "twirssi", "twirssi_location",
1705 ".irssi/scripts/twirssi.pl" );
1706 Irssi::settings_add_str( "twirssi", "twirssi_replies_store",
1707 ".irssi/scripts/twirssi.json" );
1709 Irssi::settings_add_int( "twirssi", "twitter_friends_poll", 600 );
1710 Irssi::settings_add_int( "twirssi", "twitter_timeout", 30 );
1712 Irssi::settings_add_bool( "twirssi", "twirssi_upgrade_beta", 0 );
1713 Irssi::settings_add_bool( "twirssi", "tweet_to_away", 0 );
1714 Irssi::settings_add_bool( "twirssi", "show_reply_context", 0 );
1715 Irssi::settings_add_bool( "twirssi", "show_own_tweets", 1 );
1716 Irssi::settings_add_bool( "twirssi", "twirssi_debug", 0 );
1717 Irssi::settings_add_bool( "twirssi", "twirssi_first_run", 1 );
1718 Irssi::settings_add_bool( "twirssi", "twirssi_track_replies", 1 );
1719 Irssi::settings_add_bool( "twirssi", "twirssi_replies_autonick", 1 );
1720 Irssi::settings_add_bool( "twirssi", "twirssi_use_reply_aliases", 0 );
1721 Irssi::settings_add_bool( "twirssi", "twirssi_notify_timeouts", 1 );
1722 Irssi::settings_add_bool( "twirssi", "twirssi_hilights", 1 );
1723 Irssi::settings_add_bool( "twirssi", "twirssi_always_shorten", 0 );
1724 Irssi::settings_add_bool( "twirssi", "tweet_window_input", 0 );
1725 Irssi::settings_add_bool( "twirssi", "twirssi_avoid_ssl", 0 );
1727 $last_poll = time - &get_poll_time;
1728 $window = Irssi::window_find_name( Irssi::settings_get_str('twitter_window') );
1731 ->print( "Couldn't find a window named '"
1732 . Irssi::settings_get_str('twitter_window')
1733 . "', trying to create it." );
1735 Irssi::Windowitem::window_create(
1736 Irssi::settings_get_str('twitter_window'), 1 );
1737 $window->set_name( Irssi::settings_get_str('twitter_window') );
1741 Irssi::command_bind( "dm", "cmd_direct" );
1742 Irssi::command_bind( "dm_as", "cmd_direct_as" );
1743 Irssi::command_bind( "tweet", "cmd_tweet" );
1744 Irssi::command_bind( "tweet_as", "cmd_tweet_as" );
1745 Irssi::command_bind( "retweet", "cmd_retweet" );
1746 Irssi::command_bind( "retweet_as", "cmd_retweet_as" );
1747 Irssi::command_bind( "twitter_reply", "cmd_reply" );
1748 Irssi::command_bind( "twitter_reply_as", "cmd_reply_as" );
1749 Irssi::command_bind( "twitter_login", "cmd_login" );
1750 Irssi::command_bind( "twitter_logout", "cmd_logout" );
1751 Irssi::command_bind( "twitter_switch", "cmd_switch" );
1752 Irssi::command_bind( "twitter_subscribe", "cmd_add_search" );
1753 Irssi::command_bind( "twitter_unsubscribe", "cmd_del_search" );
1754 Irssi::command_bind( "twitter_list_subscriptions", "cmd_list_search" );
1755 Irssi::command_bind( "twirssi_upgrade", "cmd_upgrade" );
1756 Irssi::command_bind( "twitter_updates", "get_updates" );
1757 Irssi::command_bind( "twitter_add_follow_extra", "cmd_add_follow" );
1758 Irssi::command_bind( "twitter_del_follow_extra", "cmd_del_follow" );
1759 Irssi::command_bind( "twitter_list_follow_extra", "cmd_list_follow" );
1760 Irssi::command_bind( "bitlbee_away", "update_away" );
1761 if ( Irssi::settings_get_bool("twirssi_use_reply_aliases") ) {
1762 Irssi::command_bind( "reply", "cmd_reply" );
1763 Irssi::command_bind( "reply_as", "cmd_reply_as" );
1765 Irssi::command_bind(
1768 print "twits: ", join ", ",
1769 map { "u: $_->{username}\@" . ref($_) } values %twits;
1770 print "selected: $user\@$defservice";
1771 print "friends: ", join ", ", sort keys %friends;
1772 print "nicks: ", join ", ", sort keys %nicks;
1773 print "searches: ", Dumper \%{ $id_map{__searches} };
1774 print "last poll: $last_poll";
1775 if ( open DUMP, ">/tmp/twirssi.cache.txt" ) {
1776 print DUMP Dumper \%tweet_cache;
1778 print "cache written out to /tmp/twirssi.cache.txt";
1782 Irssi::command_bind(
1786 "Twirssi v$VERSION (r$REV); "
1788 $Net::Twitter::VERSION
1789 ? "Net::Twitter v$Net::Twitter::VERSION. "
1793 $Net::Identica::VERSION
1794 ? "Net::Identica v$Net::Identica::VERSION. "
1798 . JSON::Any::handler()
1799 . ". See details at http://twirssi.com/"
1803 Irssi::command_bind(
1806 "/twitter_follow <username>",
1808 sub { ¬ice("Following $_[0]"); $nicks{ $_[0] } = time; }
1811 Irssi::command_bind(
1814 "/twitter_unfriend <username>",
1816 sub { ¬ice("Stopped following $_[0]"); delete $nicks{ $_[0] }; }
1819 Irssi::command_bind(
1820 "twitter_device_updates",
1822 "/twitter_device_updates none|im|sms",
1823 "update_delivery_device",
1824 sub { ¬ice("Device updated to $_[0]"); }
1827 Irssi::command_bind(
1830 "/twitter_block <username>",
1832 sub { ¬ice("Blocked $_[0]"); }
1835 Irssi::command_bind(
1838 "/twitter_unblock <username>",
1840 sub { ¬ice("Unblock $_[0]"); }
1843 Irssi::signal_add_last( 'complete word' => \&sig_complete );
1845 ¬ice(" %Y<%C(%B^%C)%N TWIRSSI v%R$VERSION%N (r$REV)");
1846 ¬ice(" %C(_(\\%N http://twirssi.com/ for full docs");
1848 " %Y||%C `%N Log in with /twitter_login, send updates with /tweet");
1850 my $file = Irssi::settings_get_str("twirssi_replies_store");
1851 if ( $file and -r $file ) {
1852 if ( open( JSON, $file ) ) {
1857 my $ref = JSON::Any->jsonToObj($json);
1859 my $num = keys %{ $id_map{__indexes} };
1860 ¬ice( sprintf "Loaded old replies from %d contact%s.",
1861 $num, ( $num == 1 ? "" : "s" ) );
1866 ¬ice("Failed to load old replies from $file: $!");
1870 if ( my $provider = Irssi::settings_get_str("short_url_provider") ) {
1871 ¬ice("Loading WWW::Shorten::$provider...");
1872 eval "use WWW::Shorten::$provider;";
1876 "Failed to load WWW::Shorten::$provider - either clear",
1877 "short_url_provider or install the CPAN module"
1882 if ( my $autouser = Irssi::settings_get_str("twitter_usernames")
1883 and my $autopass = Irssi::settings_get_str("twitter_passwords") )
1891 ->print( "Create a window named "
1892 . Irssi::settings_get_str('twitter_window')
1893 . " or change the value of twitter_window. Then, reload twirssi." );
1896 # vim: set sts=4 expandtab: