aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py58
1 files changed, 31 insertions, 27 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 2cdbb8f..3b46bc0 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1026,7 +1026,6 @@ class SlackTeam(object):
w.buffer_set(self.channel_buffer, "localvar_set_server", self.preferred_name)
if w.config_string(w.config_get('irc.look.server_buffer')) == 'merge_with_core':
w.buffer_merge(self.channel_buffer, w.buffer_search_main())
- w.buffer_set(self.channel_buffer, "nicklist", "1")
def set_muted_channels(self, muted_str):
self.muted_channels = {x for x in muted_str.split(',')}
@@ -1041,7 +1040,7 @@ class SlackTeam(object):
return self.domain
def buffer_prnt(self, data):
- w.prnt_date_tags(self.channel_buffer, SlackTS().major, tag("backlog"), data)
+ w.prnt_date_tags(self.channel_buffer, SlackTS().major, tag("team"), data)
def get_channel_map(self):
return {v.slack_name: k for k, v in self.channels.iteritems()}
@@ -1247,22 +1246,20 @@ class SlackChannel(object):
# self.create_buffer()
def check_should_open(self, force=False):
- try:
- if self.is_archived:
- return
- except:
- pass
+ if hasattr(self, "is_archived") and self.is_archived:
+ return
+
if force:
self.create_buffer()
- else:
- for reason in ["is_member", "is_open", "unread_count_display"]:
- try:
- if eval("self." + reason):
- self.create_buffer()
- if config.background_load_all_history:
- self.get_history(slow_queue=True)
- except:
- pass
+ return
+
+ # Only check is_member if is_open is not set, because in some cases
+ # (e.g. group DMs), is_member should be ignored in favor of is_open.
+ is_open = self.is_open if hasattr(self, "is_open") else self.is_member
+ if is_open or self.unread_count_display:
+ self.create_buffer()
+ if config.background_load_all_history:
+ self.get_history(slow_queue=True)
def set_related_server(self, team):
self.team = team
@@ -1270,7 +1267,7 @@ class SlackChannel(object):
def set_highlights(self):
# highlight my own name and any set highlights
if self.channel_buffer:
- highlights = self.team.highlight_words.union({'@' + self.team.nick, "!here", "!channel", "!everyone"})
+ highlights = self.team.highlight_words.union({'@' + self.team.nick, self.team.myidentifier, "!here", "!channel", "!everyone"})
h_str = ",".join(highlights)
w.buffer_set(self.channel_buffer, "highlight_words", h_str)
@@ -1517,7 +1514,7 @@ class SlackChannel(object):
def update_nicklist(self, user=None):
if not self.channel_buffer:
return
- if self.type not in ["channel", "group"]:
+ if self.type not in ["channel", "group", "mpim"]:
return
w.buffer_set(self.channel_buffer, "nicklist", "1")
# create nicklists for the current channel if they don't exist
@@ -2840,20 +2837,20 @@ def tag(tagset, user=None):
else:
default_tag = 'nick_unknown'
tagsets = {
+ # messages in the team/server buffer, e.g. "new channel created"
+ "team": "irc_notice,notify_private,log3",
# when replaying something old
- "backlog": "no_highlight,notify_none,logger_backlog_end",
+ "backlog": "irc_privmsg,no_highlight,notify_none,logger_backlog",
# when posting messages to a muted channel
- "muted": "no_highlight,notify_none,logger_backlog_end",
- # when my nick is in the message
- "highlightme": "notify_highlight,log1",
+ "muted": "irc_privmsg,no_highlight,notify_none,log1",
# when receiving a direct message
- "dm": "notify_private,notify_message,log1,irc_privmsg",
- "dmfromme": "notify_none,log1,irc_privmsg",
+ "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",
+ "joinleave": "irc_smart_filter,no_highlight,log4",
# catchall ?
- "default": "notify_message,log1",
+ "default": "irc_privmsg,notify_message,log1",
}
return default_tag + "," + tagsets[tagset]
@@ -2994,6 +2991,8 @@ def command_talk(data, current_buffer, args):
c = team.get_channel_map()
if channel_name not in c:
u = team.get_username_map()
+ if channel_name.startswith('@'):
+ channel_name = channel_name[1:]
if channel_name in u:
s = SlackRequest(team.token, "im.open", {"user": u[channel_name]}, team_hash=team.team_hash)
EVENTROUTER.receive(s)
@@ -3334,7 +3333,8 @@ def setup_hooks():
w.hook_signal('buffer_switch', "buffer_switch_callback", "EVENTROUTER")
w.hook_signal('window_switch', "buffer_switch_callback", "EVENTROUTER")
w.hook_signal('quit', "quit_notification_cb", "")
- w.hook_signal('input_text_changed', "typing_notification_cb", "")
+ if config.send_typing_notice:
+ w.hook_signal('input_text_changed', "typing_notification_cb", "")
w.hook_command(
# Command name and description
@@ -3457,6 +3457,10 @@ class PluginConfig(object):
default='italic',
desc='When receiving bold text from Slack, render it as this in weechat.'
' If your terminal lacks italic support, consider using "underline" instead.'),
+ 'send_typing_notice': Setting(
+ default='true',
+ desc='Alert Slack users when you are typing a message in the input bar '
+ '(Requires reload)'),
'server_aliases': Setting(
default='',
desc='A comma separated list of `subdomain:alias` pairs. The alias'