diff options
author | Ryan Huber <rhuber@gmail.com> | 2015-02-24 12:04:34 -0800 |
---|---|---|
committer | Ryan Huber <rhuber@gmail.com> | 2015-02-24 12:04:34 -0800 |
commit | d0decb93ec333062b4230fa6b836169d491d8e87 (patch) | |
tree | 45a77edb9582024b340c42413a07bd69bfd2ae8c | |
parent | 7ece5a48e9d258bd5be8bf830e63b2814bd5d599 (diff) | |
download | wee-slack-d0decb93ec333062b4230fa6b836169d491d8e87.tar.gz |
add channel trigger for use with iterm2
-rw-r--r-- | wee_slack.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py index 7c9b3f3..aadf9e8 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -950,6 +950,22 @@ def command_help(current_buffer, args): # Websocket handling methods +def command_openweb(current_buffer, args): + trigger = w.config_get_plugin('trigger_value') + if trigger != "0": + if args is None: + channel = channels.find(current_buffer) + url = "{}/messages/{}".format(channel.server.domain, channel.name) + topic = w.buffer_get_string(channel.channel_buffer, "title") + w.buffer_set(channel.channel_buffer, "title", "{}:{}".format(trigger, url)) + w.hook_timer(1000, 0, 1, "command_openweb", json.dumps({"topic": topic, "buffer": current_buffer})) + else: + #TODO: fix this dirty hack because i don't know the right way to send multiple args. + args = current_buffer + data = json.loads(args) + channel_buffer = channels.find(data["buffer"]).channel_buffer + w.buffer_set(channel_buffer, "title", data["topic"]) + return w.WEECHAT_RC_OK def slack_websocket_cb(server, fd): try: @@ -1533,6 +1549,8 @@ if __name__ == "__main__": w.config_set_plugin('debug_mode', "") if not w.config_get_plugin('colorize_nicks'): w.config_set_plugin('colorize_nicks', "1") + if not w.config_get_plugin('trigger_value'): + w.config_set_plugin('trigger_value', "0") version = w.info_get("version_number", "") or 0 if int(version) >= 0x00040400: |