10 $Data::Dumper::Indent = 1;
12 use vars qw($VERSION %IRSSI);
15 my ($REV) = '$Rev: 435 $' =~ /(\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-27 16:40:26 -0800 (Tue, 27 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 ( &too_long($data) and 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";
756 $irssi_to_mirc_colors{ Irssi::settings_get_str("hilight_color") };
757 if ( $_ =~ /\@($meta{account})\W/ ) {
758 $meta{nick} = "\cC$hilight_color$meta{nick}\cO";
759 $hilight = MSGLEVEL_HILIGHT;
762 if ( $meta{type} eq 'tweet' ) {
765 ( MSGLEVEL_PUBLIC | $hilight ),
766 $meta{type}, $account, $meta{nick}, $marker, $_
768 } elsif ( $meta{type} eq 'reply' ) {
771 ( MSGLEVEL_PUBLIC | $hilight ),
772 $meta{type}, $account, $meta{nick}, $marker, $_
774 } elsif ( $meta{type} eq 'dm' ) {
777 ( MSGLEVEL_MSGS | $hilight ),
778 $meta{type}, $account, $meta{nick}, $_
780 } elsif ( $meta{type} eq 'error' ) {
781 push @lines, [ MSGLEVEL_MSGS, $_ ];
782 } elsif ( $meta{type} eq 'debug' ) {
783 print "$_" if &debug,;
785 print "Unknown line type $meta{type}: $_" if &debug,;
795 my ( $f, $t ) = split ' ', $_;
796 $nicks{$f} = $friends{$f} = $t;
799 if ($new_last_poll) {
800 print "new last_poll = $new_last_poll" if &debug;
801 for my $line (@lines) {
802 $window->printformat(
804 "twirssi_" . @$line[1],
811 or warn "Failed to remove $filename: $!"
814 # keep enough cached tweets, to make sure we don't show duplicates.
815 foreach ( keys %tweet_cache ) {
816 next if $tweet_cache{$_} >= $last_poll;
817 delete $tweet_cache{$_};
819 $last_poll = $new_last_poll;
824 Irssi::settings_get_str("twirssi_replies_store") )
826 if ( open JSON, ">$file" ) {
827 print JSON JSON::Any->objToJson( \%id_map );
830 ¬ice("Failed to write replies to $file: $!");
839 if ( $attempt < 12 ) {
840 Irssi::timeout_add_once( 5000, 'monitor_child',
841 [ $filename, $attempt + 1 ] );
843 ¬ice("Giving up on polling $filename");
844 unlink $filename unless &debug;
849 return Irssi::settings_get_bool("twirssi_debug");
853 $window->print( "%R***%n @_", MSGLEVEL_PUBLIC );
859 if ( Irssi::settings_get_bool("tweet_to_away")
861 and $data !~ /^[dD] / )
864 Irssi::server_find_tag( Irssi::settings_get_str("bitlbee_server") );
866 $server->send_raw("away :$data");
869 ¬ice( "Can't find bitlbee server.",
870 "Update bitlbee_server or disable tweet_to_away" );
882 if ( length $data > 140 ) {
883 ¬ice( "Tweet too long (" . length($data) . " characters) - aborted" )
892 my $username = shift;
894 unless ( exists $twits{$username} ) {
895 ¬ice("Unknown username $username");
905 ¬ice("Not logged in! Use /twitter_login username pass!");
913 my ( $complist, $window, $word, $linestart, $want_space ) = @_;
916 $linestart =~ /^\/twitter_reply(?:_as)?\s*$/
917 or ( Irssi::settings_get_bool("twirssi_use_reply_aliases")
918 and $linestart =~ /^\/reply(?:_as)?\s*$/ )
920 { # /twitter_reply gets a nick:num
922 @$complist = map { "$_:$id_map{__indexes}{$_}" } grep /^\Q$word/i,
923 sort keys %{ $id_map{__indexes} };
926 # /tweet, /tweet_as, /dm, /dm_as - complete @nicks (and nicks as the first
928 if ( $linestart =~ /^\/(?:tweet|dm)/ ) {
929 my $prefix = $word =~ s/^@//;
930 $prefix = 0 if $linestart eq '/dm' or $linestart eq '/dm_as';
931 push @$complist, grep /^\Q$word/i,
932 sort { $nicks{$b} <=> $nicks{$a} } keys %nicks;
933 @$complist = map { "\@$_" } @$complist if $prefix;
937 sub event_send_text {
938 my ( $line, $server, $win ) = @_;
939 my $awin = Irssi::active_win();
941 # if the window where we got our text was the twitter window, and the user
942 # wants to be lazy, tweet away!
943 if ( ( $awin->get_active_name() eq $window->{name} )
944 and Irssi::settings_get_bool("tweet_window_input") )
946 &cmd_tweet( $line, $server, $win );
950 Irssi::signal_add( "send text", "event_send_text" );
952 Irssi::theme_register(
954 'twirssi_tweet', '[$0%B@$1%n$2] $3',
955 'twirssi_reply', '[$0\--> %B@$1%n$2] $3',
956 'twirssi_dm', '[$0%B@$1%n (%WDM%n)] $2',
957 'twirssi_error', 'ERROR: $0',
961 Irssi::settings_add_str( "twirssi", "twitter_window", "twitter" );
962 Irssi::settings_add_str( "twirssi", "bitlbee_server", "bitlbee" );
963 Irssi::settings_add_str( "twirssi", "short_url_provider", "TinyURL" );
964 Irssi::settings_add_str( "twirssi", "twirssi_location",
965 ".irssi/scripts/twirssi.pl" );
966 Irssi::settings_add_str( "twirssi", "twitter_usernames", undef );
967 Irssi::settings_add_str( "twirssi", "twitter_passwords", undef );
968 Irssi::settings_add_str( "twirssi", "twirssi_replies_store",
969 ".irssi/scripts/twirssi.json" );
970 Irssi::settings_add_bool( "twirssi", "tweet_to_away", 0 );
971 Irssi::settings_add_bool( "twirssi", "show_reply_context", 0 );
972 Irssi::settings_add_bool( "twirssi", "show_own_tweets", 1 );
973 Irssi::settings_add_bool( "twirssi", "twirssi_debug", 0 );
974 Irssi::settings_add_bool( "twirssi", "twirssi_first_run", 1 );
975 Irssi::settings_add_bool( "twirssi", "twirssi_track_replies", 1 );
976 Irssi::settings_add_bool( "twirssi", "twirssi_use_reply_aliases", 0 );
977 Irssi::settings_add_bool( "twirssi", "tweet_window_input", 0 );
979 $window = Irssi::window_find_name( Irssi::settings_get_str('twitter_window') );
982 Irssi::Windowitem::window_create(
983 Irssi::settings_get_str('twitter_window'), 1 );
984 $window->set_name( Irssi::settings_get_str('twitter_window') );
988 Irssi::command_bind( "dm", "cmd_direct" );
989 Irssi::command_bind( "dm_as", "cmd_direct_as" );
990 Irssi::command_bind( "tweet", "cmd_tweet" );
991 Irssi::command_bind( "tweet_as", "cmd_tweet_as" );
992 Irssi::command_bind( "twitter_reply", "cmd_reply" );
993 Irssi::command_bind( "twitter_reply_as", "cmd_reply_as" );
994 Irssi::command_bind( "twitter_login", "cmd_login" );
995 Irssi::command_bind( "twitter_logout", "cmd_logout" );
996 Irssi::command_bind( "twitter_switch", "cmd_switch" );
997 Irssi::command_bind( "twirssi_upgrade", "cmd_upgrade" );
998 if ( Irssi::settings_get_bool("twirssi_use_reply_aliases") ) {
999 Irssi::command_bind( "reply", "cmd_reply" );
1000 Irssi::command_bind( "reply_as", "cmd_reply_as" );
1002 Irssi::command_bind(
1005 print "twits: ", join ", ",
1006 map { "u: $_->{username}" } values %twits;
1007 print "friends: ", join ", ", sort keys %friends;
1008 print "nicks: ", join ", ", sort keys %nicks;
1009 print "id_map: ", Dumper \%{ $id_map{__indexes} };
1010 print "last poll: $last_poll";
1013 Irssi::command_bind(
1016 ¬ice("Twirssi v$VERSION (r$REV); "
1017 . "Net::Twitter v$Net::Twitter::VERSION. "
1019 . JSON::Any::handler()
1020 . ". See details at http://twirssi.com/" );
1023 Irssi::command_bind(
1026 "/twitter_friend <username>",
1028 sub { ¬ice("Following $_[0]"); $nicks{ $_[0] } = time; }
1031 Irssi::command_bind(
1034 "/twitter_unfriend <username>",
1036 sub { ¬ice("Stopped following $_[0]"); delete $nicks{ $_[0] }; }
1039 Irssi::command_bind( "twitter_updates", "get_updates" );
1040 Irssi::signal_add_last( 'complete word' => \&sig_complete );
1042 ¬ice(" %Y<%C(%B^%C)%N TWIRSSI v%R$VERSION%N (r$REV)");
1043 ¬ice(" %C(_(\\%N http://twirssi.com/ for full docs");
1045 " %Y||%C `%N Log in with /twitter_login, send updates with /tweet");
1047 my $file = Irssi::settings_get_str("twirssi_replies_store");
1048 if ( $file and -r $file ) {
1049 if ( open( JSON, $file ) ) {
1054 my $ref = JSON::Any->jsonToObj($json);
1056 my $num = keys %{ $id_map{__indexes} };
1057 ¬ice( sprintf "Loaded old replies from %d contact%s.",
1058 $num, ( $num == 1 ? "" : "s" ) );
1061 ¬ice("Failed to load old replies from $file: $!");
1065 if ( my $provider = Irssi::settings_get_str("short_url_provider") ) {
1066 eval "use WWW::Shorten::$provider;";
1070 "Failed to load WWW::Shorten::$provider - either clear short_url_provider or install the CPAN module"
1075 if ( my $autouser = Irssi::settings_get_str("twitter_usernames")
1076 and my $autopass = Irssi::settings_get_str("twitter_passwords") )
1083 ->print( "Create a window named "
1084 . Irssi::settings_get_str('twitter_window')
1085 . " or change the value of twitter_window. Then, reload twirssi." );
1088 # vim: set sts=4 expandtab: