From 8e81464aa2bc220f1bc4453e4c27ecf5f2f82055 Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Wed, 1 Mar 2017 10:59:35 -0500 Subject: Translate slack formatting codes to/from IRC formatting codes Signed-off-by: Ben Kelly --- wee_slack.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'wee_slack.py') diff --git a/wee_slack.py b/wee_slack.py index e8b736c..f315e75 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -2225,6 +2225,10 @@ def render(message_json, team, channel, force=False): text = text.replace("<", "<") text = text.replace(">", ">") text = text.replace("&", "&") + 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') @@ -2245,7 +2249,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 -- cgit