aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Huber <rhuber@gmail.com>2017-04-13 08:30:03 -0700
committerGitHub <noreply@github.com>2017-04-13 08:30:03 -0700
commit5a865767f6463431cf1177f7b4a79b0fc2fcce1d (patch)
tree5cd978fbdeb13f73ad265a9429355585f8a71fd3
parentd96e41d18c1d30a9e34ef72306723a9a04e4153d (diff)
parent8e81464aa2bc220f1bc4453e4c27ecf5f2f82055 (diff)
downloadwee-slack-5a865767f6463431cf1177f7b4a79b0fc2fcce1d.tar.gz
Merge pull request #338 from ToxicFrog/toxicfrog/formatting
Translate slack formatting codes to/from IRC formatting codes
-rw-r--r--wee_slack.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 9ef1f21..fb32829 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -2233,6 +2233,10 @@ def render(message_json, team, channel, force=False):
text = text.replace("&lt;", "<")
text = text.replace("&gt;", ">")
text = text.replace("&amp;", "&")
+ text = re.sub(r'(^| )\*([^*]+)\*([^a-zA-Z0-9_]|$)',
+ r'\1{}\2{}\3'.format(w.color('bold'), w.color('-bold')), text)
+ text = re.sub(r'(^| )_([^_]+)_([^a-zA-Z0-9_]|$)',
+ r'\1{}\2{}\3'.format(w.color('underline'), w.color('-underline')), text)
if type(text) is not unicode:
text = text.decode('UTF-8', 'replace')
@@ -2253,7 +2257,7 @@ def linkify_text(message, team, channel):
# function is only called on message send..
usernames = team.get_username_map()
channels = team.get_channel_map()
- message = message.split(' ')
+ message = message.replace('\x02', '*').replace('\x1F', '_').split(' ')
for item in enumerate(message):
targets = re.match('^\s*([@#])([\w.-]+[\w. -])(\W*)', item[1])
#print targets