From ea5b33638af9be5cd90dda3807a8bd4a33d53a6a Mon Sep 17 00:00:00 2001 From: spline Date: Fri, 26 Oct 2012 06:52:35 -0400 Subject: [PATCH] Add in color url support in text for tweets. --- plugin.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/plugin.py b/plugin.py index ccef25e..960d966 100644 --- a/plugin.py +++ b/plugin.py @@ -267,11 +267,7 @@ class Tweety(callbacks.Plugin): # twitter = OAuthApi(self.registryValue('consumerKey'), self.registryValue('consumerSecret'), self.registryValue('accessKey'), self.registryValue('accessSecret')) - def _highlightUrl(self, text): - URL_REGEX = compile_regex('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+') - - - def _encode(string): + def _encode(self, string): try: return string.encode(stdout.encoding, 'replace') except AttributeError: @@ -356,8 +352,9 @@ class Tweety(callbacks.Plugin): # add in the end with the text + tape if outputColorTweets: + text = re.sub(r'(http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+)', ircutils.mircColor(r'\1', 'red'), text) # color urls. ret += ": {0} ({1})".format(text, ircutils.mircColor(time, 'yellow')) - else: + else: ret += ": {0} ({1})".format(text, ircutils.bold(time)) if self.registryValue('addShortUrl', msg.args[0]):