# HG changeset patch # User Charly COSTE # Date 1263765326 -3600 # Node ID 0a8f96a1d2001aff5ecf83d5068b00d70eaeefaa # Parent 17305e57f71da0e7dd8b39d8790762014a7580bb added a "debug" command to be able to change the value of Bot.debug without restarting the bot Signed-off-by: Charly COSTE diff --git a/commands.py b/commands.py --- a/commands.py +++ b/commands.py @@ -26,7 +26,7 @@ from bridge import Bridge commands = ['xmpp-participants', 'irc-participants', 'xmpp-connections', 'irc-connections', 'connections', 'bridges'] -admin_commands = ['add-bridge', 'add-xmpp-admin', 'change-bridge-mode', 'halt', 'remove-bridge', 'restart-bot', 'restart-bridge', 'stop-bridge'] +admin_commands = ['add-bridge', 'add-xmpp-admin', 'change-bridge-mode', 'debug', 'halt', 'remove-bridge', 'restart-bot', 'restart-bridge', 'stop-bridge'] def execute(bot, command_line, bot_admin, bridge): ret = '' @@ -157,6 +157,28 @@ def connections(bot, command, args_array return irc_connections(bot, 'irc-connections', args_array, bot_admin, bridge)+'\n'+xmpp_connections(bot, 'xmpp-connections', args_array, bot_admin, bridge) +def debug(bot, command, args_array, bot_admin, bridge): + parser = ArgumentParser(prog=command) + parser.add_argument('mode', choices=['on', 'off']) + try: + args = parser.parse_args(args_array) + except ArgumentParser.ParseException as e: + if len(args_array) == 0: + if bot.debug: + return 'Debugging is on' + else: + return 'Debugging is off' + else: + return '\n'+e.args[1] + + if args.mode == 'on': + bot.debug = True + return 'Debugging is now on' + else: + bot.debug = False + return 'Debugging is now off' + + def halt(bot, command, args_array, bot_admin, bridge): bot.stop() return