Created
September 6, 2011 09:31
-
-
Save drags/1197116 to your computer and use it in GitHub Desktop.
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
if (lc($item->{'user'}->{'screen_name'}) ne lc($heap->{'username'})) { | |
if ($heap->{'config'}->{'expand_urls'}==1 && defined($item->{'entities'}->{'urls'})) { | |
foreach my $url (@{$item->{'entities'}->{'urls'}}) { | |
$kernel->post('logger','log','Replacing URL ' . $url->{'url'} . ' with ' . $url->{'expanded_url'},$heap->{'username'}) if ($config{'debug'} >= 2); | |
my $search = $url->{'url'}; | |
my $replace = $url->{'expanded_url'}; | |
$item->{'text'} =~ s/$search/$replace/g; | |
# Also replace text in retweets | |
if(defined($item->{'retweeted_status'})) { | |
$item->{'retweeted_status'}->{'text'} =~ s/$search/$replace/g; | |
} | |
} | |
} | |
if ($heap->{'config'}->{'show_realname'} == 1 && defined($item->{'entities'}->{'user_mentions'})) { | |
foreach my $user (@{$item->{'entities'}->{'user_mentions'}}) { | |
$kernel->post('logger','log','Showing realname ' . $user->{'name'} . ' for ' . $user->{'screen_name'},$heap->{'username'}) if ($config{'debug'} >= 2); | |
my $search = "@" . $user->{'screen_name'}; | |
my $replace = "@" . $user->{'screen_name'} . " (" . $user->{'name'} . ")"; | |
$item->{'text'} =~ s/$search/$replace/g; | |
# Also replace text in retweets | |
if(defined($item->{'retweeted_status'})) { | |
$item->{'retweeted_status'}->{'text'} =~ s/$search/$replace/g; | |
# TODO what? | |
if ($user->{'screen_name'} eq $item->{'retweeted_status'}->{'user'}->{'screen_name'}) { | |
# If the text does not contain the username of the person being retweeted | |
# also add realname first in text | |
if ($item->{'retweeted_status'}->{'text'} !~ /$item->{'retweeted_status'}->{'user'}->{'screen_name'}/) { | |
my $search = "^"; | |
my $replace = "(" . $user->{'name'} . ") "; | |
$item->{'retweeted_status'}->{'text'} =~ s/$search/$replace/g; | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment