if the tweet contains the {account}, also print the message at MSGLEVEL_HILIGHT
[twirssi-net-twitter-lite.git] / twirssi.pl
index 444aac62a54b1dec79a8cf7328d54cdc3b039a34..edb207ea0432f9952f17cc65b938556c04fb9faa 100644 (file)
@@ -707,6 +707,7 @@ sub monitor_child {
         while (<FILE>) {
             chomp;
             last if /^__friends__/;
+            my $hilight = 0;
             my %meta;
             foreach my $key (qw/id account nick type/) {
                 if (s/^$key:(\S+)\s*//) {
@@ -733,15 +734,16 @@ sub monitor_child {
                 $marker                            = ":$marker";
             }
 
+            if ( $_ =~ /\@$meta{account}\W/ ) {
+                $hilight = MSGLEVEL_HILIGHT;
+            }
+
             if ( $meta{type} eq 'tweet' ) {
-                $window->printformat(MSGLEVEL_PUBLIC, 'twirssi_tweet',
-                  $account, $meta{nick}, $marker, $_);
+                push @lines, [(MSGLEVEL_PUBLIC | $hilight), $meta{type}, $account, $meta{nick}, $marker, $_];
             } elsif ( $meta{type} eq 'reply' ) {
-                $window->printformat(MSGLEVEL_PUBLIC, 'twirssi_reply',
-                  $account, $meta{nick}, $marker, $_);
+                push @lines, [(MSGLEVEL_PUBLIC | $hilight), $meta{type}, $account, $meta{nick}, $marker, $_];
             } elsif ( $meta{type} eq 'dm' ) {
-                $window->printformat(MSGLEVEL_PUBLIC, 'twirssi_dm',
-                  $account, $meta{nick}, $_);
+                push @lines, [(MSGLEVEL_MSGS | $hilight), $meta{type}, $account, $meta{nick}, $_];
             } elsif ( $meta{type} eq 'error' ) {
                 $window->print("ERROR: $_", MSGLEVEL_PUBLIC);
             } elsif ( $meta{type} eq 'debug' ) {
@@ -763,6 +765,10 @@ sub monitor_child {
 
         if ($new_last_poll) {
             print "new last_poll = $new_last_poll" if &debug;
+            for my $line ( @lines ) {
+                $window->printformat(@$line[0], "twirssi_".@$line[1],
+                  @$line[2,3,4,5]);
+            }
 
             close FILE;
             unlink $filename