From 6823e0f92695801b45a07c47aeccec780585b6a9 Mon Sep 17 00:00:00 2001 From: moneromooo Date: Sun, 11 Jan 2015 09:47:24 +0000 Subject: [PATCH] Show a list of modules in help --- tipbot.py | 1 + tipbot/command_manager.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/tipbot.py b/tipbot.py index 5451646..26b84bc 100644 --- a/tipbot.py +++ b/tipbot.py @@ -163,6 +163,7 @@ def Help(nick,chan,cmd): return SendTo(nick, "See available commands with !commands or !commands ") + SendTo(nick, "Available modules: %s" % ", ".join(GetModuleNameList(IsAdmin(nick)))) SendTo(nick, "Get help on a particular module with !help ") if coinspecs.web_wallet_url: SendTo(nick, "No %s address ? You can use %s" % (coinspecs.name, coinspecs.web_wallet_url)) diff --git a/tipbot/command_manager.py b/tipbot/command_manager.py index 2a6a2f4..3767a61 100644 --- a/tipbot/command_manager.py +++ b/tipbot/command_manager.py @@ -102,6 +102,22 @@ def RegisterModule(module): return modules[module['name']] = module +def GetModuleNameList(admin): + if admin: + all = True + else: + all = False + + module_names = [] + for command_name in commands: + for c in commands[command_name]: + if 'admin' in c and c['admin'] and not all: + continue + module = c['module'] + if not module in module_names: + module_names.append(module) + return module_names + def RegisterCommand(command): if command['name'] in commands: log_warn('module %s redefined function %s from module %s' % (command['module'],command['name'],commands[command['name']][0]['module']))