X-Git-Url: https://git.sommitrealweird.co.uk/twirssi-net-twitter-lite.git/blobdiff_plain/04110752ef11d90a47aeefb5d2d6afc587d72643..3dabfbdfe64eae04d7872d1b4cbbc317401ea989:/twirssi.pl diff --git a/twirssi.pl b/twirssi.pl index 03680f4..acb469c 100644 --- a/twirssi.pl +++ b/twirssi.pl @@ -611,8 +611,7 @@ sub do_updates { foreach my $t ( reverse @$tweets ) { my $text = decode_entities( $t->{text} ); - $text =~ s/%/%%/g; - $text =~ s/(^|\W)\@([-\w]+)/$1%B\@$2%n/g; + $text =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cO/g; $text =~ s/[\n\r]/ /g; my $reply = "tweet"; if ( Irssi::settings_get_bool("show_reply_context") @@ -628,8 +627,7 @@ sub do_updates { if ($context) { my $ctext = decode_entities( $context->{text} ); - $ctext =~ s/%/%%/g; - $ctext =~ s/(^|\W)\@([-\w]+)/$1%B\@$2%n/g; + $ctext =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cO/g; $ctext =~ s/[\n\r]/ /g; printf $fh "id:%d account:%s nick:%s type:tweet %s\n", $context->{id}, $username, @@ -666,8 +664,7 @@ sub do_updates { if exists $friends{ $t->{user}{screen_name} }; my $text = decode_entities( $t->{text} ); - $text =~ s/%/%%/g; - $text =~ s/(^|\W)\@([-\w]+)/$1%B\@$2%n/g; + $text =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cO/g; $text =~ s/[\n\r]/ /g; printf $fh "id:%d account:%s nick:%s type:tweet %s\n", $t->{id}, $username, $t->{user}{screen_name}, $text; @@ -687,8 +684,7 @@ sub do_updates { foreach my $t ( reverse @$tweets ) { my $text = decode_entities( $t->{text} ); - $text =~ s/%/%%/g; - $text =~ s/(^|\W)\@([-\w]+)/$1%B\@$2%n/g; + $text =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cO/g; $text =~ s/[\n\r]/ /g; printf $fh "id:%d account:%s nick:%s type:dm %s\n", $t->{id}, $username, $t->{sender_screen_name}, $text; @@ -738,13 +734,13 @@ sub monitor_child { } if ( $meta{type} eq 'tweet' ) { - push @lines, "[$account%B\@$meta{nick}%n$marker] $_\n",; + push @lines, [$meta{type}, $account, $meta{nick}, $marker, $_]; } elsif ( $meta{type} eq 'reply' ) { - push @lines, "[$account\\--> %B\@$meta{nick}%n$marker] $_\n",; + push @lines, [$meta{type}, $account, $meta{nick}, $marker, $_]; } elsif ( $meta{type} eq 'dm' ) { - push @lines, "[$account%B\@$meta{nick}%n (%WDM%n)] $_\n",; + push @lines, [$meta{type}, $account, $meta{nick}, $_]; } elsif ( $meta{type} eq 'error' ) { - push @lines, "ERROR: $_\n"; + $window->print("ERROR: $_", MSGLEVEL_PUBLIC); } elsif ( $meta{type} eq 'debug' ) { print "$_" if &debug,; } else { @@ -764,12 +760,9 @@ sub monitor_child { if ($new_last_poll) { print "new last_poll = $new_last_poll" if &debug; - foreach my $line (@lines) { - chomp $line; - $window->print( $line, MSGLEVEL_PUBLIC ); - foreach ( $line =~ /\@([-\w]+)/ ) { - $nicks{$1} = time; - } + for my $line ( @lines ) { + $window->printformat(MSGLEVEL_PUBLIC, "twirssi_".@$line[0], + @$line[1,2,3,4]); } close FILE; @@ -914,6 +907,12 @@ sub event_send_text { Irssi::signal_add( "send text", "event_send_text" ); +Irssi::theme_register([ + 'twirssi_tweet', '[$0%B@$1%n$2] $3', + 'twirssi_reply', '[$0\--> %B@$1%n$2] $3', + 'twirssi_dm', '[$0%B@$1%n (%WDM%n)] $2', +]); + Irssi::settings_add_str( "twirssi", "twitter_window", "twitter" ); Irssi::settings_add_str( "twirssi", "bitlbee_server", "bitlbee" ); Irssi::settings_add_str( "twirssi", "short_url_provider", "TinyURL" ); @@ -933,6 +932,11 @@ Irssi::settings_add_bool( "twirssi", "twirssi_use_reply_aliases", 0 ); Irssi::settings_add_bool( "twirssi", "tweet_window_input", 0 ); $window = Irssi::window_find_name( Irssi::settings_get_str('twitter_window') ); +if (!$window) { + $window = Irssi::Windowitem::window_create (Irssi::settings_get_str('twitter_window'), 1); + $window->set_name (Irssi::settings_get_str('twitter_window')); +} + if ($window) { Irssi::command_bind( "dm", "cmd_direct" ); Irssi::command_bind( "dm_as", "cmd_direct_as" ); @@ -1034,3 +1038,4 @@ if ($window) { . " or change the value of twitter_window. Then, reload twirssi." ); } +# vim: set sts=4 expandtab: