From: Brian S. Stephan Date: Tue, 27 Jan 2009 02:15:43 +0000 (-0600) Subject: Merge branch 'master' into bss X-Git-Url: https://git.sommitrealweird.co.uk/twirssi-net-twitter-lite.git/commitdiff_plain/ee0c503ce407c794199a9d00662aecb076d652dd?hp=-c Merge branch 'master' into bss --- ee0c503ce407c794199a9d00662aecb076d652dd diff --combined twirssi.pl index 4decda6,aaf0bd1..43aba35 --- a/twirssi.pl +++ b/twirssi.pl @@@ -11,8 -11,8 +11,8 @@@ $Data::Dumper::Indent = 1 use vars qw($VERSION %IRSSI); - $VERSION = "1.7.6"; - my ($REV) = '$Rev: 379 $' =~ /(\d+)/; + $VERSION = "1.7.7"; + my ($REV) = '$Rev: 422 $' =~ /(\d+)/; %IRSSI = ( authors => 'Dan Boger', contact => 'zigdon@gmail.com', @@@ -21,7 -21,7 +21,7 @@@ . 'Can optionally set your bitlbee /away message to same', license => 'GNU GPL v2', url => 'http://tinyurl.com/twirssi', - changed => '$Date: 2009-01-21 09:50:42 -0800 (Wed, 21 Jan 2009) $', + changed => '$Date: 2009-01-26 08:19:42 -0800 (Mon, 26 Jan 2009) $', ); my $window; @@@ -34,24 -34,6 +34,24 @@@ my %friends my $last_poll = time - 300; my %tweet_cache; my %id_map; +my %irssi_to_mirc_colors = ( + '%k' => '01', + '%r' => '05', + '%g' => '03', + '%y' => '07', + '%b' => '02', + '%m' => '06', + '%c' => '10', + '%w' => '15', + '%K' => '14', + '%R' => '04', + '%G' => '09', + '%Y' => '08', + '%B' => '12', + '%M' => '13', + '%C' => '11', + '%W' => '00', +); sub cmd_direct { my ( $data, $server, $win ) = @_; @@@ -127,7 -109,7 +127,7 @@@ sub cmd_tweet_as return unless &valid_username($username); - if ( Irssi::settings_get_str("short_url_provider") ) { + if ( &too_long($data) and Irssi::settings_get_str("short_url_provider") ) { foreach my $url ( $data =~ /(https?:\/\/\S+[\w\/])/g ) { eval { my $short = makeashorterlink($url); @@@ -629,7 -611,8 +629,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") @@@ -645,7 -628,8 +645,7 @@@ 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, @@@ -682,7 -666,8 +682,7 @@@ 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; @@@ -702,7 -687,8 +702,7 @@@ 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; @@@ -725,7 -711,6 +725,7 @@@ sub monitor_child while () { chomp; last if /^__friends__/; + my $hilight = 0; my %meta; foreach my $key (qw/id account nick type/) { if (s/^$key:(\S+)\s*//) { @@@ -752,20 -737,14 +752,20 @@@ $marker = ":$marker"; } + my $hilight_color = $irssi_to_mirc_colors{Irssi::settings_get_str("hilight_color")}; + if ( $_ =~ /\@($meta{account})\W/ ) { + $meta{nick} = "\cC$hilight_color$meta{nick}\cO"; + $hilight = MSGLEVEL_HILIGHT; + } + if ( $meta{type} eq 'tweet' ) { - push @lines, "[$account%B\@$meta{nick}%n$marker] $_\n",; + push @lines, [(MSGLEVEL_PUBLIC | $hilight), $meta{type}, $account, $meta{nick}, $marker, $_]; } elsif ( $meta{type} eq 'reply' ) { - push @lines, "[$account\\--> %B\@$meta{nick}%n$marker] $_\n",; + push @lines, [(MSGLEVEL_PUBLIC | $hilight), $meta{type}, $account, $meta{nick}, $marker, $_]; } elsif ( $meta{type} eq 'dm' ) { - push @lines, "[$account%B\@$meta{nick}%n (%WDM%n)] $_\n",; + push @lines, [(MSGLEVEL_MSGS | $hilight), $meta{type}, $account, $meta{nick}, $_]; } elsif ( $meta{type} eq 'error' ) { - push @lines, "ERROR: $_\n"; + push @lines, [MSGLEVEL_MSGS, $_]; } elsif ( $meta{type} eq 'debug' ) { print "$_" if &debug,; } else { @@@ -785,9 -764,12 +785,9 @@@ 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(@$line[0], "twirssi_".@$line[1], + @$line[2,3,4,5]); } close FILE; @@@ -860,11 -842,12 +860,12 @@@ sub update_away } sub too_long { - my $data = shift; + my $data = shift; + my $noalert = shift; if ( length $data > 140 ) { - ¬ice( - "Tweet too long (" . length($data) . " characters) - aborted" ); + ¬ice( "Tweet too long (" . length($data) . " characters) - aborted" ) + unless $noalert; return 1; } @@@ -932,13 -915,6 +933,13 @@@ 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', + 'twirssi_error', 'ERROR: $0', +]); + 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" ); @@@ -956,11 -932,13 +957,13 @@@ Irssi::settings_add_bool( "twirssi", "t Irssi::settings_add_bool( "twirssi", "twirssi_track_replies", 1 ); 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')); + $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) { @@@ -1064,4 -1042,3 +1067,4 @@@ . " or change the value of twitter_window. Then, reload twirssi." ); } +# vim: set sts=4 expandtab: