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;
39 my ( $data, $server, $win ) = @_;
41 return unless &logged_in($twit);
43 my ( $target, $text ) = split ' ', $data, 2;
44 unless ( $target and $text ) {
45 ¬ice("Usage: /dm <nick> <message>");
49 &cmd_direct_as( "$user $data", $server, $win );
53 my ( $data, $server, $win ) = @_;
55 return unless &logged_in($twit);
57 my ( $username, $target, $text ) = split ' ', $data, 3;
58 unless ( $username and $target and $text ) {
59 ¬ice("Usage: /dm_as <username> <nick> <message>");
63 return unless &valid_username($username);
66 unless ( $twits{$username}
67 ->new_direct_message( { user => $target, text => $text } ) )
69 ¬ice("DM to $target failed");
75 ¬ice("DM caused an error. Aborted");
79 ¬ice("DM sent to $target");
80 $nicks{$target} = time;
84 my ( $data, $server, $win ) = @_;
86 return unless &logged_in($twit);
88 $data =~ s/^\s+|\s+$//;
90 ¬ice("Usage: /tweet <update>");
94 &cmd_tweet_as( "$user $data", $server, $win );
98 my ( $data, $server, $win ) = @_;
100 return unless &logged_in($twit);
102 $data =~ s/^\s+|\s+$//;
103 my ( $username, $data ) = split ' ', $data, 2;
105 unless ( $username and $data ) {
106 ¬ice("Usage: /tweet_as <username> <update>");
110 return unless &valid_username($username);
112 if ( Irssi::settings_get_str("short_url_provider") ) {
113 foreach my $url ( $data =~ /(https?:\/\/\S+[\w\/])/g ) {
115 my $short = makeashorterlink($url);
116 $data =~ s/\Q$url/$short/g;
121 return if &too_long($data);
124 unless ( $twits{$username}->update($data) )
126 ¬ice("Update failed");
132 ¬ice("Update caused an error. Aborted.");
136 foreach ( $data =~ /@([-\w]+)/ ) {
140 my $away = &update_away($data);
142 ¬ice( "Update sent" . ( $away ? " (and away msg set)" : "" ) );
146 my ( $data, $server, $win ) = @_;
148 return unless &logged_in($twit);
150 $data =~ s/^\s+|\s+$//;
152 ¬ice("Usage: /reply <nick[:num]> <update>");
156 $data =~ s/^\s+|\s+$//;
157 my ( $id, $data ) = split ' ', $data, 2;
158 unless ( $id and $data ) {
159 ¬ice("Usage: /reply_as <nick[:num]> <update>");
163 &cmd_reply_as( "$user $id $data", $server, $win );
167 my ( $data, $server, $win ) = @_;
169 unless ( Irssi::settings_get_bool("twirssi_track_replies") ) {
170 ¬ice("twirssi_track_replies is required in order to reply to "
171 . "specific tweets. Either enable it, or just use /tweet "
172 . "\@username <text>." );
176 return unless &logged_in($twit);
178 $data =~ s/^\s+|\s+$//;
179 my ( $username, $id, $data ) = split ' ', $data, 3;
181 unless ( $username and $data ) {
182 ¬ice("Usage: /reply_as <username> <nick[:num]> <update>");
186 return unless &valid_username($username);
189 $id =~ s/[^\w\d\-:]+//g;
190 ( $nick, $id ) = split /:/, $id;
191 unless ( exists $id_map{ lc $nick } ) {
192 ¬ice("Can't find a tweet from $nick to reply to!");
196 $id = $id_map{__indexes}{$nick} unless $id;
197 unless ( $id_map{ lc $nick }[$id] ) {
198 ¬ice("Can't find a tweet numbered $id from $nick to reply to!");
202 # remove any @nick at the beginning of the reply, as we'll add it anyway
203 $data =~ s/^\s*\@?$nick\s*//;
204 $data = "\@$nick " . $data;
206 if ( Irssi::settings_get_str("short_url_provider") ) {
207 foreach my $url ( $data =~ /(https?:\/\/\S+[\w\/])/g ) {
209 my $short = makeashorterlink($url);
210 $data =~ s/\Q$url/$short/g;
215 return if &too_long($data);
219 $twits{$username}->update(
222 in_reply_to_status_id => $id_map{ lc $nick }[$id]
227 ¬ice("Update failed");
233 ¬ice("Update caused an error. Aborted");
237 foreach ( $data =~ /@([-\w]+)/ ) {
241 my $away = &update_away($data);
243 ¬ice( "Update sent" . ( $away ? " (and away msg set)" : "" ) );
247 my ( $usage_str, $api_name, $post_ref ) = @_;
250 my ( $data, $server, $win ) = @_;
252 return unless &logged_in($twit);
254 $data =~ s/^\s+|\s+$//;
256 ¬ice("Usage: $usage_str");
261 unless ( $twit->$api_name($data) )
263 ¬ice("$api_name failed");
269 ¬ice("$api_name caused an error. Aborted.");
273 &$post_ref($data) if $post_ref;
278 my ( $data, $server, $win ) = @_;
280 $data =~ s/^\s+|\s+$//g;
281 if ( exists $twits{$data} ) {
282 ¬ice("Switching to $data");
283 $twit = $twits{$data};
286 ¬ice("Unknown user $data");
291 my ( $data, $server, $win ) = @_;
293 $data =~ s/^\s+|\s+$//g;
294 return unless &valid_username($data);
297 ¬ice("Logging out $data...");
298 $twits{$data}->end_session();
299 delete $twits{$data};
301 ¬ice("Logging out $user...");
302 $twit->end_session();
304 delete $twits{$user};
306 &cmd_switch( ( keys %twits )[0], $server, $win );
308 Irssi::timeout_remove($poll) if $poll;
315 my ( $data, $server, $win ) = @_;
318 ( $user, $pass ) = split ' ', $data, 2;
319 } elsif ( my $autouser = Irssi::settings_get_str("twitter_usernames")
320 and my $autopass = Irssi::settings_get_str("twitter_passwords") )
322 my @user = split /\s*,\s*/, $autouser;
323 my @pass = split /\s*,\s*/, $autopass;
324 if ( @user != @pass ) {
325 ¬ice("Number of usernames doesn't match "
326 . "the number of passwords - auto-login failed" );
329 while ( @user and @pass ) {
337 ¬ice("/twitter_login requires either a username and password "
338 . "or twitter_usernames and twitter_passwords to be set." );
342 %friends = %nicks = ();
344 $twit = Net::Twitter->new(
350 unless ( $twit->verify_credentials() ) {
351 ¬ice("Login as $user failed");
354 &cmd_switch( ( keys %twits )[0], $server, $win );
360 my $rate_limit = $twit->rate_limit_status();
361 if ( $rate_limit and $rate_limit->{remaining_hits} < 1 ) {
362 ¬ice("Rate limit exceeded, try again later");
367 $twits{$user} = $twit;
368 Irssi::timeout_remove($poll) if $poll;
369 $poll = Irssi::timeout_add( 300 * 1000, \&get_updates, "" );
370 ¬ice("Logged in as $user, loading friends list...");
372 ¬ice( "loaded friends: ", scalar keys %friends );
373 if ( Irssi::settings_get_bool("twirssi_first_run") ) {
374 Irssi::settings_set_bool( "twirssi_first_run", 0 );
375 unless ( exists $friends{twirssi} ) {
376 ¬ice("Welcome to twirssi!"
377 . " Perhaps you should add \@twirssi to your friends list,"
378 . " so you can be notified when a new version is release?"
379 . " Just type /twitter_friend twirssi." );
386 ¬ice("Login failed");
391 my ( $data, $server, $win ) = @_;
393 my $loc = Irssi::settings_get_str("twirssi_location");
396 "$loc isn't writable, can't upgrade. Perhaps you need to /set twirssi_location?"
401 if ( not -x "/usr/bin/md5sum" and not $data ) {
403 "/usr/bin/md5sum can't be found - try '/twirssi_upgrade nomd5' to skip MD5 verification"
410 eval { use Digest::MD5; };
414 "Failed to load Digest::MD5. Try '/twirssi_upgrade nomd5' to skip MD5 verification"
419 $md5 = get("http://twirssi.com/md5sum");
423 ¬ice("Failed to download md5sum from peeron! Aborting.");
427 unless ( open( CUR, $loc ) ) {
429 "Failed to read $loc. Check that /set twirssi_location is set to the correct location."
434 my $cur_md5 = Digest::MD5::md5_hex(<CUR>);
437 if ( $cur_md5 eq $md5 ) {
438 ¬ice("Current twirssi seems to be up to date.");
443 my $URL = "http://twirssi.com/twirssi.pl";
444 ¬ice("Downloading twirssi from $URL");
445 LWP::Simple::getstore( $URL, "$loc.upgrade" );
448 unless ( open( NEW, "$loc.upgrade" ) ) {
450 "Failed to read $loc.upgrade. Check that /set twirssi_location is set to the correct location."
455 my $new_md5 = Digest::MD5::md5_hex(<NEW>);
458 if ( $new_md5 ne $md5 ) {
459 ¬ice("MD5 verification failed. expected $md5, got $new_md5");
464 rename $loc, "$loc.backup"
465 or ¬ice("Failed to back up $loc: $!. Aborting")
467 rename "$loc.upgrade", $loc
468 or ¬ice("Failed to rename $loc.upgrade: $!. Aborting")
471 my ( $dir, $file ) = ( $loc =~ m{(.*)/([^/]+)$} );
472 if ( -e "$dir/autorun/$file" ) {
473 ¬ice("Updating $dir/autorun/$file");
474 unlink "$dir/autorun/$file"
475 or ¬ice("Failed to remove old $file from autorun: $!");
476 symlink "../$file", "$dir/autorun/$file"
477 or ¬ice("Failed to create symlink in autorun directory: $!");
480 ¬ice("Download complete. Reload twirssi with /script load $file");
490 print $fh "type:debug Loading friends page $page...\n"
491 if ( $fh and &debug );
492 my $friends = $twit->friends( { page => $page } );
493 last unless $friends;
494 $new_friends{ $_->{screen_name} } = time foreach @$friends;
496 last if @$friends == 0 or $page == 10;
501 print $fh "type:debug Error during friends list update. Aborted.\n";
505 my ( $added, $removed ) = ( 0, 0 );
506 print $fh "type:debug Scanning for new friends...\n" if ( $fh and &debug );
507 foreach ( keys %new_friends ) {
508 next if exists $friends{$_};
513 print $fh "type:debug Scanning for removed friends...\n"
514 if ( $fh and &debug );
515 foreach ( keys %friends ) {
516 next if exists $new_friends{$_};
521 return ( $added, $removed );
525 print scalar localtime, " - get_updates starting" if &debug;
528 Irssi::window_find_name( Irssi::settings_get_str('twitter_window') );
531 ->print( "Can't find a window named '"
532 . Irssi::settings_get_str('twitter_window')
533 . "'. Create it or change the value of twitter_window" );
536 return unless &logged_in($twit);
538 my ( $fh, $filename ) = File::Temp::tempfile();
542 Irssi::timeout_add_once( 5000, 'monitor_child', [ $filename, 0 ] );
543 Irssi::pidwait_add($pid);
544 } elsif ( defined $pid ) { # child
552 $error += &do_updates( $fh, $user, $twit );
553 foreach ( keys %twits ) {
555 $error += &do_updates( $fh, $_, $twits{$_} );
558 my ( $added, $removed ) = &load_friends($fh);
559 if ( $added + $removed ) {
560 print $fh "type:debug %R***%n Friends list updated: ",
562 sprintf( "%d added", $added ),
563 sprintf( "%d removed", $removed ) ),
566 print $fh "__friends__\n";
567 foreach ( sort keys %friends ) {
568 print $fh "$_ $friends{$_}\n";
572 print $fh "type:debug Update encountered errors. Aborted\n";
573 print $fh $last_poll;
580 print scalar localtime, " - get_updates ends" if &debug;
584 my ( $fh, $username, $obj ) = @_;
586 print scalar localtime, " - Polling for updates for $username" if &debug;
589 $tweets = $obj->friends_timeline(
590 { since => HTTP::Date::time2str($last_poll) } );
594 print $fh "type:debug Error during friends_timeline call. Aborted.\n";
598 unless ( ref $tweets ) {
599 if ( $obj->can("get_error") ) {
601 eval { $error = JSON::Any->jsonToObj( $obj->get_error() ) };
602 if ($@) { $error = $obj->get_error() }
603 print $fh "type:debug API Error during friends_timeline call: ",
607 "type:debug API Error during friends_timeline call. Aborted.\n";
612 foreach my $t ( reverse @$tweets ) {
613 my $text = decode_entities( $t->{text} );
614 $text =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cO/g;
615 $text =~ s/[\n\r]/ /g;
617 if ( Irssi::settings_get_bool("show_reply_context")
618 and $t->{in_reply_to_screen_name} ne $username
619 and $t->{in_reply_to_screen_name}
620 and not exists $friends{ $t->{in_reply_to_screen_name} } )
622 $nicks{ $t->{in_reply_to_screen_name} } = time;
625 $context = $obj->show_status( $t->{in_reply_to_status_id} );
629 my $ctext = decode_entities( $context->{text} );
630 $ctext =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cO/g;
631 $ctext =~ s/[\n\r]/ /g;
632 printf $fh "id:%d account:%s nick:%s type:tweet %s\n",
633 $context->{id}, $username,
634 $context->{user}{screen_name}, $ctext;
637 print $fh "type:debug request to get context failed: $@";
640 "type:debug Failed to get context from $t->{in_reply_to_screen_name}"
645 if $t->{user}{screen_name} eq $username
646 and not Irssi::settings_get_bool("show_own_tweets");
647 printf $fh "id:%d account:%s nick:%s type:%s %s\n",
648 $t->{id}, $username, $t->{user}{screen_name}, $reply, $text;
651 print scalar localtime, " - Polling for replies" if &debug;
653 $tweets = $obj->replies( { since => HTTP::Date::time2str($last_poll) } )
658 print $fh "type:debug Error during replies call. Aborted.\n";
662 foreach my $t ( reverse @$tweets ) {
664 if exists $friends{ $t->{user}{screen_name} };
666 my $text = decode_entities( $t->{text} );
667 $text =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cO/g;
668 $text =~ s/[\n\r]/ /g;
669 printf $fh "id:%d account:%s nick:%s type:tweet %s\n",
670 $t->{id}, $username, $t->{user}{screen_name}, $text;
673 print scalar localtime, " - Polling for DMs" if &debug;
676 $obj->direct_messages( { since => HTTP::Date::time2str($last_poll) } )
681 print $fh "type:debug Error during direct_messages call. Aborted.\n";
685 foreach my $t ( reverse @$tweets ) {
686 my $text = decode_entities( $t->{text} );
687 $text =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cO/g;
688 $text =~ s/[\n\r]/ /g;
689 printf $fh "id:%d account:%s nick:%s type:dm %s\n",
690 $t->{id}, $username, $t->{sender_screen_name}, $text;
692 print scalar localtime, " - Done" if &debug;
699 my $filename = $data->[0];
700 my $attempt = $data->[1];
702 print scalar localtime, " - checking child log at $filename ($attempt)"
705 if ( open FILE, $filename ) {
709 last if /^__friends__/;
711 foreach my $key (qw/id account nick type/) {
712 if (s/^$key:(\S+)\s*//) {
717 next if exists $meta{id} and exists $tweet_cache{ $meta{id} };
718 $tweet_cache{ $meta{id} } = time;
720 if ( $meta{account} ne $user ) {
721 $account = "$meta{account}: ";
725 if ( $meta{type} ne 'dm'
726 and Irssi::settings_get_bool("twirssi_track_replies")
730 $marker = ( $id_map{__indexes}{ $meta{nick} } + 1 ) % 100;
731 $id_map{ lc $meta{nick} }[$marker] = $meta{id};
732 $id_map{__indexes}{ $meta{nick} } = $marker;
733 $marker = ":$marker";
736 if ( $meta{type} eq 'tweet' ) {
737 push @lines, [$meta{type}, $account, $meta{nick}, $marker, $_];
738 } elsif ( $meta{type} eq 'reply' ) {
739 push @lines, [$meta{type}, $account, $meta{nick}, $marker, $_];
740 } elsif ( $meta{type} eq 'dm' ) {
741 push @lines, [$meta{type}, $account, $meta{nick}, $_];
742 } elsif ( $meta{type} eq 'error' ) {
744 } elsif ( $meta{type} eq 'debug' ) {
745 print "$_" if &debug,;
747 print "Unknown line type $meta{type}: $_" if &debug,;
757 my ( $f, $t ) = split ' ', $_;
758 $nicks{$f} = $friends{$f} = $t;
761 if ($new_last_poll) {
762 print "new last_poll = $new_last_poll" if &debug;
763 for my $line ( @lines ) {
764 $window->printformat(MSGLEVEL_PUBLIC, "twirssi_".@$line[0],
770 or warn "Failed to remove $filename: $!"
773 # keep enough cached tweets, to make sure we don't show duplicates.
774 foreach ( keys %tweet_cache ) {
775 next if $tweet_cache{$_} >= $last_poll;
776 delete $tweet_cache{$_};
778 $last_poll = $new_last_poll;
783 Irssi::settings_get_str("twirssi_replies_store") )
785 if ( open JSON, ">$file" ) {
786 print JSON JSON::Any->objToJson( \%id_map );
789 ¬ice("Failed to write replies to $file: $!");
798 if ( $attempt < 12 ) {
799 Irssi::timeout_add_once( 5000, 'monitor_child',
800 [ $filename, $attempt + 1 ] );
802 ¬ice("Giving up on polling $filename");
803 unlink $filename unless &debug;
808 return Irssi::settings_get_bool("twirssi_debug");
812 $window->print( "%R***%n @_", MSGLEVEL_PUBLIC );
818 if ( Irssi::settings_get_bool("tweet_to_away")
820 and $data !~ /^[dD] / )
823 Irssi::server_find_tag( Irssi::settings_get_str("bitlbee_server") );
825 $server->send_raw("away :$data");
828 ¬ice( "Can't find bitlbee server.",
829 "Update bitlbee_server or disable tweet_to_away" );
840 if ( length $data > 140 ) {
842 "Tweet too long (" . length($data) . " characters) - aborted" );
850 my $username = shift;
852 unless ( exists $twits{$username} ) {
853 ¬ice("Unknown username $username");
863 ¬ice("Not logged in! Use /twitter_login username pass!");
871 my ( $complist, $window, $word, $linestart, $want_space ) = @_;
874 $linestart =~ /^\/twitter_reply(?:_as)?\s*$/
875 or ( Irssi::settings_get_bool("twirssi_use_reply_aliases")
876 and $linestart =~ /^\/reply(?:_as)?\s*$/ )
878 { # /twitter_reply gets a nick:num
880 @$complist = map { "$_:$id_map{__indexes}{$_}" } grep /^\Q$word/i,
881 sort keys %{ $id_map{__indexes} };
884 # /tweet, /tweet_as, /dm, /dm_as - complete @nicks (and nicks as the first
886 if ( $linestart =~ /^\/(?:tweet|dm)/ ) {
887 my $prefix = $word =~ s/^@//;
888 $prefix = 0 if $linestart eq '/dm' or $linestart eq '/dm_as';
889 push @$complist, grep /^\Q$word/i,
890 sort { $nicks{$b} <=> $nicks{$a} } keys %nicks;
891 @$complist = map { "\@$_" } @$complist if $prefix;
895 sub event_send_text {
896 my ( $line, $server, $win ) = @_;
897 my $awin = Irssi::active_win();
899 # if the window where we got our text was the twitter window, and the user
900 # wants to be lazy, tweet away!
901 if ( ( $awin->get_active_name() eq $window->{name} )
902 and Irssi::settings_get_bool("tweet_window_input") )
904 &cmd_tweet( $line, $server, $win );
908 Irssi::signal_add( "send text", "event_send_text" );
910 Irssi::theme_register([
911 'twirssi_tweet', '[$0%B@$1%n$2] $3',
912 'twirssi_reply', '[$0\--> %B@$1%n$2] $3',
913 'twirssi_dm', '[$0%B@$1%n (%WDM%n)] $2',
914 'twirssi_error', 'ERROR: $0',
917 Irssi::settings_add_str( "twirssi", "twitter_window", "twitter" );
918 Irssi::settings_add_str( "twirssi", "bitlbee_server", "bitlbee" );
919 Irssi::settings_add_str( "twirssi", "short_url_provider", "TinyURL" );
920 Irssi::settings_add_str( "twirssi", "twirssi_location",
921 ".irssi/scripts/twirssi.pl" );
922 Irssi::settings_add_str( "twirssi", "twitter_usernames", undef );
923 Irssi::settings_add_str( "twirssi", "twitter_passwords", undef );
924 Irssi::settings_add_str( "twirssi", "twirssi_replies_store",
925 ".irssi/scripts/twirssi.json" );
926 Irssi::settings_add_bool( "twirssi", "tweet_to_away", 0 );
927 Irssi::settings_add_bool( "twirssi", "show_reply_context", 0 );
928 Irssi::settings_add_bool( "twirssi", "show_own_tweets", 1 );
929 Irssi::settings_add_bool( "twirssi", "twirssi_debug", 0 );
930 Irssi::settings_add_bool( "twirssi", "twirssi_first_run", 1 );
931 Irssi::settings_add_bool( "twirssi", "twirssi_track_replies", 1 );
932 Irssi::settings_add_bool( "twirssi", "twirssi_use_reply_aliases", 0 );
933 Irssi::settings_add_bool( "twirssi", "tweet_window_input", 0 );
934 $window = Irssi::window_find_name( Irssi::settings_get_str('twitter_window') );
937 $window = Irssi::Windowitem::window_create (Irssi::settings_get_str('twitter_window'), 1);
938 $window->set_name (Irssi::settings_get_str('twitter_window'));
942 Irssi::command_bind( "dm", "cmd_direct" );
943 Irssi::command_bind( "dm_as", "cmd_direct_as" );
944 Irssi::command_bind( "tweet", "cmd_tweet" );
945 Irssi::command_bind( "tweet_as", "cmd_tweet_as" );
946 Irssi::command_bind( "twitter_reply", "cmd_reply" );
947 Irssi::command_bind( "twitter_reply_as", "cmd_reply_as" );
948 Irssi::command_bind( "twitter_login", "cmd_login" );
949 Irssi::command_bind( "twitter_logout", "cmd_logout" );
950 Irssi::command_bind( "twitter_switch", "cmd_switch" );
951 Irssi::command_bind( "twirssi_upgrade", "cmd_upgrade" );
952 if ( Irssi::settings_get_bool("twirssi_use_reply_aliases") ) {
953 Irssi::command_bind( "reply", "cmd_reply" );
954 Irssi::command_bind( "reply_as", "cmd_reply_as" );
959 print "twits: ", join ", ",
960 map { "u: $_->{username}" } values %twits;
961 print "friends: ", join ", ", sort keys %friends;
962 print "nicks: ", join ", ", sort keys %nicks;
963 print "id_map: ", Dumper \%{ $id_map{__indexes} };
964 print "last poll: $last_poll";
970 ¬ice("Twirssi v$VERSION (r$REV); "
971 . "Net::Twitter v$Net::Twitter::VERSION. "
973 . JSON::Any::handler()
974 . ". See details at http://twirssi.com/" );
980 "/twitter_friend <username>",
982 sub { ¬ice("Following $_[0]"); $nicks{ $_[0] } = time; }
988 "/twitter_unfriend <username>",
990 sub { ¬ice("Stopped following $_[0]"); delete $nicks{ $_[0] }; }
993 Irssi::command_bind( "twitter_updates", "get_updates" );
994 Irssi::signal_add_last( 'complete word' => \&sig_complete );
996 ¬ice(" %Y<%C(%B^%C)%N TWIRSSI v%R$VERSION%N (r$REV)");
997 ¬ice(" %C(_(\\%N http://twirssi.com/ for full docs");
999 " %Y||%C `%N Log in with /twitter_login, send updates with /tweet");
1001 my $file = Irssi::settings_get_str("twirssi_replies_store");
1002 if ( $file and -r $file ) {
1003 if ( open( JSON, $file ) ) {
1008 my $ref = JSON::Any->jsonToObj($json);
1010 my $num = keys %{ $id_map{__indexes} };
1011 ¬ice( sprintf "Loaded old replies from %d contact%s.",
1012 $num, ( $num == 1 ? "" : "s" ) );
1015 ¬ice("Failed to load old replies from $file: $!");
1019 if ( my $provider = Irssi::settings_get_str("short_url_provider") ) {
1020 eval "use WWW::Shorten::$provider;";
1024 "Failed to load WWW::Shorten::$provider - either clear short_url_provider or install the CPAN module"
1029 if ( my $autouser = Irssi::settings_get_str("twitter_usernames")
1030 and my $autopass = Irssi::settings_get_str("twitter_passwords") )
1037 ->print( "Create a window named "
1038 . Irssi::settings_get_str('twitter_window')
1039 . " or change the value of twitter_window. Then, reload twirssi." );
1042 # vim: set sts=4 expandtab: