10 use POSIX qw/:sys_wait_h/;
11 $Data::Dumper::Indent = 1;
13 use vars qw($VERSION %IRSSI);
15 $VERSION = "2.3.4beta";
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 my $modified = $data;
180 $data = &shorten($text);
182 return if $modified and &too_long($data);
188 $success = $twits{$username}->update(
192 # in_reply_to_status_id => $id_map{ lc $nick }[$id]
197 $twits{$username}->retweet( { id => $id_map{ lc $nick }[$id] } );
198 $success = $success->{id} if ref $success;
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.05";
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 = &get_text( $t, $obj );
974 if ( Irssi::settings_get_bool("show_reply_context")
975 and $t->{in_reply_to_screen_name} ne $username
976 and $t->{in_reply_to_screen_name}
977 and not exists $friends{ $t->{in_reply_to_screen_name} } )
979 $nicks{ $t->{in_reply_to_screen_name} } = time;
981 unless ( $cache->{ $t->{in_reply_to_status_id} } ) {
983 $cache->{ $t->{in_reply_to_status_id} } =
984 $obj->show_status( $t->{in_reply_to_status_id} );
988 $context = $cache->{ $t->{in_reply_to_status_id} };
991 my $ctext = &get_text( $context, $obj );
992 printf $fh "id:%s account:%s nick:%s type:tweet %s\n",
993 $context->{id}, $username,
994 $context->{user}{screen_name}, $ctext;
999 if $t->{user}{screen_name} eq $username
1000 and not Irssi::settings_get_bool("show_own_tweets");
1001 printf $fh "id:%s account:%s nick:%s type:%s %s\n",
1002 $t->{id}, $username, $t->{user}{screen_name}, $reply, $text;
1003 $new_poll_id = $t->{id} if $new_poll_id < $t->{id};
1005 printf $fh "id:%s account:%s type:last_id timeline\n",
1006 $new_poll_id, $username;
1008 print scalar localtime, " - Polling for replies since ",
1009 $id_map{__last_id}{$username}{reply}
1013 if ( $id_map{__last_id}{$username}{reply} )
1015 $tweets = $obj->replies(
1016 { since_id => $id_map{__last_id}{$username}{reply} } )
1019 $tweets = $obj->replies() || [];
1024 print $fh "type:debug Error during replies call. Aborted.\n";
1028 foreach my $t ( reverse @$tweets ) {
1030 if exists $friends{ $t->{user}{screen_name} };
1032 my $text = &get_text( $t, $obj );
1033 printf $fh "id:%s account:%s nick:%s type:tweet %s\n",
1034 $t->{id}, $username, $t->{user}{screen_name}, $text;
1035 $new_poll_id = $t->{id} if $new_poll_id < $t->{id};
1037 printf $fh "id:%s account:%s type:last_id reply\n", $new_poll_id, $username;
1039 print scalar localtime, " - Polling for DMs" if &debug;
1042 if ( $id_map{__last_id}{$username}{dm} )
1044 $tweets = $obj->direct_messages(
1045 { since_id => $id_map{__last_id}{$username}{dm} } )
1048 $tweets = $obj->direct_messages() || [];
1053 print $fh "type:debug Error during direct_messages call. Aborted.\n";
1057 foreach my $t ( reverse @$tweets ) {
1058 my $text = decode_entities( $t->{text} );
1059 $text =~ s/[\n\r]/ /g;
1060 printf $fh "id:%s account:%s nick:%s type:dm %s\n",
1061 $t->{id}, $username, $t->{sender_screen_name}, $text;
1062 $new_poll_id = $t->{id} if $new_poll_id < $t->{id};
1064 printf $fh "id:%s account:%s type:last_id dm\n", $new_poll_id, $username;
1066 print scalar localtime, " - Polling for subscriptions" if &debug;
1067 if ( $obj->can('search') and $id_map{__searches}{$username} ) {
1069 foreach my $topic ( sort keys %{ $id_map{__searches}{$username} } ) {
1070 print $fh "type:debug searching for $topic since ",
1071 "$id_map{__searches}{$username}{$topic}\n";
1073 $search = $obj->search(
1076 since_id => $id_map{__searches}{$username}{$topic}
1083 "type:debug Error during search($topic) call. Aborted.\n";
1087 unless ( $search->{max_id} ) {
1088 print $fh "type:debug Invalid search results when searching",
1089 " for $topic. Aborted.\n";
1093 $id_map{__searches}{$username}{$topic} = $search->{max_id};
1094 printf $fh "id:%s account:%s type:searchid topic:%s\n",
1095 $search->{max_id}, $username, $topic;
1097 foreach my $t ( reverse @{ $search->{results} } ) {
1098 my $text = &get_text( $t, $obj );
1099 printf $fh "id:%s account:%s nick:%s type:search topic:%s %s\n",
1100 $t->{id}, $username, $t->{from_user}, $topic, $text;
1101 $new_poll_id = $t->{id}
1103 or $t->{id} < $new_poll_id;
1108 print scalar localtime, " - Done" if &debug;
1114 my ( $fh, $target, $username, $obj, $cache ) = @_;
1116 my $last_id = $id_map{__last_id}{$username}{$target};
1118 print $fh "type:debug get_timeline("
1119 . "$fix_replies_index{$username}=$target > $last_id) started."
1120 . " username = $username\n";
1122 $tweets = $obj->user_timeline(
1125 ( $last_id ? ( since_id => $last_id ) : () ),
1132 "type:debug Error during user_timeline($target) call: Aborted.\n";
1133 print $fh "type:debug : $_\n" foreach split /\n/, Dumper($@);
1139 "type:debug user_timeline($target) call returned undef! Aborted\n";
1143 foreach my $t ( reverse @$tweets ) {
1144 my $text = &get_text( $t, $obj );
1145 my $reply = "tweet";
1146 if ( Irssi::settings_get_bool("show_reply_context")
1147 and $t->{in_reply_to_screen_name} ne $username
1148 and $t->{in_reply_to_screen_name}
1149 and not exists $friends{ $t->{in_reply_to_screen_name} } )
1151 $nicks{ $t->{in_reply_to_screen_name} } = time;
1153 unless ( $cache->{ $t->{in_reply_to_status_id} } ) {
1155 $cache->{ $t->{in_reply_to_status_id} } =
1156 $obj->show_status( $t->{in_reply_to_status_id} );
1160 $context = $cache->{ $t->{in_reply_to_status_id} };
1163 my $ctext = &get_text( $context, $obj );
1164 printf $fh "id:%s account:%s nick:%s type:tweet %s\n",
1165 $context->{id}, $username,
1166 $context->{user}{screen_name}, $ctext;
1170 printf $fh "id:%s account:%s nick:%s type:%s %s\n",
1171 $t->{id}, $username, $t->{user}{screen_name}, $reply, $text;
1172 $last_id = $t->{id} if $last_id < $t->{id};
1174 printf $fh "id:%s account:%s type:last_id_fixreplies %s\n",
1175 $last_id, $username, $target;
1182 my $filename = $data->[0];
1183 my $attempt = $data->[1];
1185 print scalar localtime, " - checking child log at $filename ($attempt)"
1187 my ($new_last_poll);
1189 # reap any random leftover processes - work around a bug in irssi on gentoo
1190 waitpid(-1, WNOHANG);
1192 # first time we run we don't want to print out *everything*, so we just
1195 if ( open FILE, $filename ) {
1196 binmode FILE, ":utf8";
1200 last if /^__friends__/;
1201 unless (/\n$/) { # skip partial lines
1202 # print "Skipping partial line: $_" if &debug;
1209 foreach my $key (qw/id account nick type topic/) {
1210 if (s/^$key:(\S+)\s*//) {
1215 if ( $meta{type} and $meta{type} eq 'fix_replies_index' ) {
1216 $fix_replies_index{ $meta{account} } = $meta{id};
1217 print "fix_replies_index for $meta{account} set to $meta{id}"
1222 if ( not $meta{type} or $meta{type} !~ /searchid|last_id/ ) {
1223 if ( exists $meta{id} and exists $new_cache{ $meta{id} } ) {
1227 $new_cache{ $meta{id} } = time;
1229 if ( exists $meta{id} and exists $tweet_cache{ $meta{id} } ) {
1235 $meta{account} =~ s/\@(\w+)$//;
1236 $meta{service} = $1;
1238 lc $meta{service} eq
1239 lc Irssi::settings_get_str("twirssi_default_service") )
1241 $account = "$meta{account}: "
1242 if lc "$meta{account}\@$meta{service}" ne lc
1243 "$user\@$defservice";
1245 $account = "$meta{account}\@$meta{service}: ";
1249 if ( $meta{type} ne 'dm'
1250 and Irssi::settings_get_bool("twirssi_track_replies")
1254 $marker = ( $id_map{__indexes}{ $meta{nick} } + 1 ) % 100;
1255 $id_map{ lc $meta{nick} }[$marker] = $meta{id};
1256 $id_map{__indexes}{ $meta{nick} } = $marker;
1257 $id_map{__tweets}{ lc $meta{nick} }[$marker] = $_;
1258 $marker = ":$marker";
1262 $irssi_to_mirc_colors{ Irssi::settings_get_str("hilight_color") };
1263 my $nick = "\@$meta{account}";
1264 if ( $_ =~ /\Q$nick\E(?:\W|$)/i
1265 and Irssi::settings_get_bool("twirssi_hilights") )
1267 $meta{nick} = "\cC$hilight_color$meta{nick}\cO";
1268 $hilight = MSGLEVEL_HILIGHT;
1271 if ( $meta{type} =~ /tweet|reply/ ) {
1274 ( MSGLEVEL_PUBLIC | $hilight ),
1275 $meta{type}, $account, $meta{nick}, $marker, $_
1277 } elsif ( $meta{type} eq 'search' ) {
1280 ( MSGLEVEL_PUBLIC | $hilight ),
1281 $meta{type}, $account, $meta{topic},
1282 $meta{nick}, $marker, $_
1285 exists $id_map{__searches}{ $meta{account} }{ $meta{topic} }
1287 $id_map{__searches}{ $meta{account} }{ $meta{topic} } )
1289 $id_map{__searches}{ $meta{account} }{ $meta{topic} } =
1292 } elsif ( $meta{type} eq 'dm' ) {
1295 ( MSGLEVEL_MSGS | $hilight ),
1296 $meta{type}, $account, $meta{nick}, $_
1298 } elsif ( $meta{type} eq 'searchid' ) {
1299 print "Search '$meta{topic}' returned id $meta{id}" if &debug;
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 print "Search '$meta{topic}' returned invalid id $meta{id}";
1311 } elsif ( $meta{type} eq 'last_id' ) {
1312 $id_map{__last_id}{"$meta{account}\@$meta{service}"}{$_} =
1314 if $id_map{__last_id}{"$meta{account}\@$meta{service}"}{$_} <
1316 } elsif ( $meta{type} eq 'last_id_fixreplies' ) {
1317 $id_map{__last_id}{"$meta{account}\@$meta{service}"}{$_} =
1319 if $id_map{__last_id}{"$meta{account}\@$meta{service}"}{$_} <
1321 } elsif ( $meta{type} eq 'error' ) {
1322 push @lines, [ MSGLEVEL_MSGS, $_ ];
1323 } elsif ( $meta{type} eq 'debug' ) {
1324 print "$_" if &debug,;
1326 print "Unknown line type $meta{type}: $_" if &debug,;
1332 if (/^__updated (\d+)$/) {
1333 $last_friends_poll = $1;
1334 print "Friend list updated" if &debug;
1339 $new_last_poll = $1;
1340 if ( $new_last_poll >= $last_poll ) {
1343 print "Impossible! ",
1344 "new_last_poll=$new_last_poll < last_poll=$last_poll!"
1346 undef $new_last_poll;
1350 my ( $f, $t ) = split ' ', $_;
1351 $nicks{$f} = $friends{$f} = $t;
1354 if ($new_last_poll) {
1355 print "new last_poll = $new_last_poll" if &debug;
1356 print "new last_poll_id = ", Dumper( $id_map{__last_id} ) if &debug;
1358 print "First call, not printing updates" if &debug;
1360 foreach my $line (@lines) {
1361 $window->printformat(
1363 "twirssi_" . $line->[1],
1364 @$line[ 2 .. $#$line - 1 ],
1365 &hilight( $line->[-1] )
1372 or warn "Failed to remove $filename: $!"
1375 # commit the pending cache lines to the actual cache, now that
1376 # we've printed our output
1377 %tweet_cache = ( %tweet_cache, %new_cache );
1379 # keep enough cached tweets, to make sure we don't show duplicates.
1380 foreach ( keys %tweet_cache ) {
1381 next if $tweet_cache{$_} >= $last_poll - 3600;
1382 delete $tweet_cache{$_};
1384 $last_poll = $new_last_poll;
1386 # make sure the pid is removed from the waitpid list
1387 Irssi::pidwait_remove($child_pid);
1389 # and that we don't leave any zombies behind, somehow
1395 Irssi::settings_get_str("twirssi_replies_store") )
1397 if ( open JSON, ">$file" ) {
1398 print JSON JSON::Any->objToJson( \%id_map );
1401 &ccrap("Failed to write replies to $file: $!");
1412 if ( $attempt < 24 ) {
1413 Irssi::timeout_add_once( 5000, 'monitor_child',
1414 [ $filename, $attempt + 1 ] );
1416 print "Giving up on polling $filename" if &debug;
1417 Irssi::pidwait_remove($child_pid);
1419 unlink $filename unless &debug;
1421 return unless Irssi::settings_get_bool("twirssi_notify_timeouts");
1424 my @time = localtime($last_poll);
1425 if ( time - $last_poll < 24 * 60 * 60 ) {
1426 $since = sprintf( "%d:%02d", @time[ 2, 1 ] );
1428 $since = scalar localtime($last_poll);
1431 if ( not $failwhale and time - $last_poll > 60 * 60 ) {
1436 q{ .--./ / | _.---.| },
1448 if ( time - $last_poll < 600 ) {
1449 &ccrap("Haven't been able to get updated tweets since $since");
1455 return Irssi::settings_get_bool("twirssi_debug");
1459 $window->print( "%R***%n @_", MSGLEVEL_PUBLIC );
1463 $window->print( "%R***%n @_", MSGLEVEL_CLIENTCRAP );
1469 if ( Irssi::settings_get_bool("tweet_to_away")
1471 and $data !~ /^[dD] / )
1474 Irssi::server_find_tag( Irssi::settings_get_str("bitlbee_server") );
1476 $server->send_raw("away :$data");
1479 &ccrap( "Can't find bitlbee server.",
1480 "Update bitlbee_server or disable tweet_to_away" );
1490 my $noalert = shift;
1492 if ( length $data > 140 ) {
1493 ¬ice( "Tweet too long (" . length($data) . " characters) - aborted" )
1501 sub valid_username {
1502 my $username = shift;
1504 $username = &normalize_username($username);
1506 unless ( exists $twits{$username} ) {
1507 ¬ice("Unknown username $username");
1517 ¬ice("Not logged in! Use /twitter_login username pass!");
1525 my ( $complist, $window, $word, $linestart, $want_space ) = @_;
1528 $linestart =~ /^\/(?:retweet|twitter_reply)(?:_as)?\s*$/
1529 or ( Irssi::settings_get_bool("twirssi_use_reply_aliases")
1530 and $linestart =~ /^\/reply(?:_as)?\s*$/ )
1532 { # /twitter_reply gets a nick:num
1534 @$complist = map { "$_:$id_map{__indexes}{$_}" }
1535 sort { $nicks{$b} <=> $nicks{$a} }
1537 keys %{ $id_map{__indexes} };
1541 /^\/(twitter_unfriend|twitter_add_follow_extra|twitter_del_follow_extra)\s*$/
1543 { # /twitter_unfriend gets a nick
1545 push @$complist, grep /^\Q$word/i,
1546 sort { $nicks{$b} <=> $nicks{$a} } keys %nicks;
1549 # /tweet, /tweet_as, /dm, /dm_as - complete @nicks (and nicks as the first
1551 if ( $linestart =~ /^\/(?:tweet|dm)/ ) {
1552 my $prefix = $word =~ s/^@//;
1553 $prefix = 0 if $linestart eq '/dm' or $linestart eq '/dm_as';
1554 push @$complist, grep /^\Q$word/i,
1555 sort { $nicks{$b} <=> $nicks{$a} } keys %nicks;
1556 @$complist = map { "\@$_" } @$complist if $prefix;
1560 sub event_send_text {
1561 my ( $line, $server, $win ) = @_;
1562 my $awin = Irssi::active_win();
1564 # if the window where we got our text was the twitter window, and the user
1565 # wants to be lazy, tweet away!
1566 if ( ( $awin->get_active_name() eq $window->{name} )
1567 and Irssi::settings_get_bool("tweet_window_input") )
1569 &cmd_tweet( $line, $server, $win );
1574 my $poll = Irssi::settings_get_int("twitter_poll_interval");
1575 return $poll if $poll >= 60;
1582 if ( Irssi::settings_get_str("twirssi_nick_color") ) {
1583 my $c = Irssi::settings_get_str("twirssi_nick_color");
1584 $c = $irssi_to_mirc_colors{$c};
1585 $text =~ s/(^|\W)\@(\w+)/$1\cC$c\@$2\cO/g if $c;
1587 if ( Irssi::settings_get_str("twirssi_topic_color") ) {
1588 my $c = Irssi::settings_get_str("twirssi_topic_color");
1589 $c = $irssi_to_mirc_colors{$c};
1590 $text =~ s/(^|\W)(\#|\!)([-\w]+)/$1\cC$c$2$3\cO/g if $c;
1592 $text =~ s/[\n\r]/ /g;
1600 my $provider = Irssi::settings_get_str("short_url_provider");
1603 Irssi::settings_get_bool("twirssi_always_shorten")
1604 or &too_long( $data, 1 )
1610 if ( $provider eq 'Bitly' ) {
1611 @args[ 1, 2 ] = split ',',
1612 Irssi::settings_get_str("short_url_args"), 2;
1613 unless ( @args == 3 ) {
1615 "WWW::Shorten::Bitly requires a username and API key.",
1616 "Set short_url_args to username,API_key or change your",
1617 "short_url_provider."
1619 return decode "utf8", $data;
1623 foreach my $url ( $data =~ /(https?:\/\/\S+[\w\/])/g ) {
1626 my $short = makeashorterlink(@args);
1628 $data =~ s/\Q$url/$short/g;
1630 ¬ice("Failed to shorten $url!");
1636 return decode "utf8", $data;
1639 sub normalize_username {
1642 my ( $username, $service ) = split /\@/, $user, 2;
1644 $service = ucfirst lc $service;
1647 ucfirst lc Irssi::settings_get_str("twirssi_default_service");
1648 unless ( exists $twits{"$username\@$service"} ) {
1650 foreach my $t ( sort keys %twits ) {
1651 next unless $t =~ /^\Q$username\E\@(Twitter|Identica)/;
1657 ¬ice("Can't find a logged in user '$user'");
1662 return "$username\@$service";
1668 my $text = decode_entities( $tweet->{text} );
1669 if ( $tweet->{truncated} ) {
1670 if ( exists $tweet->{retweeted_status} ) {
1671 $text = "RT \@$tweet->{retweeted_status}{user}{screen_name}: "
1672 . "$tweet->{retweeted_status}{text}";
1673 } elsif ( $object->isa('Net::Twitter') ) {
1674 $text .= " -- http://twitter.com/$tweet->{user}{screen_name}"
1675 . "/status/$tweet->{id}";
1679 $text =~ s/[\n\r]/ /g;
1684 Irssi::signal_add( "send text", "event_send_text" );
1686 Irssi::theme_register(
1688 'twirssi_tweet', '[$0%B@$1%n$2] $3',
1689 'twirssi_search', '[$0%r$1%n:%B@$2%n$3] $4',
1690 'twirssi_reply', '[$0\--> %B@$1%n$2] $3',
1691 'twirssi_dm', '[$0%r@$1%n (%WDM%n)] $2',
1692 'twirssi_error', 'ERROR: $0',
1696 Irssi::settings_add_int( "twirssi", "twitter_poll_interval", 300 );
1697 Irssi::settings_add_str( "twirssi", "twitter_window", "twitter" );
1698 Irssi::settings_add_str( "twirssi", "bitlbee_server", "bitlbee" );
1699 Irssi::settings_add_str( "twirssi", "short_url_provider", "TinyURL" );
1700 Irssi::settings_add_str( "twirssi", "short_url_args", undef );
1701 Irssi::settings_add_str( "twirssi", "twitter_usernames", undef );
1702 Irssi::settings_add_str( "twirssi", "twitter_passwords", undef );
1703 Irssi::settings_add_str( "twirssi", "twirssi_default_service", "Twitter" );
1704 Irssi::settings_add_str( "twirssi", "twirssi_nick_color", "%B" );
1705 Irssi::settings_add_str( "twirssi", "twirssi_topic_color", "%r" );
1706 Irssi::settings_add_str( "twirssi", "twirssi_retweet_format",
1707 'RT $n: "$t" ${-- $c$}' );
1708 Irssi::settings_add_str( "twirssi", "twirssi_location",
1709 ".irssi/scripts/twirssi.pl" );
1710 Irssi::settings_add_str( "twirssi", "twirssi_replies_store",
1711 ".irssi/scripts/twirssi.json" );
1713 Irssi::settings_add_int( "twirssi", "twitter_friends_poll", 600 );
1714 Irssi::settings_add_int( "twirssi", "twitter_timeout", 30 );
1716 Irssi::settings_add_bool( "twirssi", "twirssi_upgrade_beta", 0 );
1717 Irssi::settings_add_bool( "twirssi", "tweet_to_away", 0 );
1718 Irssi::settings_add_bool( "twirssi", "show_reply_context", 0 );
1719 Irssi::settings_add_bool( "twirssi", "show_own_tweets", 1 );
1720 Irssi::settings_add_bool( "twirssi", "twirssi_debug", 0 );
1721 Irssi::settings_add_bool( "twirssi", "twirssi_first_run", 1 );
1722 Irssi::settings_add_bool( "twirssi", "twirssi_track_replies", 1 );
1723 Irssi::settings_add_bool( "twirssi", "twirssi_replies_autonick", 1 );
1724 Irssi::settings_add_bool( "twirssi", "twirssi_use_reply_aliases", 0 );
1725 Irssi::settings_add_bool( "twirssi", "twirssi_notify_timeouts", 1 );
1726 Irssi::settings_add_bool( "twirssi", "twirssi_hilights", 1 );
1727 Irssi::settings_add_bool( "twirssi", "twirssi_always_shorten", 0 );
1728 Irssi::settings_add_bool( "twirssi", "tweet_window_input", 0 );
1729 Irssi::settings_add_bool( "twirssi", "twirssi_avoid_ssl", 0 );
1731 $last_poll = time - &get_poll_time;
1732 $window = Irssi::window_find_name( Irssi::settings_get_str('twitter_window') );
1735 ->print( "Couldn't find a window named '"
1736 . Irssi::settings_get_str('twitter_window')
1737 . "', trying to create it." );
1739 Irssi::Windowitem::window_create(
1740 Irssi::settings_get_str('twitter_window'), 1 );
1741 $window->set_name( Irssi::settings_get_str('twitter_window') );
1745 Irssi::command_bind( "dm", "cmd_direct" );
1746 Irssi::command_bind( "dm_as", "cmd_direct_as" );
1747 Irssi::command_bind( "tweet", "cmd_tweet" );
1748 Irssi::command_bind( "tweet_as", "cmd_tweet_as" );
1749 Irssi::command_bind( "retweet", "cmd_retweet" );
1750 Irssi::command_bind( "retweet_as", "cmd_retweet_as" );
1751 Irssi::command_bind( "twitter_reply", "cmd_reply" );
1752 Irssi::command_bind( "twitter_reply_as", "cmd_reply_as" );
1753 Irssi::command_bind( "twitter_login", "cmd_login" );
1754 Irssi::command_bind( "twitter_logout", "cmd_logout" );
1755 Irssi::command_bind( "twitter_switch", "cmd_switch" );
1756 Irssi::command_bind( "twitter_subscribe", "cmd_add_search" );
1757 Irssi::command_bind( "twitter_unsubscribe", "cmd_del_search" );
1758 Irssi::command_bind( "twitter_list_subscriptions", "cmd_list_search" );
1759 Irssi::command_bind( "twirssi_upgrade", "cmd_upgrade" );
1760 Irssi::command_bind( "twitter_updates", "get_updates" );
1761 Irssi::command_bind( "twitter_add_follow_extra", "cmd_add_follow" );
1762 Irssi::command_bind( "twitter_del_follow_extra", "cmd_del_follow" );
1763 Irssi::command_bind( "twitter_list_follow_extra", "cmd_list_follow" );
1764 Irssi::command_bind( "bitlbee_away", "update_away" );
1765 if ( Irssi::settings_get_bool("twirssi_use_reply_aliases") ) {
1766 Irssi::command_bind( "reply", "cmd_reply" );
1767 Irssi::command_bind( "reply_as", "cmd_reply_as" );
1769 Irssi::command_bind(
1772 print "twits: ", join ", ",
1773 map { "u: $_->{username}\@" . ref($_) } values %twits;
1774 print "selected: $user\@$defservice";
1775 print "friends: ", join ", ", sort keys %friends;
1776 print "nicks: ", join ", ", sort keys %nicks;
1777 print "searches: ", Dumper \%{ $id_map{__searches} };
1778 print "last poll: $last_poll";
1779 if ( open DUMP, ">/tmp/twirssi.cache.txt" ) {
1780 print DUMP Dumper \%tweet_cache;
1782 print "cache written out to /tmp/twirssi.cache.txt";
1786 Irssi::command_bind(
1790 "Twirssi v$VERSION; "
1792 $Net::Twitter::VERSION
1793 ? "Net::Twitter v$Net::Twitter::VERSION. "
1797 $Net::Identica::VERSION
1798 ? "Net::Identica v$Net::Identica::VERSION. "
1802 . JSON::Any::handler()
1803 . ". See details at http://twirssi.com/"
1807 Irssi::command_bind(
1810 "/twitter_follow <username>",
1812 sub { ¬ice("Following $_[0]"); $nicks{ $_[0] } = time; }
1815 Irssi::command_bind(
1818 "/twitter_unfriend <username>",
1820 sub { ¬ice("Stopped following $_[0]"); delete $nicks{ $_[0] }; }
1823 Irssi::command_bind(
1824 "twitter_device_updates",
1826 "/twitter_device_updates none|im|sms",
1827 "update_delivery_device",
1828 sub { ¬ice("Device updated to $_[0]"); }
1831 Irssi::command_bind(
1834 "/twitter_block <username>",
1836 sub { ¬ice("Blocked $_[0]"); }
1839 Irssi::command_bind(
1842 "/twitter_unblock <username>",
1844 sub { ¬ice("Unblock $_[0]"); }
1847 Irssi::signal_add_last( 'complete word' => \&sig_complete );
1849 ¬ice(" %Y<%C(%B^%C)%N TWIRSSI v%R$VERSION%N");
1850 ¬ice(" %C(_(\\%N http://twirssi.com/ for full docs");
1852 " %Y||%C `%N Log in with /twitter_login, send updates with /tweet");
1854 my $file = Irssi::settings_get_str("twirssi_replies_store");
1855 if ( $file and -r $file ) {
1856 if ( open( JSON, $file ) ) {
1861 my $ref = JSON::Any->jsonToObj($json);
1863 my $num = keys %{ $id_map{__indexes} };
1864 ¬ice( sprintf "Loaded old replies from %d contact%s.",
1865 $num, ( $num == 1 ? "" : "s" ) );
1870 ¬ice("Failed to load old replies from $file: $!");
1874 if ( my $provider = Irssi::settings_get_str("short_url_provider") ) {
1875 ¬ice("Loading WWW::Shorten::$provider...");
1876 eval "use WWW::Shorten::$provider;";
1880 "Failed to load WWW::Shorten::$provider - either clear",
1881 "short_url_provider or install the CPAN module"
1886 if ( my $autouser = Irssi::settings_get_str("twitter_usernames")
1887 and my $autopass = Irssi::settings_get_str("twitter_passwords") )
1895 ->print( "Create a window named "
1896 . Irssi::settings_get_str('twitter_window')
1897 . " or change the value of twitter_window. Then, reload twirssi." );
1900 # vim: set sts=4 expandtab: