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
This commit is contained in:
moneromooo 2014-12-31 10:31:16 +00:00
parent 85a7348571
commit 2c8ff697bd
4 changed files with 41 additions and 16 deletions

View file

@ -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 <modulename>")
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)

View file

@ -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

View file

@ -247,6 +247,7 @@ def RainActive(nick,chan,cmd):
RegisterCommand({
'module': 'tipping',
'name': 'tip',
'parms': '<nick> <amount>',
'function': Tip,
@ -254,6 +255,7 @@ RegisterCommand({
'help': "tip another user"
})
RegisterCommand({
'module': 'tipping',
'name': 'rain',
'parms': '<amount> [<users>]',
'function': Rain,
@ -261,6 +263,7 @@ RegisterCommand({
'help': "rain some coins on everyone (or just a few)"
})
RegisterCommand({
'module': 'tipping',
'name': 'rainactive',
'parms': '<amount> [<hours>]',
'function': RainActive,

View file

@ -147,6 +147,7 @@ def Withdraw(nick,chan,cmd):
RegisterCommand({
'module': 'withdraw',
'name': 'withdraw',
'parms': '<address> [<amount>]',
'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,