mirror of
http://aero2k.de/t/repos/urlbot-native.git
synced 2017-09-06 15:25:38 +02:00
implement enable/disable for ptypes_PARSE plugins
This commit is contained in:
35
plugins.py
35
plugins.py
@@ -201,6 +201,9 @@ def data_parse_other(msg_obj):
|
|||||||
if ratelimit_exceeded(p.ratelimit_class):
|
if ratelimit_exceeded(p.ratelimit_class):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if not p.is_enabled:
|
||||||
|
continue
|
||||||
|
|
||||||
ret = p(reply_user=reply_user, data=data)
|
ret = p(reply_user=reply_user, data=data)
|
||||||
|
|
||||||
if None != ret:
|
if None != ret:
|
||||||
@@ -220,19 +223,21 @@ def command_help(argv, **args):
|
|||||||
logger('plugin', 'empty help request, sent all commands')
|
logger('plugin', 'empty help request, sent all commands')
|
||||||
commands = args['cmd_list']
|
commands = args['cmd_list']
|
||||||
commands.sort()
|
commands.sort()
|
||||||
|
parsers = args['parser_list']
|
||||||
|
parsers.sort()
|
||||||
return {
|
return {
|
||||||
'msg': args['reply_user'] + ': known commands: ' +
|
'msg': [
|
||||||
str(commands).strip('[]')
|
'%s: known commands: %s' % (
|
||||||
}
|
args['reply_user'], str(commands).strip('[]')
|
||||||
|
),
|
||||||
if not what in [p.plugin_name for p in plugins[ptypes_COMMAND]]:
|
'known parsers: %s' % str(parsers).strip('[]')
|
||||||
logger('plugin', 'no help found for %s' % what)
|
]
|
||||||
return {
|
|
||||||
'msg': args['reply_user'] + ': no such command: %s' % what
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flag = False
|
||||||
for p in plugins[ptypes_COMMAND]:
|
for p in plugins[ptypes_COMMAND]:
|
||||||
if what == p.plugin_name:
|
if what == p.plugin_name:
|
||||||
|
flag = True
|
||||||
logger('plugin', 'sent help for %s' % what)
|
logger('plugin', 'sent help for %s' % what)
|
||||||
return {
|
return {
|
||||||
'msg': args['reply_user'] + ': help for %s: %s' % (
|
'msg': args['reply_user'] + ': help for %s: %s' % (
|
||||||
@@ -240,6 +245,13 @@ def command_help(argv, **args):
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if not flag:
|
||||||
|
logger('plugin', 'no help found for %s' % what)
|
||||||
|
return {
|
||||||
|
'msg': args['reply_user'] + ': no such command: %s' % what
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@pluginfunction('version', 'prints version', ptypes_COMMAND)
|
@pluginfunction('version', 'prints version', ptypes_COMMAND)
|
||||||
def command_version(argv, **args):
|
def command_version(argv, **args):
|
||||||
if 'version' != argv[0]:
|
if 'version' != argv[0]:
|
||||||
@@ -606,9 +618,9 @@ def command_plugin_activation(argv, **args):
|
|||||||
'msg': args['reply_user'] + ': not allowed'
|
'msg': args['reply_user'] + ': not allowed'
|
||||||
}
|
}
|
||||||
|
|
||||||
for c in plugins[ptypes_COMMAND]:
|
for p in plugins[ptypes_COMMAND] + plugins[ptypes_PARSE]:
|
||||||
if c.plugin_name == plugin:
|
if p.plugin_name == plugin:
|
||||||
c.is_enabled = 'enable' == command
|
p.is_enabled = 'enable' == command
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'msg': args['reply_user'] + ': %sd %s' % (
|
'msg': args['reply_user'] + ': %sd %s' % (
|
||||||
@@ -750,6 +762,7 @@ def data_parse_commands(msg_obj):
|
|||||||
ret = p(
|
ret = p(
|
||||||
data = data,
|
data = data,
|
||||||
cmd_list = [pl.plugin_name for pl in plugins[ptypes_COMMAND]],
|
cmd_list = [pl.plugin_name for pl in plugins[ptypes_COMMAND]],
|
||||||
|
parser_list = [pl.plugin_name for pl in plugins[ptypes_PARSE]],
|
||||||
reply_user = reply_user,
|
reply_user = reply_user,
|
||||||
msg_obj = msg_obj,
|
msg_obj = msg_obj,
|
||||||
argv = words[1:]
|
argv = words[1:]
|
||||||
|
|||||||
Reference in New Issue
Block a user