aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorRyan Huber <rhuber@gmail.com>2015-11-20 09:48:59 -0800
committerRyan Huber <rhuber@gmail.com>2015-11-20 09:48:59 -0800
commit9790e9a4487cf0222c8d3ed857e68e062afa1211 (patch)
tree1867c755ac1c6e09f4afe9918e48527d00e6bb36 /wee_slack.py
parent72347bfe9826245c8df42bd04122786aaea9083d (diff)
downloadwee-slack-9790e9a4487cf0222c8d3ed857e68e062afa1211.tar.gz
add code to do changes of topic.
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 1dc7fed..2298205 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1195,6 +1195,37 @@ 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:
+ 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()
@@ -2108,6 +2139,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", "")