aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2018-11-06 19:42:44 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2019-01-26 12:51:07 +0100
commitc311c37fa99fe31cead934a26646f3235b2c96a8 (patch)
treea486ad79e458c3ffddaf8d6be9393fbe0f37c7bd
parente71aa42a64429a57215f878f1f30985e36b198d7 (diff)
downloadwee-slack-c311c37fa99fe31cead934a26646f3235b2c96a8.tar.gz
Add /slack help command
Fixes #363
-rw-r--r--wee_slack.py30
1 files changed, 26 insertions, 4 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 08cf0d4..4bdb229 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -3584,6 +3584,30 @@ def slack_command_cb(data, current_buffer, args):
return w.WEECHAT_RC_OK
+@utf8_decode
+def command_help(data, current_buffer, args):
+ """
+ /slack help
+ Print help for /slack commands
+ """
+ args = args.split()
+ if len(args) > 1:
+ cmd = EVENTROUTER.cmds.get(args[1])
+ if cmd:
+ cmds = {args[1]: cmd}
+ else:
+ w.prnt('', 'Command not found: ' + args[1])
+ return w.WEECHAT_RC_OK
+ else:
+ cmds = EVENTROUTER.cmds
+ w.prnt('', 'Slack commands:')
+
+ for name, cmd in sorted(cmds.items()):
+ helptext = (cmd.__doc__ or '').rstrip()
+ w.prnt('', '{}:{}'.format(name, helptext))
+ return w.WEECHAT_RC_OK
+
+
@slack_buffer_required
def command_distracting(data, current_buffer, args):
channel = EVENTROUTER.weechat_controller.buffers.get(current_buffer, None)
@@ -3850,8 +3874,6 @@ def load_emoji():
def setup_hooks():
- cmds = get_functions_with_prefix("command_")
-
w.bar_item_new('slack_typing_notice', '(extra)typing_bar_item_cb', '')
w.hook_timer(1000, 0, 0, "typing_update_cb", "")
@@ -3873,10 +3895,10 @@ def setup_hooks():
'[command] [command options]',
# Description of arguments
'Commands:\n' +
- '\n'.join(cmds.keys()) +
+ '\n'.join(sorted(EVENTROUTER.cmds.keys())) +
'\nUse /slack help [command] to find out more\n',
# Completions
- '|'.join(cmds.keys()),
+ '|'.join(EVENTROUTER.cmds.keys()),
# Function name
'slack_command_cb', '')
# w.hook_command('me', '', 'stuff', 'stuff2', '', 'me_command_cb', '')