Created
February 21, 2013 20:23
-
-
Save RC1140/5007879 to your computer and use it in GitHub Desktop.
Small little extension for ttytter that allows you to highlight the names of certain users. I also changed the way tweets are displayed to suit my liking.
To use it run ttytter -exts=customTtyTterOutput.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.pl = <$handle>); | |
#Convert array to hash/dictionary | |
our %users = map { $_ => 1 } @customConsole.pl; | |
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
@the-solipsist Didnt see your message till now , but not sure what you mean by point [1] , as for the double effect , yes you can , you should ideally not call the default handler which is what returning what should have done.