aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2017-10-17 21:46:04 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2018-09-02 22:21:00 +0200
commit8f15b1b22a1b6bb0b59728870d9cb547d8b7db3d (patch)
treed959f62738a51c7dfd1145369ec92c95383ad7aa
parent6cefb708926195af328f7362fe1f297047b5afd0 (diff)
downloadwee-slack-8f15b1b22a1b6bb0b59728870d9cb547d8b7db3d.tar.gz
Support passing muted as a keyword arg to tag()
For muted channels, we need the tags for muted in addition to the tags we normally want.
-rw-r--r--wee_slack.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 8a321da..2e3800e 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -3126,30 +3126,30 @@ def format_nick(nick, previous_nick=None):
return nick_prefix_color + nick_prefix + w.color("reset") + nick + nick_suffix_color + nick_suffix + w.color("reset")
-def tag(tagset, user=None):
- if user:
- default_tag = "nick_" + user.replace(" ", "_")
- else:
- default_tag = 'nick_unknown'
+def tag(tagset, user=None, muted=False):
tagsets = {
# messages in the team/server buffer, e.g. "new channel created"
- "team_info": "no_highlight,log3",
- "team_message": "irc_privmsg,notify_message,log1",
+ "team_info": {"no_highlight", "log3"},
+ "team_message": {"irc_privmsg", "notify_message", "log1"},
# when replaying something old
- "backlog": "irc_privmsg,no_highlight,notify_none,logger_backlog",
- # when posting messages to a muted channel
- "muted": "irc_privmsg,no_highlight,notify_none,log1",
+ "backlog": {"irc_privmsg", "no_highlight", "notify_none", "logger_backlog"},
# when receiving a direct message
- "dm": "irc_privmsg,notify_private,log1",
- "dmfromme": "irc_privmsg,no_highlight,notify_none,log1",
+ "dm": {"irc_privmsg", "notify_private", "log1"},
+ "dmfromme": {"irc_privmsg", "no_highlight", "notify_none", "log1"},
# when this is a join/leave, attach for smart filter ala:
# if user in [x.strip() for x in w.prefix("join"), w.prefix("quit")]
- "joinleave": "irc_smart_filter,no_highlight,log4",
- "topic": "irc_topic,no_highlight,log3",
+ "joinleave": {"irc_smart_filter", "no_highlight", "log4"},
+ "topic": {"irc_topic", "no_highlight", "log3"},
# catchall ?
- "default": "irc_privmsg,notify_message,log1",
+ "default": {"irc_privmsg", "notify_message", "log1"},
}
- return "{},slack_{},{}".format(default_tag, tagset, tagsets[tagset])
+ nick_tag = {"nick_{}".format(user or "unknown").replace(" ", "_")}
+ slack_tag = {"slack_{}".format(tagset)}
+ tags = nick_tag | slack_tag | tagsets[tagset]
+ if muted:
+ tags -= {"notify_highlight", "notify_message", "notify_private"}
+ tags |= {"no_highlight", "notify_none"}
+ return ",".join(tags)
###### New/converted command_ commands