aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Huber <rhuber@gmail.com>2017-02-09 11:37:54 -0800
committerRyan Huber <rhuber@gmail.com>2017-02-09 11:37:54 -0800
commit8aba52aa6993ed480ea50cdb58d8d2d26f3eb5bc (patch)
tree687dfe54775b5803955b1bb6b4acc4d05ff9d65c
parent966cd40a8322e18b0ca9db012568ca823edd76eb (diff)
downloadwee-slack-8aba52aa6993ed480ea50cdb58d8d2d26f3eb5bc.tar.gz
handle topic fully
-rw-r--r--wee_slack.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 8649e47..1705ef3 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -952,6 +952,7 @@ class SlackChannel(object):
self.members = set(kwargs.get('members', set()))
self.eventrouter = eventrouter
self.slack_name = kwargs["name"]
+ self.slack_topic = kwargs.get("topic", {"value": ""})
self.identifier = kwargs["id"]
self.last_read = SlackTS(kwargs.get("last_read", SlackTS()))
#print self.last_read
@@ -998,6 +999,14 @@ class SlackChannel(object):
"long_base": "{}.{}".format(self.team.domain, self.slack_name),
}
return select[style]
+ def render_topic(self, topic=None):
+ if self.channel_buffer:
+ if not topic:
+ encoded_topic = self.slack_topic['value'].encode('utf-8')
+ else:
+ encoded_topic = topic.encode('utf-8')
+ self.encoded_topic = topic.encode('utf-8')
+ w.buffer_set(self.channel_buffer, "title", encoded_topic)
def update_from_message_json(self, message_json):
for key, value in message_json.items():
setattr(self, key, value)
@@ -1053,6 +1062,7 @@ class SlackChannel(object):
w.buffer_set(self.channel_buffer, "localvar_set_type", 'channel')
w.buffer_set(self.channel_buffer, "localvar_set_channel", self.formatted_name())
w.buffer_set(self.channel_buffer, "short_name", self.formatted_name(style="sidebar", enable_color=True))
+ self.render_topic()
#if self.server.alias:
# w.buffer_set(self.channel_buffer, "localvar_set_server", self.server.alias)
#else:
@@ -1862,7 +1872,7 @@ def process_message(message_json, eventrouter, store=True, **kwargs):
'message_deleted',
'channel_join',
'channel_leave',
- #'channel_topic',
+ 'channel_topic',
#'group_join',
#'group_leave',
]
@@ -1986,6 +1996,11 @@ def subprocess_message_changed(message_json, eventrouter, channel, team):
def subprocess_message_deleted(message_json, eventrouter, channel, team):
channel.change_message(message_json["deleted_ts"], "(deleted)", '')
+def subprocess_channel_topic(message_json, eventrouter, channel, team):
+ text = unfurl_refs(message_json["text"], ignore_alt_text=False)
+ channel.buffer_prnt(w.prefix("network").rstrip(), text, message_json["ts"])
+ channel.render_topic(message_json["topic"])
+
def process_reply(message_json, eventrouter, **kwargs):
dbg('processing reply')
team = kwargs["team"]
@@ -2395,19 +2410,14 @@ def command_topic(data, current_buffer, args):
Change the topic of a channel
/slack topic [<channel>] [<topic>|-delete]
"""
- print args
- print 'topic'
e = EVENTROUTER
team = e.weechat_controller.buffers[current_buffer].team
- print team
#server = servers.find(current_domain_name())
args = args.split(' ')
- print args
if len(args) > 2 and args[1].startswith('#'):
cmap = team.get_channel_map()
channel_name = args[1][1:]
channel = team.channels[cmap[channel_name]]
- print channel
topic = " ".join(args[2:])
else:
channel = e.weechat_controller.buffers[current_buffer]