aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2016-03-05 00:22:32 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2016-04-22 16:41:55 +0200
commitbef6007e5450639f2a5f64e7fa6ce15db56d30c6 (patch)
treecce8c9b709b2f1118e109bf9b16d3111b9c6ac0c
parent339ccaff398bfc959b20c61faa1dc1ca09590164 (diff)
downloadwee-slack-bef6007e5450639f2a5f64e7fa6ce15db56d30c6.tar.gz
Add a config option for showing nicks for reactions
Some may think it takes up too much space to show all the nicks for all of the reactions. This adds a config option `show_reaction_nicks` for configuring that. If set to false, it only shows the number of persons that added each reaction, like before. If set to true, it shows the new version with each nick. It defaults to false, to not change the behavior.
-rw-r--r--wee_slack.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 5f2be1d..1ee1fc8 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1575,8 +1575,12 @@ def create_reaction_string(reactions):
for r in reactions:
if len(r["users"]) > 0:
count += 1
- users = ",".join(resolve_ref("@{}".format(user)) for user in r["users"])
- reaction_string += ":{}:({}) ".format(r["name"], users)
+ if show_reaction_nicks:
+ nicks = [resolve_ref("@{}".format(user)) for user in r["users"]]
+ users = "({})".format(",".join(nicks))
+ else:
+ users = len(r["users"])
+ reaction_string += ":{}:{} ".format(r["name"], users)
reaction_string = reaction_string[:-1] + ']'
if count == 0:
reaction_string = ''
@@ -2150,7 +2154,7 @@ def create_slack_debug_buffer():
def config_changed_cb(data, option, value):
global slack_api_token, distracting_channels, colorize_nicks, colorize_private_chats, slack_debug, debug_mode, \
- unfurl_ignore_alt_text, colorize_messages
+ unfurl_ignore_alt_text, colorize_messages, show_reaction_nicks
slack_api_token = w.config_get_plugin("slack_api_token")
@@ -2164,6 +2168,7 @@ def config_changed_cb(data, option, value):
if debug_mode != '' and debug_mode != 'false':
create_slack_debug_buffer()
colorize_private_chats = w.config_string_to_boolean(w.config_get_plugin("colorize_private_chats"))
+ show_reaction_nicks = w.config_string_to_boolean(w.config_get_plugin("show_reaction_nicks"))
unfurl_ignore_alt_text = False
if w.config_get_plugin('unfurl_ignore_alt_text') != "0":
@@ -2234,6 +2239,8 @@ if __name__ == "__main__":
w.config_set_plugin('unfurl_ignore_alt_text', "0")
if not w.config_get_plugin('switch_buffer_on_join'):
w.config_set_plugin('switch_buffer_on_join', "1")
+ if not w.config_get_plugin('show_reaction_nicks'):
+ w.config_set_plugin('show_reaction_nicks', "0")
if w.config_get_plugin('channels_not_on_current_server_color'):
w.config_option_unset('channels_not_on_current_server_color')