Skip to content

Instantly share code, notes, and snippets.

@Jestre
Forked from RC1140/ customTtyTterOutput.pl
Created May 15, 2014 00:00
Show Gist options
  • Save Jestre/0c8a9d50f8d4ecbf880f to your computer and use it in GitHub Desktop.
Save Jestre/0c8a9d50f8d4ecbf880f to your computer and use it in GitHub Desktop.
use Term::ANSIColor;
#Open a text file with a list of users to highlight
open our $handle, '<', "/home/<your username>/tweetersToHighlight.txt";
chomp(our @customConsole = <$handle>);
#Convert array to hash/dictionary
our %users = map { $_ => 1 } @customConsole;
close $handle;
#Setup ttytter hook
$handle = sub {
#Store reference to the origin function
my $ref = shift;
#Store the text for later processeing (even though i never got to it)
my $text = &descape($ref->{'text'});
#If the user is in the highlight file then color the username red
if($users{$ref->{'user'}->{'name'}}){
print color 'bold red';
print $streamout (&descape($ref->{'user'}->{'name'})," (@",&descape($ref->{'user'}->{'screen_name'}),") : \n");
print color 'reset';
print $streamout ("\t[ ", $text, " ]", "\n");
return 1;
}else{
#Otherwise print my custom output
print color 'reset';
print $streamout (&descape($ref->{'user'}->{'name'})," (@",&descape($ref->{'user'}->{'screen_name'}),") : \n");
print $streamout ("\t[ ", $text, " ]", "\n");
return 1;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment