diff options
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/wee_slack.py b/wee_slack.py index 8a2276f..f86ee60 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -664,15 +664,15 @@ class Channel(object): tags += ",no_highlight,notify_none,logger_backlog_end" set_read_marker = True elif message.find(self.server.nick.encode('utf-8')) > -1: - tags = ",notify_highlight,log1" + tags += ",notify_highlight,log1" elif user != self.server.nick and self.name in self.server.users: - tags = ",notify_private,notify_message,log1,irc_privmsg" + tags += ",notify_private,notify_message,log1,irc_privmsg" elif self.muted: - tags = ",no_highlight,notify_none,logger_backlog_end" + tags += ",no_highlight,notify_none,logger_backlog_end" elif user in [x.strip() for x in w.prefix("join"), w.prefix("quit")]: - tags = ",irc_smart_filter" + tags += ",irc_smart_filter" else: - tags = ",notify_message,log1,irc_privmsg" + tags += ",notify_message,log1,irc_privmsg" # don't write these to local log files # tags += ",no_log" time_int = int(time_float) @@ -685,7 +685,12 @@ class Channel(object): name = prefix_same_nick else: nick_prefix = w.config_string(w.config_get('weechat.look.nick_prefix')) + nick_prefix_color_name = w.config_string(w.config_get('weechat.color.chat_nick_prefix')) + nick_prefix_color = w.color(nick_prefix_color_name) + nick_suffix = w.config_string(w.config_get('weechat.look.nick_suffix')) + nick_suffix_color_name = w.config_string(w.config_get('weechat.color.chat_nick_prefix')) + nick_suffix_color = w.color(nick_suffix_color_name) if user_obj: name = user_obj.formatted_name() @@ -694,7 +699,7 @@ class Channel(object): else: name = user self.last_active_user = None - name = nick_prefix + name + nick_suffix + name = nick_prefix_color + nick_prefix + w.color("reset") + name + nick_suffix_color + nick_suffix + w.color("reset") name = name.decode('utf-8') # colorize nicks in each line chat_color = w.config_string(w.config_get('weechat.color.chat')) @@ -1316,6 +1321,35 @@ def command_markread(current_buffer, args): servers.find(domain).channels.find(channel).mark_read() +@slack_buffer_required +def command_slash(current_buffer, args): + """ + Support for custom slack commands + /slack slash /customcommand arg1 arg2 arg3 + """ + + server = servers.find(current_domain_name()) + channel = current_buffer_name(short=True) + domain = current_domain_name() + + if args is None: + server.buffer_prnt("Usage: /slack slash /someslashcommand [arguments...].") + return + + split_args = args.split(None, 1) + + command = split_args[0] + text = split_args[1] if len(split_args) > 1 else "" + + if servers.find(domain).channels.find(channel): + channel_identifier = servers.find(domain).channels.find(channel).identifier + + if channel_identifier: + async_slack_api_request(server.domain, server.token, 'chat.command', {'command': command, 'text': text, 'channel': channel_identifier}) + else: + server.buffer_prnt("User or channel not found.") + + def command_flushcache(current_buffer, args): global message_cache message_cache = collections.defaultdict(list) |