aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Kelly <bk@ancilla.ca>2017-07-12 12:18:23 -0400
committerGitHub <noreply@github.com>2017-07-12 12:18:23 -0400
commit0c96ed1ccc93833c1bc31c8af822f37bb5fd0ba8 (patch)
tree32f95c1277f155f7cfe19ac62aece7d785ae7d7e
parentef2712973ad95ddc06cc1cca73e6154fb87f7348 (diff)
parent56ae9127224662befbff55ef5240cb232775f050 (diff)
downloadwee-slack-0c96ed1ccc93833c1bc31c8af822f37bb5fd0ba8.tar.gz
Merge pull request #350 from ToxicFrog/toxicfrog/italics
Add italic support, and settings to switch between italic and underline
-rw-r--r--wee_slack.py39
1 files changed, 27 insertions, 12 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 09252c9..a0600c0 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -2467,9 +2467,13 @@ def render(message_json, team, channel, force=False):
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)
+ r'\1{}\2{}\3'.format(w.color(config.render_bold_as),
+ w.color('-' + config.render_bold_as)),
+ text)
text = re.sub(r'(^| )_([^_]+)_([^a-zA-Z0-9_]|$)',
- r'\1{}\2{}\3'.format(w.color('underline'), w.color('-underline')), text)
+ r'\1{}\2{}\3'.format(w.color(config.render_italic_as),
+ w.color('-' + config.render_italic_as)),
+ text)
# if self.threads:
# text += " [Replies: {} Thread ID: {} ] ".format(len(self.threads), self.thread_id)
@@ -2485,7 +2489,11 @@ 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.replace('\x02', '*').replace('\x1F', '_').split(' ')
+ message = (message
+ .replace('\x02', '*')
+ .replace('\x1D', '_')
+ .replace('\x1F', config.map_underline_to)
+ .split(' '))
for item in enumerate(message):
targets = re.match('^\s*([@#])([\w.-]+[\w. -])(\W*)', item[1])
if targets and targets.groups()[0] == '@':
@@ -3231,6 +3239,9 @@ class PluginConfig(object):
'debug_mode': 'false',
'debug_level': '3',
'distracting_channels': '',
+ 'map_underline_to': '_',
+ 'render_bold_as': 'bold',
+ 'render_italic_as': 'italic',
'show_reaction_nicks': 'false',
'slack_api_token': 'INSERT VALID KEY HERE!',
'slack_timeout': '20000',
@@ -3282,6 +3293,19 @@ class PluginConfig(object):
def get_boolean(self, key):
return w.config_string_to_boolean(w.config_get_plugin(key))
+ def get_string(self, key):
+ return w.config_get_plugin(key)
+
+ def get_int(self, key):
+ return int(w.config_get_plugin(key))
+
+ get_debug_level = get_int
+ get_map_underline_to = get_string
+ get_render_bold_as = get_string
+ get_render_italic_as = get_string
+ get_slack_timeout = get_int
+ get_thread_suffix_color = get_string
+
def get_distracting_channels(self, key):
return [x.strip() for x in w.config_get_plugin(key).split(',')]
@@ -3297,15 +3321,6 @@ class PluginConfig(object):
else:
return token
- def get_thread_suffix_color(self, key):
- return w.config_get_plugin("thread_suffix_color")
-
- def get_debug_level(self, key):
- return int(w.config_get_plugin(key))
-
- def get_slack_timeout(self, key):
- return int(w.config_get_plugin(key))
-
def migrate(self):
"""
This is to migrate the extension name from slack_extension to slack