Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
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;
}
};
@the-solipsist

This comment has been minimized.

Copy link

@the-solipsist the-solipsist commented Oct 11, 2013

Is there any way to:

  1. add ttytter's tweet code to the output?
  2. prevent each tweet from appearing twice in the timeline (i.e., remove ttytter's native output)?
@RC1140

This comment has been minimized.

Copy link
Owner Author

@RC1140 RC1140 commented Jul 28, 2014

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.