10 $Data::Dumper::Indent = 1;
12 use vars qw($VERSION %IRSSI);
15 my ($REV) = '$Rev: 379 $' =~ /(\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://tinyurl.com/twirssi',
24 changed => '$Date: 2009-01-21 09:50:42 -0800 (Wed, 21 Jan 2009) $',
34 my $last_poll = time - 300;
37 my %irssi_to_mirc_colors = (
57 my ( $data, $server, $win ) = @_;
59 return unless &logged_in($twit);
61 my ( $target, $text ) = split ' ', $data, 2;
62 unless ( $target and $text ) {
63 ¬ice("Usage: /dm <nick> <message>");
67 &cmd_direct_as( "$user $data", $server, $win );
71 my ( $data, $server, $win ) = @_;
73 return unless &logged_in($twit);
75 my ( $username, $target, $text ) = split ' ', $data, 3;
76 unless ( $username and $target and $text ) {
77 ¬ice("Usage: /dm_as <username> <nick> <message>");
81 return unless &valid_username($username);
84 unless ( $twits{$username}
85 ->new_direct_message( { user => $target, text => $text } ) )
87 ¬ice("DM to $target failed");
93 ¬ice("DM caused an error. Aborted");
97 ¬ice("DM sent to $target");
98 $nicks{$target} = time;
102 my ( $data, $server, $win ) = @_;
104 return unless &logged_in($twit);
106 $data =~ s/^\s+|\s+$//;
108 ¬ice("Usage: /tweet <update>");
112 &cmd_tweet_as( "$user $data", $server, $win );
116 my ( $data, $server, $win ) = @_;
118 return unless &logged_in($twit);
120 $data =~ s/^\s+|\s+$//;
121 my ( $username, $data ) = split ' ', $data, 2;
123 unless ( $username and $data ) {
124 ¬ice("Usage: /tweet_as <username> <update>");
128 return unless &valid_username($username);
130 if ( Irssi::settings_get_str("short_url_provider") ) {
131 foreach my $url ( $data =~ /(https?:\/\/\S+[\w\/])/g ) {
133 my $short = makeashorterlink($url);
134 $data =~ s/\Q$url/$short/g;
139 return if &too_long($data);
142 unless ( $twits{$username}->update($data) )
144 ¬ice("Update failed");
150 ¬ice("Update caused an error. Aborted.");
154 foreach ( $data =~ /@([-\w]+)/ ) {
158 my $away = &update_away($data);
160 ¬ice( "Update sent" . ( $away ? " (and away msg set)" : "" ) );
164 my ( $data, $server, $win ) = @_;
166 return unless &logged_in($twit);
168 $data =~ s/^\s+|\s+$//;
170 ¬ice("Usage: /reply <nick[:num]> <update>");
174 $data =~ s/^\s+|\s+$//;
175 my ( $id, $data ) = split ' ', $data, 2;
176 unless ( $id and $data ) {
177 ¬ice("Usage: /reply_as <nick[:num]> <update>");
181 &cmd_reply_as( "$user $id $data", $server, $win );
185 my ( $data, $server, $win ) = @_;
187 unless ( Irssi::settings_get_bool("twirssi_track_replies") ) {
188 ¬ice("twirssi_track_replies is required in order to reply to "
189 . "specific tweets. Either enable it, or just use /tweet "
190 . "\@username <text>." );
194 return unless &logged_in($twit);
196 $data =~ s/^\s+|\s+$//;
197 my ( $username, $id, $data ) = split ' ', $data, 3;
199 unless ( $username and $data ) {
200 ¬ice("Usage: /reply_as <username> <nick[:num]> <update>");
204 return unless &valid_username($username);
207 $id =~ s/[^\w\d\-:]+//g;
208 ( $nick, $id ) = split /:/, $id;
209 unless ( exists $id_map{ lc $nick } ) {
210 ¬ice("Can't find a tweet from $nick to reply to!");
214 $id = $id_map{__indexes}{$nick} unless $id;
215 unless ( $id_map{ lc $nick }[$id] ) {
216 ¬ice("Can't find a tweet numbered $id from $nick to reply to!");
220 # remove any @nick at the beginning of the reply, as we'll add it anyway
221 $data =~ s/^\s*\@?$nick\s*//;
222 $data = "\@$nick " . $data;
224 if ( Irssi::settings_get_str("short_url_provider") ) {
225 foreach my $url ( $data =~ /(https?:\/\/\S+[\w\/])/g ) {
227 my $short = makeashorterlink($url);
228 $data =~ s/\Q$url/$short/g;
233 return if &too_long($data);
237 $twits{$username}->update(
240 in_reply_to_status_id => $id_map{ lc $nick }[$id]
245 ¬ice("Update failed");
251 ¬ice("Update caused an error. Aborted");
255 foreach ( $data =~ /@([-\w]+)/ ) {
259 my $away = &update_away($data);
261 ¬ice( "Update sent" . ( $away ? " (and away msg set)" : "" ) );
265 my ( $usage_str, $api_name, $post_ref ) = @_;
268 my ( $data, $server, $win ) = @_;
270 return unless &logged_in($twit);
272 $data =~ s/^\s+|\s+$//;
274 ¬ice("Usage: $usage_str");
279 unless ( $twit->$api_name($data) )
281 ¬ice("$api_name failed");
287 ¬ice("$api_name caused an error. Aborted.");
291 &$post_ref($data) if $post_ref;
296 my ( $data, $server, $win ) = @_;
298 $data =~ s/^\s+|\s+$//g;
299 if ( exists $twits{$data} ) {
300 ¬ice("Switching to $data");
301 $twit = $twits{$data};
304 ¬ice("Unknown user $data");
309 my ( $data, $server, $win ) = @_;
311 $data =~ s/^\s+|\s+$//g;
312 return unless &valid_username($data);
315 ¬ice("Logging out $data...");
316 $twits{$data}->end_session();
317 delete $twits{$data};
319 ¬ice("Logging out $user...");
320 $twit->end_session();
322 delete $twits{$user};
324 &cmd_switch( ( keys %twits )[0], $server, $win );
326 Irssi::timeout_remove($poll) if $poll;
333 my ( $data, $server, $win ) = @_;
336 ( $user, $pass ) = split ' ', $data, 2;
337 } elsif ( my $autouser = Irssi::settings_get_str("twitter_usernames")
338 and my $autopass = Irssi::settings_get_str("twitter_passwords") )
340 my @user = split /\s*,\s*/, $autouser;
341 my @pass = split /\s*,\s*/, $autopass;
342 if ( @user != @pass ) {
343 ¬ice("Number of usernames doesn't match "
344 . "the number of passwords - auto-login failed" );
347 while ( @user and @pass ) {
355 ¬ice("/twitter_login requires either a username and password "
356 . "or twitter_usernames and twitter_passwords to be set." );
360 %friends = %nicks = ();
362 $twit = Net::Twitter->new(
368 unless ( $twit->verify_credentials() ) {
369 ¬ice("Login as $user failed");
372 &cmd_switch( ( keys %twits )[0], $server, $win );
378 my $rate_limit = $twit->rate_limit_status();
379 if ( $rate_limit and $rate_limit->{remaining_hits} < 1 ) {
380 ¬ice("Rate limit exceeded, try again later");
385 $twits{$user} = $twit;
386 Irssi::timeout_remove($poll) if $poll;
387 $poll = Irssi::timeout_add( 300 * 1000, \&get_updates, "" );
388 ¬ice("Logged in as $user, loading friends list...");
390 ¬ice( "loaded friends: ", scalar keys %friends );
391 if ( Irssi::settings_get_bool("twirssi_first_run") ) {
392 Irssi::settings_set_bool( "twirssi_first_run", 0 );
393 unless ( exists $friends{twirssi} ) {
394 ¬ice("Welcome to twirssi!"
395 . " Perhaps you should add \@twirssi to your friends list,"
396 . " so you can be notified when a new version is release?"
397 . " Just type /twitter_friend twirssi." );
404 ¬ice("Login failed");
409 my ( $data, $server, $win ) = @_;
411 my $loc = Irssi::settings_get_str("twirssi_location");
414 "$loc isn't writable, can't upgrade. Perhaps you need to /set twirssi_location?"
419 if ( not -x "/usr/bin/md5sum" and not $data ) {
421 "/usr/bin/md5sum can't be found - try '/twirssi_upgrade nomd5' to skip MD5 verification"
428 eval { use Digest::MD5; };
432 "Failed to load Digest::MD5. Try '/twirssi_upgrade nomd5' to skip MD5 verification"
437 $md5 = get("http://twirssi.com/md5sum");
441 ¬ice("Failed to download md5sum from peeron! Aborting.");
445 unless ( open( CUR, $loc ) ) {
447 "Failed to read $loc. Check that /set twirssi_location is set to the correct location."
452 my $cur_md5 = Digest::MD5::md5_hex(<CUR>);
455 if ( $cur_md5 eq $md5 ) {
456 ¬ice("Current twirssi seems to be up to date.");
461 my $URL = "http://twirssi.com/twirssi.pl";
462 ¬ice("Downloading twirssi from $URL");
463 LWP::Simple::getstore( $URL, "$loc.upgrade" );
466 unless ( open( NEW, "$loc.upgrade" ) ) {
468 "Failed to read $loc.upgrade. Check that /set twirssi_location is set to the correct location."
473 my $new_md5 = Digest::MD5::md5_hex(<NEW>);
476 if ( $new_md5 ne $md5 ) {
477 ¬ice("MD5 verification failed. expected $md5, got $new_md5");
482 rename $loc, "$loc.backup"
483 or ¬ice("Failed to back up $loc: $!. Aborting")
485 rename "$loc.upgrade", $loc
486 or ¬ice("Failed to rename $loc.upgrade: $!. Aborting")
489 my ( $dir, $file ) = ( $loc =~ m{(.*)/([^/]+)$} );
490 if ( -e "$dir/autorun/$file" ) {
491 ¬ice("Updating $dir/autorun/$file");
492 unlink "$dir/autorun/$file"
493 or ¬ice("Failed to remove old $file from autorun: $!");
494 symlink "../$file", "$dir/autorun/$file"
495 or ¬ice("Failed to create symlink in autorun directory: $!");
498 ¬ice("Download complete. Reload twirssi with /script load $file");
508 print $fh "type:debug Loading friends page $page...\n"
509 if ( $fh and &debug );
510 my $friends = $twit->friends( { page => $page } );
511 last unless $friends;
512 $new_friends{ $_->{screen_name} } = time foreach @$friends;
514 last if @$friends == 0 or $page == 10;
519 print $fh "type:debug Error during friends list update. Aborted.\n";
523 my ( $added, $removed ) = ( 0, 0 );
524 print $fh "type:debug Scanning for new friends...\n" if ( $fh and &debug );
525 foreach ( keys %new_friends ) {
526 next if exists $friends{$_};
531 print $fh "type:debug Scanning for removed friends...\n"
532 if ( $fh and &debug );
533 foreach ( keys %friends ) {
534 next if exists $new_friends{$_};
539 return ( $added, $removed );
543 print scalar localtime, " - get_updates starting" if &debug;
546 Irssi::window_find_name( Irssi::settings_get_str('twitter_window') );
549 ->print( "Can't find a window named '"
550 . Irssi::settings_get_str('twitter_window')
551 . "'. Create it or change the value of twitter_window" );
554 return unless &logged_in($twit);
556 my ( $fh, $filename ) = File::Temp::tempfile();
560 Irssi::timeout_add_once( 5000, 'monitor_child', [ $filename, 0 ] );
561 Irssi::pidwait_add($pid);
562 } elsif ( defined $pid ) { # child
570 $error += &do_updates( $fh, $user, $twit );
571 foreach ( keys %twits ) {
573 $error += &do_updates( $fh, $_, $twits{$_} );
576 my ( $added, $removed ) = &load_friends($fh);
577 if ( $added + $removed ) {
578 print $fh "type:debug %R***%n Friends list updated: ",
580 sprintf( "%d added", $added ),
581 sprintf( "%d removed", $removed ) ),
584 print $fh "__friends__\n";
585 foreach ( sort keys %friends ) {
586 print $fh "$_ $friends{$_}\n";
590 print $fh "type:debug Update encountered errors. Aborted\n";
591 print $fh $last_poll;
598 print scalar localtime, " - get_updates ends" if &debug;
602 my ( $fh, $username, $obj ) = @_;
604 print scalar localtime, " - Polling for updates for $username" if &debug;
607 $tweets = $obj->friends_timeline(
608 { since => HTTP::Date::time2str($last_poll) } );
612 print $fh "type:debug Error during friends_timeline call. Aborted.\n";
616 unless ( ref $tweets ) {
617 if ( $obj->can("get_error") ) {
619 eval { $error = JSON::Any->jsonToObj( $obj->get_error() ) };
620 if ($@) { $error = $obj->get_error() }
621 print $fh "type:debug API Error during friends_timeline call: ",
625 "type:debug API Error during friends_timeline call. Aborted.\n";
630 foreach my $t ( reverse @$tweets ) {
631 my $text = decode_entities( $t->{text} );
632 $text =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cO/g;
633 $text =~ s/[\n\r]/ /g;
635 if ( Irssi::settings_get_bool("show_reply_context")
636 and $t->{in_reply_to_screen_name} ne $username
637 and $t->{in_reply_to_screen_name}
638 and not exists $friends{ $t->{in_reply_to_screen_name} } )
640 $nicks{ $t->{in_reply_to_screen_name} } = time;
643 $context = $obj->show_status( $t->{in_reply_to_status_id} );
647 my $ctext = decode_entities( $context->{text} );
648 $ctext =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cO/g;
649 $ctext =~ s/[\n\r]/ /g;
650 printf $fh "id:%d account:%s nick:%s type:tweet %s\n",
651 $context->{id}, $username,
652 $context->{user}{screen_name}, $ctext;
655 print $fh "type:debug request to get context failed: $@";
658 "type:debug Failed to get context from $t->{in_reply_to_screen_name}"
663 if $t->{user}{screen_name} eq $username
664 and not Irssi::settings_get_bool("show_own_tweets");
665 printf $fh "id:%d account:%s nick:%s type:%s %s\n",
666 $t->{id}, $username, $t->{user}{screen_name}, $reply, $text;
669 print scalar localtime, " - Polling for replies" if &debug;
671 $tweets = $obj->replies( { since => HTTP::Date::time2str($last_poll) } )
676 print $fh "type:debug Error during replies call. Aborted.\n";
680 foreach my $t ( reverse @$tweets ) {
682 if exists $friends{ $t->{user}{screen_name} };
684 my $text = decode_entities( $t->{text} );
685 $text =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cO/g;
686 $text =~ s/[\n\r]/ /g;
687 printf $fh "id:%d account:%s nick:%s type:tweet %s\n",
688 $t->{id}, $username, $t->{user}{screen_name}, $text;
691 print scalar localtime, " - Polling for DMs" if &debug;
694 $obj->direct_messages( { since => HTTP::Date::time2str($last_poll) } )
699 print $fh "type:debug Error during direct_messages call. Aborted.\n";
703 foreach my $t ( reverse @$tweets ) {
704 my $text = decode_entities( $t->{text} );
705 $text =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cO/g;
706 $text =~ s/[\n\r]/ /g;
707 printf $fh "id:%d account:%s nick:%s type:dm %s\n",
708 $t->{id}, $username, $t->{sender_screen_name}, $text;
710 print scalar localtime, " - Done" if &debug;
717 my $filename = $data->[0];
718 my $attempt = $data->[1];
720 print scalar localtime, " - checking child log at $filename ($attempt)"
723 if ( open FILE, $filename ) {
727 last if /^__friends__/;
730 foreach my $key (qw/id account nick type/) {
731 if (s/^$key:(\S+)\s*//) {
736 next if exists $meta{id} and exists $tweet_cache{ $meta{id} };
737 $tweet_cache{ $meta{id} } = time;
739 if ( $meta{account} ne $user ) {
740 $account = "$meta{account}: ";
744 if ( $meta{type} ne 'dm'
745 and Irssi::settings_get_bool("twirssi_track_replies")
749 $marker = ( $id_map{__indexes}{ $meta{nick} } + 1 ) % 100;
750 $id_map{ lc $meta{nick} }[$marker] = $meta{id};
751 $id_map{__indexes}{ $meta{nick} } = $marker;
752 $marker = ":$marker";
755 my $hilight_color = $irssi_to_mirc_colors{Irssi::settings_get_str("hilight_color")};
756 if ( $_ =~ s/\@($meta{account})\W/\cC$hilight_color\@$1\cO/g ) {
757 $hilight = MSGLEVEL_HILIGHT;
760 if ( $meta{type} eq 'tweet' ) {
761 push @lines, [(MSGLEVEL_PUBLIC | $hilight), $meta{type}, $account, $meta{nick}, $marker, $_];
762 } elsif ( $meta{type} eq 'reply' ) {
763 push @lines, [(MSGLEVEL_PUBLIC | $hilight), $meta{type}, $account, $meta{nick}, $marker, $_];
764 } elsif ( $meta{type} eq 'dm' ) {
765 push @lines, [(MSGLEVEL_MSGS | $hilight), $meta{type}, $account, $meta{nick}, $_];
766 } elsif ( $meta{type} eq 'error' ) {
767 push @lines, [MSGLEVEL_MSGS, $_];
768 } elsif ( $meta{type} eq 'debug' ) {
769 print "$_" if &debug,;
771 print "Unknown line type $meta{type}: $_" if &debug,;
781 my ( $f, $t ) = split ' ', $_;
782 $nicks{$f} = $friends{$f} = $t;
785 if ($new_last_poll) {
786 print "new last_poll = $new_last_poll" if &debug;
787 for my $line ( @lines ) {
788 $window->printformat(@$line[0], "twirssi_".@$line[1],
794 or warn "Failed to remove $filename: $!"
797 # keep enough cached tweets, to make sure we don't show duplicates.
798 foreach ( keys %tweet_cache ) {
799 next if $tweet_cache{$_} >= $last_poll;
800 delete $tweet_cache{$_};
802 $last_poll = $new_last_poll;
807 Irssi::settings_get_str("twirssi_replies_store") )
809 if ( open JSON, ">$file" ) {
810 print JSON JSON::Any->objToJson( \%id_map );
813 ¬ice("Failed to write replies to $file: $!");
822 if ( $attempt < 12 ) {
823 Irssi::timeout_add_once( 5000, 'monitor_child',
824 [ $filename, $attempt + 1 ] );
826 ¬ice("Giving up on polling $filename");
827 unlink $filename unless &debug;
832 return Irssi::settings_get_bool("twirssi_debug");
836 $window->print( "%R***%n @_", MSGLEVEL_PUBLIC );
842 if ( Irssi::settings_get_bool("tweet_to_away")
844 and $data !~ /^[dD] / )
847 Irssi::server_find_tag( Irssi::settings_get_str("bitlbee_server") );
849 $server->send_raw("away :$data");
852 ¬ice( "Can't find bitlbee server.",
853 "Update bitlbee_server or disable tweet_to_away" );
864 if ( length $data > 140 ) {
866 "Tweet too long (" . length($data) . " characters) - aborted" );
874 my $username = shift;
876 unless ( exists $twits{$username} ) {
877 ¬ice("Unknown username $username");
887 ¬ice("Not logged in! Use /twitter_login username pass!");
895 my ( $complist, $window, $word, $linestart, $want_space ) = @_;
898 $linestart =~ /^\/twitter_reply(?:_as)?\s*$/
899 or ( Irssi::settings_get_bool("twirssi_use_reply_aliases")
900 and $linestart =~ /^\/reply(?:_as)?\s*$/ )
902 { # /twitter_reply gets a nick:num
904 @$complist = map { "$_:$id_map{__indexes}{$_}" } grep /^\Q$word/i,
905 sort keys %{ $id_map{__indexes} };
908 # /tweet, /tweet_as, /dm, /dm_as - complete @nicks (and nicks as the first
910 if ( $linestart =~ /^\/(?:tweet|dm)/ ) {
911 my $prefix = $word =~ s/^@//;
912 $prefix = 0 if $linestart eq '/dm' or $linestart eq '/dm_as';
913 push @$complist, grep /^\Q$word/i,
914 sort { $nicks{$b} <=> $nicks{$a} } keys %nicks;
915 @$complist = map { "\@$_" } @$complist if $prefix;
919 sub event_send_text {
920 my ( $line, $server, $win ) = @_;
921 my $awin = Irssi::active_win();
923 # if the window where we got our text was the twitter window, and the user
924 # wants to be lazy, tweet away!
925 if ( ( $awin->get_active_name() eq $window->{name} )
926 and Irssi::settings_get_bool("tweet_window_input") )
928 &cmd_tweet( $line, $server, $win );
932 Irssi::signal_add( "send text", "event_send_text" );
934 Irssi::theme_register([
935 'twirssi_tweet', '[$0%B@$1%n$2] $3',
936 'twirssi_reply', '[$0\--> %B@$1%n$2] $3',
937 'twirssi_dm', '[$0%B@$1%n (%WDM%n)] $2',
938 'twirssi_error', 'ERROR: $0',
941 Irssi::settings_add_str( "twirssi", "twitter_window", "twitter" );
942 Irssi::settings_add_str( "twirssi", "bitlbee_server", "bitlbee" );
943 Irssi::settings_add_str( "twirssi", "short_url_provider", "TinyURL" );
944 Irssi::settings_add_str( "twirssi", "twirssi_location",
945 ".irssi/scripts/twirssi.pl" );
946 Irssi::settings_add_str( "twirssi", "twitter_usernames", undef );
947 Irssi::settings_add_str( "twirssi", "twitter_passwords", undef );
948 Irssi::settings_add_str( "twirssi", "twirssi_replies_store",
949 ".irssi/scripts/twirssi.json" );
950 Irssi::settings_add_bool( "twirssi", "tweet_to_away", 0 );
951 Irssi::settings_add_bool( "twirssi", "show_reply_context", 0 );
952 Irssi::settings_add_bool( "twirssi", "show_own_tweets", 1 );
953 Irssi::settings_add_bool( "twirssi", "twirssi_debug", 0 );
954 Irssi::settings_add_bool( "twirssi", "twirssi_first_run", 1 );
955 Irssi::settings_add_bool( "twirssi", "twirssi_track_replies", 1 );
956 Irssi::settings_add_bool( "twirssi", "twirssi_use_reply_aliases", 0 );
957 Irssi::settings_add_bool( "twirssi", "tweet_window_input", 0 );
958 $window = Irssi::window_find_name( Irssi::settings_get_str('twitter_window') );
961 $window = Irssi::Windowitem::window_create (Irssi::settings_get_str('twitter_window'), 1);
962 $window->set_name (Irssi::settings_get_str('twitter_window'));
966 Irssi::command_bind( "dm", "cmd_direct" );
967 Irssi::command_bind( "dm_as", "cmd_direct_as" );
968 Irssi::command_bind( "tweet", "cmd_tweet" );
969 Irssi::command_bind( "tweet_as", "cmd_tweet_as" );
970 Irssi::command_bind( "twitter_reply", "cmd_reply" );
971 Irssi::command_bind( "twitter_reply_as", "cmd_reply_as" );
972 Irssi::command_bind( "twitter_login", "cmd_login" );
973 Irssi::command_bind( "twitter_logout", "cmd_logout" );
974 Irssi::command_bind( "twitter_switch", "cmd_switch" );
975 Irssi::command_bind( "twirssi_upgrade", "cmd_upgrade" );
976 if ( Irssi::settings_get_bool("twirssi_use_reply_aliases") ) {
977 Irssi::command_bind( "reply", "cmd_reply" );
978 Irssi::command_bind( "reply_as", "cmd_reply_as" );
983 print "twits: ", join ", ",
984 map { "u: $_->{username}" } values %twits;
985 print "friends: ", join ", ", sort keys %friends;
986 print "nicks: ", join ", ", sort keys %nicks;
987 print "id_map: ", Dumper \%{ $id_map{__indexes} };
988 print "last poll: $last_poll";
994 ¬ice("Twirssi v$VERSION (r$REV); "
995 . "Net::Twitter v$Net::Twitter::VERSION. "
997 . JSON::Any::handler()
998 . ". See details at http://twirssi.com/" );
1001 Irssi::command_bind(
1004 "/twitter_friend <username>",
1006 sub { ¬ice("Following $_[0]"); $nicks{ $_[0] } = time; }
1009 Irssi::command_bind(
1012 "/twitter_unfriend <username>",
1014 sub { ¬ice("Stopped following $_[0]"); delete $nicks{ $_[0] }; }
1017 Irssi::command_bind( "twitter_updates", "get_updates" );
1018 Irssi::signal_add_last( 'complete word' => \&sig_complete );
1020 ¬ice(" %Y<%C(%B^%C)%N TWIRSSI v%R$VERSION%N (r$REV)");
1021 ¬ice(" %C(_(\\%N http://twirssi.com/ for full docs");
1023 " %Y||%C `%N Log in with /twitter_login, send updates with /tweet");
1025 my $file = Irssi::settings_get_str("twirssi_replies_store");
1026 if ( $file and -r $file ) {
1027 if ( open( JSON, $file ) ) {
1032 my $ref = JSON::Any->jsonToObj($json);
1034 my $num = keys %{ $id_map{__indexes} };
1035 ¬ice( sprintf "Loaded old replies from %d contact%s.",
1036 $num, ( $num == 1 ? "" : "s" ) );
1039 ¬ice("Failed to load old replies from $file: $!");
1043 if ( my $provider = Irssi::settings_get_str("short_url_provider") ) {
1044 eval "use WWW::Shorten::$provider;";
1048 "Failed to load WWW::Shorten::$provider - either clear short_url_provider or install the CPAN module"
1053 if ( my $autouser = Irssi::settings_get_str("twitter_usernames")
1054 and my $autopass = Irssi::settings_get_str("twitter_passwords") )
1061 ->print( "Create a window named "
1062 . Irssi::settings_get_str('twitter_window')
1063 . " or change the value of twitter_window. Then, reload twirssi." );
1066 # vim: set sts=4 expandtab: