add is_enabled flag; 'plugin enable' works
This commit is contained in:
41
plugins.py
41
plugins.py
@@ -140,6 +140,7 @@ def command_command(args):
|
|||||||
'name': 'command',
|
'name': 'command',
|
||||||
'desc': 'lists commands',
|
'desc': 'lists commands',
|
||||||
'args': ('argv0', 'reply_user', 'cmd_list'),
|
'args': ('argv0', 'reply_user', 'cmd_list'),
|
||||||
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_GLOBAL
|
'ratelimit_class': RATE_GLOBAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,6 +158,7 @@ def command_help(args):
|
|||||||
'name': 'help',
|
'name': 'help',
|
||||||
'desc': 'print help for a command',
|
'desc': 'print help for a command',
|
||||||
'args': ('argv0', 'argv1', 'reply_user', 'cmd_list'),
|
'args': ('argv0', 'argv1', 'reply_user', 'cmd_list'),
|
||||||
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_GLOBAL
|
'ratelimit_class': RATE_GLOBAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,6 +190,7 @@ def command_version(args):
|
|||||||
'name': 'version',
|
'name': 'version',
|
||||||
'desc': 'prints version',
|
'desc': 'prints version',
|
||||||
'args': ('argv0', 'reply_user'),
|
'args': ('argv0', 'reply_user'),
|
||||||
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_GLOBAL
|
'ratelimit_class': RATE_GLOBAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,6 +208,7 @@ def command_klammer(args):
|
|||||||
'name': 'klammer',
|
'name': 'klammer',
|
||||||
'desc': 'prints an anoying paper clip aka. Karl Klammer',
|
'desc': 'prints an anoying paper clip aka. Karl Klammer',
|
||||||
'args': ('argv0', 'reply_user'),
|
'args': ('argv0', 'reply_user'),
|
||||||
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_GLOBAL
|
'ratelimit_class': RATE_GLOBAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,6 +234,7 @@ def command_unicode(args):
|
|||||||
'name': 'unikot',
|
'name': 'unikot',
|
||||||
'desc': 'prints an unicode string',
|
'desc': 'prints an unicode string',
|
||||||
'args': ('argv0', 'reply_user'),
|
'args': ('argv0', 'reply_user'),
|
||||||
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_GLOBAL
|
'ratelimit_class': RATE_GLOBAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,6 +257,7 @@ def command_source(args):
|
|||||||
'name': 'source',
|
'name': 'source',
|
||||||
'desc': 'prints git URL',
|
'desc': 'prints git URL',
|
||||||
'args': ('argv0', 'reply_user'),
|
'args': ('argv0', 'reply_user'),
|
||||||
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_GLOBAL
|
'ratelimit_class': RATE_GLOBAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,6 +275,7 @@ def command_dice(args):
|
|||||||
'name': 'dice',
|
'name': 'dice',
|
||||||
'desc': 'rolls a dice, optional N times',
|
'desc': 'rolls a dice, optional N times',
|
||||||
'args': ('argv0', 'argv1', 'reply_user'),
|
'args': ('argv0', 'argv1', 'reply_user'),
|
||||||
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_INTERACTIVE
|
'ratelimit_class': RATE_INTERACTIVE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,6 +325,7 @@ def command_uptime(args):
|
|||||||
'name': 'uptime',
|
'name': 'uptime',
|
||||||
'desc': 'prints uptime',
|
'desc': 'prints uptime',
|
||||||
'args': ('argv0', 'reply_user'),
|
'args': ('argv0', 'reply_user'),
|
||||||
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_GLOBAL
|
'ratelimit_class': RATE_GLOBAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,6 +352,7 @@ def command_ping(args):
|
|||||||
'name': 'ping',
|
'name': 'ping',
|
||||||
'desc': 'sends pong',
|
'desc': 'sends pong',
|
||||||
'args': ('argv0', 'reply_user'),
|
'args': ('argv0', 'reply_user'),
|
||||||
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_INTERACTIVE
|
'ratelimit_class': RATE_INTERACTIVE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,6 +380,7 @@ def command_info(args):
|
|||||||
'name': 'info',
|
'name': 'info',
|
||||||
'desc': 'prints info message',
|
'desc': 'prints info message',
|
||||||
'args': ('argv0', 'reply_user'),
|
'args': ('argv0', 'reply_user'),
|
||||||
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_GLOBAL
|
'ratelimit_class': RATE_GLOBAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,6 +398,7 @@ def command_teatimer(args):
|
|||||||
'name': 'teatimer',
|
'name': 'teatimer',
|
||||||
'desc': 'sets a tea timer to $1 or currently %d seconds' % conf('tea_steep_time'),
|
'desc': 'sets a tea timer to $1 or currently %d seconds' % conf('tea_steep_time'),
|
||||||
'args': ('reply_user', 'msg_obj', 'argv0', 'argv1'),
|
'args': ('reply_user', 'msg_obj', 'argv0', 'argv1'),
|
||||||
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_GLOBAL
|
'ratelimit_class': RATE_GLOBAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,6 +442,7 @@ def command_decode(args):
|
|||||||
'name': 'decode',
|
'name': 'decode',
|
||||||
'desc': 'prints the long description of an unicode character',
|
'desc': 'prints the long description of an unicode character',
|
||||||
'args': ('argv0', 'argv1', 'reply_user'),
|
'args': ('argv0', 'argv1', 'reply_user'),
|
||||||
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_GLOBAL
|
'ratelimit_class': RATE_GLOBAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,6 +476,7 @@ def command_show_blacklist(args):
|
|||||||
'name': 'show-blacklist',
|
'name': 'show-blacklist',
|
||||||
'desc': 'show the current URL blacklist, optionally filtered',
|
'desc': 'show the current URL blacklist, optionally filtered',
|
||||||
'args': ('argv0', 'reply_user', 'argv1'),
|
'args': ('argv0', 'reply_user', 'argv1'),
|
||||||
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_GLOBAL
|
'ratelimit_class': RATE_GLOBAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,6 +521,7 @@ def command_usersetting(args):
|
|||||||
'name': 'set',
|
'name': 'set',
|
||||||
'desc': 'modify a user setting',
|
'desc': 'modify a user setting',
|
||||||
'args': ('reply_user', 'argv0', 'argv1', 'argv2', 'msg_obj'),
|
'args': ('reply_user', 'argv0', 'argv1', 'argv2', 'msg_obj'),
|
||||||
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_GLOBAL
|
'ratelimit_class': RATE_GLOBAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,6 +574,7 @@ def command_cake(args):
|
|||||||
'name': 'cake',
|
'name': 'cake',
|
||||||
'desc': 'displays a cake ASCII art',
|
'desc': 'displays a cake ASCII art',
|
||||||
'args': ('argv0', 'reply_user'),
|
'args': ('argv0', 'reply_user'),
|
||||||
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_GLOBAL
|
'ratelimit_class': RATE_GLOBAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,6 +591,7 @@ def command_remember(args):
|
|||||||
'name': 'remember',
|
'name': 'remember',
|
||||||
'desc': 'remembers something',
|
'desc': 'remembers something',
|
||||||
'args': ('argv0', 'argv1', 'data', 'reply_user'),
|
'args': ('argv0', 'argv1', 'data', 'reply_user'),
|
||||||
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_GLOBAL
|
'ratelimit_class': RATE_GLOBAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -603,6 +619,7 @@ def command_recall(args):
|
|||||||
'name': 'recall',
|
'name': 'recall',
|
||||||
'desc': "recalls something previously 'remember'ed",
|
'desc': "recalls something previously 'remember'ed",
|
||||||
'args': ('argv0', 'reply_user'),
|
'args': ('argv0', 'reply_user'),
|
||||||
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_GLOBAL
|
'ratelimit_class': RATE_GLOBAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,6 +638,7 @@ def command_plugin_activation(args):
|
|||||||
'name': 'plugin',
|
'name': 'plugin',
|
||||||
'desc': 'disables or re-enables plugins',
|
'desc': 'disables or re-enables plugins',
|
||||||
'args': ('argv0', 'argv1', 'argv2', 'reply_user'),
|
'args': ('argv0', 'argv1', 'argv2', 'reply_user'),
|
||||||
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_GLOBAL
|
'ratelimit_class': RATE_GLOBAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -634,8 +652,8 @@ def command_plugin_activation(args):
|
|||||||
|
|
||||||
if None == command or 'list' == command:
|
if None == command or 'list' == command:
|
||||||
return {
|
return {
|
||||||
'msg': [args['reply_user'] + ': known plugins:'] +
|
'msg': args['reply_user'] + ': known plugins: ' +
|
||||||
[c['name'] for c in plugins['command']]
|
str([c['name'] for c in plugins['command']])[1:-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
if None == plugin:
|
if None == plugin:
|
||||||
@@ -643,19 +661,16 @@ def command_plugin_activation(args):
|
|||||||
'msg': args['reply_user'] + ': no plugin given'
|
'msg': args['reply_user'] + ': no plugin given'
|
||||||
}
|
}
|
||||||
|
|
||||||
if 'enable' == command:
|
if 'enable' == command or 'disable' == command:
|
||||||
return {
|
|
||||||
'msg': args['reply_user'] + ': enable not implemented yet'
|
|
||||||
}
|
|
||||||
|
|
||||||
if 'disable' == command:
|
|
||||||
for i, c in enumerate(plugins['command']):
|
for i, c in enumerate(plugins['command']):
|
||||||
if c['name'] == plugin:
|
if c['name'] == plugin:
|
||||||
del(plugins['command'][i])
|
plugins['command'][i]['is_enabled'] = \
|
||||||
|
True if 'enable' == command else False
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'msg': args['reply_user'] + ': disabled %s' %
|
'msg': args['reply_user'] + ': %sd %s' %(
|
||||||
plugin
|
command, plugin
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -672,6 +687,7 @@ def command_plugin_activation(args):
|
|||||||
# 'name': 'dummy',
|
# 'name': 'dummy',
|
||||||
# 'desc': 'dummy description',
|
# 'desc': 'dummy description',
|
||||||
# 'args': ('argv0', 'reply_user'),
|
# 'args': ('argv0', 'reply_user'),
|
||||||
|
# 'is_enabled': True,
|
||||||
# 'ratelimit_class': RATE_GLOBAL
|
# 'ratelimit_class': RATE_GLOBAL
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
@@ -719,6 +735,9 @@ def data_parse_commands(msg_obj):
|
|||||||
if ratelimit_exceeded(p['ratelimit_class']):
|
if ratelimit_exceeded(p['ratelimit_class']):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if not p['is_enabled']:
|
||||||
|
continue
|
||||||
|
|
||||||
args = {}
|
args = {}
|
||||||
|
|
||||||
if 'args' in list(p.keys()):
|
if 'args' in list(p.keys()):
|
||||||
|
|||||||
Reference in New Issue
Block a user