+ my $hilight = 0;
+ my %meta;
+ foreach my $key (qw/id account nick type topic/) {
+ if (s/^$key:(\S+)\s*//) {
+ $meta{$key} = $1;
+ }
+ }
+
+ if ( not $meta{type} or $meta{type} ne 'searchid' ) {
+ if ( exists $meta{id} and exists $new_cache{ $meta{id} } ) {
+ next;
+ }
+
+ $new_cache{ $meta{id} } = time;
+
+ if ( exists $meta{id} and exists $tweet_cache{ $meta{id} } ) {
+ next;
+ }
+ }
+
+ my $account = "";
+ if ( $meta{account} ne $user ) {
+ $account = "$meta{account}: ";
+ }
+
+ my $marker = "";
+ if ( $meta{type} ne 'dm'
+ and Irssi::settings_get_bool("twirssi_track_replies")
+ and $meta{nick}
+ and $meta{id} )
+ {
+ $marker = ( $id_map{__indexes}{ $meta{nick} } + 1 ) % 100;
+ $id_map{ lc $meta{nick} }[$marker] = $meta{id};
+ $id_map{__indexes}{ $meta{nick} } = $marker;
+ $marker = ":$marker";
+ }
+
+ my $hilight_color =
+ $irssi_to_mirc_colors{ Irssi::settings_get_str("hilight_color") };
+ if ( ( $_ =~ /\@$meta{account}\W/i )
+ && Irssi::settings_get_bool("twirssi_hilights") )
+ {
+ $meta{nick} = "\cC$hilight_color$meta{nick}\cO";
+ $hilight = MSGLEVEL_HILIGHT;
+ }
+
+ if ( $meta{type} =~ /tweet|reply/ ) {
+ push @lines,
+ [
+ ( MSGLEVEL_PUBLIC | $hilight ),
+ $meta{type}, $account, $meta{nick}, $marker, $_
+ ];
+ } elsif ( $meta{type} eq 'ellispis' ) {
+ push @lines,
+ [
+ MSGLEVEL_PUBLIC,
+ "tweet", $account, $meta{nick}, "", $_
+ ];
+ } elsif ( $meta{type} eq 'search' ) {
+ push @lines,
+ [
+ ( MSGLEVEL_PUBLIC | $hilight ),
+ $meta{type}, $account, $meta{topic},
+ $meta{nick}, $marker, $_
+ ];
+ if (
+ exists $id_map{__searches}{ $meta{account} }{ $meta{topic} }
+ and $meta{id} >
+ $id_map{__searches}{ $meta{account} }{ $meta{topic} } )
+ {
+ $id_map{__searches}{ $meta{account} }{ $meta{topic} } =
+ $meta{id};
+ }
+ } elsif ( $meta{type} eq 'dm' ) {
+ push @lines,
+ [
+ ( MSGLEVEL_MSGS | $hilight ),
+ $meta{type}, $account, $meta{nick}, $_
+ ];
+ } elsif ( $meta{type} eq 'searchid' ) {
+ print "Search '$meta{topic}' returned id $meta{id}" if &debug;
+ if (
+ exists $id_map{__searches}{ $meta{account} }{ $meta{topic} }
+ and $meta{id} >=
+ $id_map{__searches}{ $meta{account} }{ $meta{topic} } )
+ {
+ $id_map{__searches}{ $meta{account} }{ $meta{topic} } =
+ $meta{id};
+ } elsif (&debug) {
+ print "Search '$meta{topic}' returned invalid id $meta{id}";
+ }
+ } elsif ( $meta{type} eq 'error' ) {
+ push @lines, [ MSGLEVEL_MSGS, $_ ];
+ } elsif ( $meta{type} eq 'debug' ) {
+ print "$_" if &debug,;
+ } else {
+ print "Unknown line type $meta{type}: $_" if &debug,;
+ }