aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 5af9cca..c665d35 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1197,6 +1197,40 @@ def command_openweb(current_buffer, args):
w.buffer_set(channel_buffer, "title", data["topic"])
return w.WEECHAT_RC_OK
+def topic_command_cb(data, current_buffer, args):
+ if command_topic(current_buffer, args.split(None, 1)[1]):
+ return w.WEECHAT_RC_OK_EAT
+ else:
+ return w.WEECHAT_RC_OK
+
+def command_topic(current_buffer, args):
+ """
+ Change the topic of a channel
+ /slack topic [<channel>] [<topic>|-delete]
+ """
+ server = servers.find(current_domain_name())
+ if server:
+ arrrrgs = args.split(None, 1)
+ if arrrrgs[0].startswith('#'):
+ channel = server.channels.find(arrrrgs[0])
+ topic = arrrrgs[1]
+ else:
+ channel = server.channels.find(current_buffer)
+ topic = args
+
+ if channel:
+ if topic == "-delete":
+ async_slack_api_request(server.domain, server.token, 'channels.setTopic', {"channel": channel.identifier, "topic": ""})
+ else:
+ async_slack_api_request(server.domain, server.token, 'channels.setTopic', {"channel": channel.identifier, "topic": topic})
+ return True
+ else:
+ return False
+ else:
+ return False
+
+
+
def slack_websocket_cb(server, fd):
try:
data = servers.find(server).ws.recv()
@@ -2110,6 +2144,7 @@ if __name__ == "__main__":
w.hook_command_run('/join', 'join_command_cb', '')
w.hook_command_run('/part', 'part_command_cb', '')
w.hook_command_run('/leave', 'part_command_cb', '')
+ w.hook_command_run('/topic', 'topic_command_cb', '')
w.hook_command_run("/input complete_next", "complete_next_cb", "")
w.hook_completion("nicks", "complete @-nicks for slack",
"nick_completion_cb", "")