From 21f87ac8ac6db9121a09cba5a85e44c6a5555caa Mon Sep 17 00:00:00 2001 From: urlbot Date: Sat, 3 Jan 2015 18:59:44 +0100 Subject: [PATCH] mv 'enable'|'disable' to own commands --- plugins.py | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/plugins.py b/plugins.py index bbb1512..0c3f99c 100644 --- a/plugins.py +++ b/plugins.py @@ -636,26 +636,20 @@ def command_plugin_activation(args): if 'register' == args: return { 'name': 'plugin', - 'desc': 'disables or re-enables plugins', - 'args': ('argv0', 'argv1', 'argv2', 'reply_user'), + 'desc': "'disable' or 'enable' plugins", + 'args': ('argv0', 'argv1', 'reply_user'), 'is_enabled': True, 'ratelimit_class': RATE_GLOBAL } - if 'plugin' != args['argv0']: + command = args['argv0'] + plugin = args['argv1'] + + if not command in ('enable', 'disable'): return - command = args['argv1'] - plugin = args['argv2'] - logger('plugin', 'plugin activation plugin called') - if command in (None, 'list'): - return { - 'msg': args['reply_user'] + ': known plugins: ' + - str([c['name'] for c in plugins['command']])[1:-1] - } - if None == plugin: return { 'msg': args['reply_user'] + ': no plugin given' @@ -665,24 +659,19 @@ def command_plugin_activation(args): 'msg': args['reply_user'] + ': not allowed' } - if command in ('enable', 'disable'): - for i, c in enumerate(plugins['command']): - if c['name'] == plugin: - plugins['command'][i]['is_enabled'] = \ - True if 'enable' == command else False + for i, c in enumerate(plugins['command']): + if c['name'] == plugin: + plugins['command'][i]['is_enabled'] = \ + True if 'enable' == command else False - return { - 'msg': args['reply_user'] + ': %sd %s' %( - command, plugin - ) - } - - return { - 'msg': args['reply_user'] + ': unknown plugin %s' % plugin - } + return { + 'msg': args['reply_user'] + ': %sd %s' %( + command, plugin + ) + } return { - 'msg': args['reply_user'] + ': dummy plugin called' + 'msg': args['reply_user'] + ': unknown plugin %s' % plugin } #def command_dummy(args):