From 2c8ff697bd64068aa706dc4c15874af067dc065f Mon Sep 17 00:00:00 2001 From: moneromooo Date: Wed, 31 Dec 2014 10:31:16 +0000 Subject: [PATCH] Rejig !commands to be less spammy Commands are now organized per module, and full command sysnopsis is only given for a module at a time --- tipbot.py | 24 ++++++++++++------------ tipbot/command_manager.py | 27 +++++++++++++++++++++++---- tipbot/modules/tipping.py | 3 +++ tipbot/modules/withdraw.py | 3 +++ 4 files changed, 41 insertions(+), 16 deletions(-) diff --git a/tipbot.py b/tipbot.py index 6f86130..d51960b 100644 --- a/tipbot.py +++ b/tipbot.py @@ -178,7 +178,7 @@ def DumpUsers(nick,chan,cmd): log_info(str(userstable)) def Help(nick,chan,cmd): - SendTo(nick, "See available commands with !commands") + SendTo(nick, "See available commands with !commands or !commands ") if 'payment' in modulenames: SendTo(nick, "You can send %s to your account:" % coinspecs.name); SendTo(nick, " Address: %s" % GetTipbotAddress()) @@ -237,18 +237,18 @@ def OnIdentified(nick, identified): RunNextCommand(nick, identified) def RegisterCommands(): - RegisterCommand({'name': 'help', 'function': Help, 'help': "Displays help about %s" % config.tipbot_name}) - RegisterCommand({'name': 'commands', 'function': Commands, 'help': "Displays list of commands"}) - RegisterCommand({'name': 'isregistered', 'function': IsRegistered, 'help': "show whether you are currently registered with freenode"}) - RegisterCommand({'name': 'balance', 'function': GetBalance, 'registered': True, 'help': "show your current balance"}) - RegisterCommand({'name': 'info', 'function': Info, 'help': "infornmation about %s" % config.tipbot_name}) + RegisterCommand({'module': 'builtin', 'name': 'help', 'function': Help, 'help': "Displays help about %s" % config.tipbot_name}) + RegisterCommand({'module': 'builtin', 'name': 'commands', 'parms': '[module]', 'function': Commands, 'help': "Displays list of commands"}) + RegisterCommand({'module': 'builtin', 'name': 'isregistered', 'function': IsRegistered, 'help': "show whether you are currently registered with freenode"}) + RegisterCommand({'module': 'builtin', 'name': 'balance', 'function': GetBalance, 'registered': True, 'help': "show your current balance"}) + RegisterCommand({'module': 'builtin', 'name': 'info', 'function': Info, 'help': "infornmation about %s" % config.tipbot_name}) - RegisterCommand({'name': 'height', 'function': GetHeight, 'admin': True, 'help': "Get current blockchain height"}) - RegisterCommand({'name': 'tipbot_balance', 'function': GetTipbotBalance, 'admin': True, 'help': "Get current blockchain height"}) - RegisterCommand({'name': 'addbalance', 'function': AddBalance, 'admin': True, 'help': "Add balance to your account"}) - RegisterCommand({'name': 'scanwho', 'function': ScanWho, 'admin': True, 'help': "Refresh users list in a channel"}) - RegisterCommand({'name': 'dump_users', 'function': DumpUsers, 'admin': True, 'help': "Dump users table to log"}) - RegisterCommand({'name': 'show_activity', 'function': ShowActivity, 'admin': True, 'help': "Show time since a user was last active"}) + RegisterCommand({'module': 'builtin', 'name': 'height', 'function': GetHeight, 'admin': True, 'help': "Get current blockchain height"}) + RegisterCommand({'module': 'builtin', 'name': 'tipbot_balance', 'function': GetTipbotBalance, 'admin': True, 'help': "Get current blockchain height"}) + RegisterCommand({'module': 'builtin', 'name': 'addbalance', 'function': AddBalance, 'admin': True, 'help': "Add balance to your account"}) + RegisterCommand({'module': 'builtin', 'name': 'scanwho', 'function': ScanWho, 'admin': True, 'help': "Refresh users list in a channel"}) + RegisterCommand({'module': 'builtin', 'name': 'dump_users', 'function': DumpUsers, 'admin': True, 'help': "Dump users table to log"}) + RegisterCommand({'module': 'builtin', 'name': 'show_activity', 'function': ShowActivity, 'admin': True, 'help': "Show time since a user was last active"}) def OnCommandProxy(cmd,chan,who): OnCommand(cmd,chan,who,RunAdminCommand,RunRegisteredCommand) diff --git a/tipbot/command_manager.py b/tipbot/command_manager.py index da5e0c8..629d97b 100644 --- a/tipbot/command_manager.py +++ b/tipbot/command_manager.py @@ -59,15 +59,34 @@ def Commands(nick,chan,cmd): all = True else: all = False + + module_name = GetParam(cmd,1) + SendTo(nick, "Commands for %s:" % config.tipbot_name) + + msgs = dict() for command_name in commands: c = commands[command_name] if 'admin' in c and c['admin'] and not all: continue - synopsis = c['name'] - if 'parms' in c: - synopsis = synopsis + " " + c['parms'] - SendTo(nick, "%s - %s" % (synopsis, c['help'])) + module = c['module'] + if module_name: + if module_name != module: + continue + synopsis = c['name'] + if 'parms' in c: + synopsis = synopsis + " " + c['parms'] + SendTo(nick, "%s - %s" % (synopsis, c['help'])) + else: + if module in msgs: + msgs[module] = msgs[module] +(", ") + else: + msgs[module] = module + " module: " + msgs[module] = msgs[module] +(c['name']) + + if not module_name: + for msg in msgs: + SendTo(nick, "%s" % msgs[msg]) def RegisterCommand(command): commands[command['name']] = command diff --git a/tipbot/modules/tipping.py b/tipbot/modules/tipping.py index bce7061..10815e6 100644 --- a/tipbot/modules/tipping.py +++ b/tipbot/modules/tipping.py @@ -247,6 +247,7 @@ def RainActive(nick,chan,cmd): RegisterCommand({ + 'module': 'tipping', 'name': 'tip', 'parms': ' ', 'function': Tip, @@ -254,6 +255,7 @@ RegisterCommand({ 'help': "tip another user" }) RegisterCommand({ + 'module': 'tipping', 'name': 'rain', 'parms': ' []', 'function': Rain, @@ -261,6 +263,7 @@ RegisterCommand({ 'help': "rain some coins on everyone (or just a few)" }) RegisterCommand({ + 'module': 'tipping', 'name': 'rainactive', 'parms': ' []', 'function': RainActive, diff --git a/tipbot/modules/withdraw.py b/tipbot/modules/withdraw.py index 262506b..b243fe8 100644 --- a/tipbot/modules/withdraw.py +++ b/tipbot/modules/withdraw.py @@ -147,6 +147,7 @@ def Withdraw(nick,chan,cmd): RegisterCommand({ + 'module': 'withdraw', 'name': 'withdraw', 'parms': '
[]', 'function': Withdraw, @@ -154,12 +155,14 @@ RegisterCommand({ 'help': "withdraw part or all of your balance" }) RegisterCommand({ + 'module': 'withdraw', 'name': 'enable_withdraw', 'function': EnableWithdraw, 'admin': True, 'help': "Enable withdrawals" }) RegisterCommand({ + 'module': 'withdraw', 'name': 'disable_withdraw', 'function': DisableWithdraw, 'admin': True,