1111
1212use vars qw( $VERSION %IRSSI) ;
1313
14- $VERSION = " 2.0" ;
15- my ($REV ) = ' $Rev: 443 $' =~ / (\d +)/ ;
14+ $VERSION = " 2.0.1 " ;
15+ my ($REV ) = ' $Rev: 449 $' =~ / (\d +)/ ;
1616%IRSSI = (
1717 authors => ' Dan Boger' ,
1818 contact => ' zigdon@gmail.com' ,
2121 . ' Can optionally set your bitlbee /away message to same' ,
2222 license => ' GNU GPL v2' ,
2323 url => ' http://twirssi.com' ,
24- changed => ' $Date: 2009-01-29 18:25:38 -0800 (Thu, 29 Jan 2009) $' ,
24+ changed => ' $Date: 2009-02-02 09:49:45 -0800 (Mon, 02 Feb 2009) $' ,
2525);
2626
2727my $window ;
@@ -127,7 +127,9 @@ sub cmd_tweet_as {
127127
128128 return unless &valid_username($username );
129129
130- if ( &too_long($data ) and Irssi::settings_get_str(" short_url_provider" ) ) {
130+ if ( &too_long( $data , 1 )
131+ and Irssi::settings_get_str(" short_url_provider" ) )
132+ {
131133 foreach my $url ( $data =~ / (https?:\/\/\S +[\w\/ ])/g ) {
132134 eval {
133135 my $short = makeashorterlink($url );
@@ -309,6 +311,7 @@ sub cmd_logout {
309311 my ( $data , $server , $win ) = @_ ;
310312
311313 $data =~ s / ^\s +|\s +$// g ;
314+ $data = $user unless $data ;
312315 return unless &valid_username($data );
313316
314317 if ($data ) {
@@ -418,6 +421,12 @@ sub cmd_add_search {
418421
419422 $data =~ s / ^\s +|\s +$// ;
420423 $data = lc $data ;
424+
425+ unless ($data ) {
426+ ¬ice(" Usage: /twitter_subscribe <topic>" );
427+ return ;
428+ }
429+
421430 if ( exists $id_map {__searches }{$user }{$data } ) {
422431 ¬ice(" Already had a subscription for '$data '" );
423432 return ;
@@ -437,6 +446,12 @@ sub cmd_del_search {
437446 }
438447 $data =~ s / ^\s +|\s +$// ;
439448 $data = lc $data ;
449+
450+ unless ($data ) {
451+ ¬ice(" Usage: /twitter_unsubscribe <topic>" );
452+ return ;
453+ }
454+
440455 unless ( exists $id_map {__searches }{$user }{$data } ) {
441456 ¬ice(" No subscription found for '$data '" );
442457 return ;
@@ -696,8 +711,7 @@ sub do_updates {
696711
697712 foreach my $t ( reverse @$tweets ) {
698713 my $text = decode_entities( $t -> {text } );
699- $text =~ s / (^|\W )\@ ([-\w ]+)/ $1 \cC 12\@ $2 \cO / g ;
700- $text =~ s / [\n\r ]/ / g ;
714+ $text = &hilight($text );
701715 my $reply = " tweet" ;
702716 if ( Irssi::settings_get_bool(" show_reply_context" )
703717 and $t -> {in_reply_to_screen_name } ne $username
@@ -712,8 +726,7 @@ sub do_updates {
712726
713727 if ($context ) {
714728 my $ctext = decode_entities( $context -> {text } );
715- $ctext =~ s / (^|\W )\@ ([-\w ]+)/ $1 \cC 12\@ $2 \cO / g ;
716- $ctext =~ s / [\n\r ]/ / g ;
729+ $ctext = &hilight($ctext );
717730 printf $fh " id:%d account:%s nick:%s type:tweet %s \n " ,
718731 $context -> {id }, $username ,
719732 $context -> {user }{screen_name }, $ctext ;
@@ -722,7 +735,7 @@ sub do_updates {
722735 print $fh " type:debug request to get context failed: $@ " ;
723736 } else {
724737 print $fh
725- " type:debug Failed to get context from $t ->{in_reply_to_screen_name}"
738+ " type:debug Failed to get context from $t ->{in_reply_to_screen_name}\n "
726739 if &debug;
727740 }
728741 }
@@ -749,8 +762,7 @@ sub do_updates {
749762 if exists $friends { $t -> {user }{screen_name } };
750763
751764 my $text = decode_entities( $t -> {text } );
752- $text =~ s / (^|\W )\@ ([-\w ]+)/ $1 \cC 12\@ $2 \cO / g ;
753- $text =~ s / [\n\r ]/ / g ;
765+ $text = &hilight($text );
754766 printf $fh " id:%d account:%s nick:%s type:tweet %s \n " ,
755767 $t -> {id }, $username , $t -> {user }{screen_name }, $text ;
756768 }
@@ -769,8 +781,7 @@ sub do_updates {
769781
770782 foreach my $t ( reverse @$tweets ) {
771783 my $text = decode_entities( $t -> {text } );
772- $text =~ s / (^|\W )\@ ([-\w ]+)/ $1 \cC 12\@ $2 \cO / g ;
773- $text =~ s / [\n\r ]/ / g ;
784+ $text = &hilight($text );
774785 printf $fh " id:%d account:%s nick:%s type:dm %s \n " ,
775786 $t -> {id }, $username , $t -> {sender_screen_name }, $text ;
776787 }
@@ -779,6 +790,8 @@ sub do_updates {
779790 if ( $obj -> can(' search' ) and $id_map {__searches }{$username } ) {
780791 my $search ;
781792 foreach my $topic ( sort keys %{ $id_map {__searches }{$username } } ) {
793+ print $fh " type:debug searching for $topic since " ,
794+ " $id_map {__searches}{$username }{$topic }\n " ;
782795 eval {
783796 $search = $obj -> search(
784797 {
@@ -796,7 +809,8 @@ sub do_updates {
796809
797810 unless ( $search -> {max_id } ) {
798811 print $fh
799- " type:debug Invalid search results when searching for $topic . Aborted.\n " ;
812+ " type:debug Invalid search results when searching for $topic ." ,
813+ " Aborted.\n " ;
800814 return 1;
801815 }
802816
@@ -806,9 +820,7 @@ sub do_updates {
806820
807821 foreach my $t ( reverse @{ $search -> {results } } ) {
808822 my $text = decode_entities( $t -> {text } );
809- $text =~ s / (^|\W )\@ ([-\w ]+)/ $1 \cC 12\@ $2 \cO / g ;
810- $text =~ s / (^|\W )\# ([-\w ]+)/ $1 \cC 5\# $2 \cO / g ;
811- $text =~ s / [\n\r ]/ / g ;
823+ $text = &hilight($text );
812824 printf $fh " id:%d account:%s nick:%s type:search topic:%s %s \n " ,
813825 $t -> {id }, $username , $t -> {from_user }, $topic , $text ;
814826 }
@@ -862,7 +874,7 @@ sub monitor_child {
862874
863875 my $hilight_color =
864876 $irssi_to_mirc_colors { Irssi::settings_get_str(" hilight_color" ) };
865- if ( $_ =~ / \@ ( $meta {account}) \W / ) {
877+ if ( $_ =~ / \@ $meta {account}\W /i ) {
866878 $meta {nick } = " \cC $hilight_color$meta {nick}\cO " ;
867879 $hilight = MSGLEVEL_HILIGHT;
868880 }
@@ -887,8 +899,15 @@ sub monitor_child {
887899 $meta {type }, $account , $meta {nick }, $_
888900 ];
889901 } elsif ( $meta {type } eq ' searchid' ) {
890- $id_map {__searches }{ $meta {account } }{ $meta {topic } } =
891- $meta {id };
902+ print " Search '$meta {topic}' returned id $meta {id}" ;
903+ if ( $meta {id } >=
904+ $id_map {__searches }{ $meta {account } }{ $meta {topic } } )
905+ {
906+ $id_map {__searches }{ $meta {account } }{ $meta {topic } } =
907+ $meta {id };
908+ } else {
909+ print " Search '$meta {topic}' returned invalid id $meta {id}" ;
910+ }
892911 print " Search '$meta {topic}' id set to $meta {id}" if &debug;
893912 } elsif ( $meta {type } eq ' error' ) {
894913 push @lines , [ MSGLEVEL_MSGS, $_ ];
@@ -1066,6 +1085,16 @@ sub get_poll_time {
10661085 return 60;
10671086}
10681087
1088+ sub hilight {
1089+ my $text = shift ;
1090+
1091+ $text =~ s / (^|\W )\@ ([-\w ]+)/ $1 \cC 12\@ $2 \cO / g ;
1092+ $text =~ s / (^|\W )\# ([-\w ]+)/ $1 \cC 5\# $2 \cO / g ;
1093+ $text =~ s / [\n\r ]/ / g ;
1094+
1095+ return $text ;
1096+ }
1097+
10691098Irssi::signal_add( " send text" , " event_send_text" );
10701099
10711100Irssi::theme_register(
0 commit comments