1
0
mirror of http://aero2k.de/t/repos/urlbot-native.git synced 2017-09-06 15:25:38 +02:00

refactor plugins

This commit is contained in:
Thorsten S
2015-12-26 13:50:21 +01:00
parent bd12a4caf7
commit 12d9222ddf
6 changed files with 495 additions and 479 deletions

View File

@@ -205,3 +205,31 @@ def giphy(subject, api_key):
except:
pass
return giphy_url
def pluginfunction(name, desc, plugin_type, ratelimit_class=RATE_GLOBAL, enabled=True):
"""A decorator to make a plugin out of a function
:param enabled:
:param ratelimit_class:
:param plugin_type:
:param desc:
:param name:
"""
if plugin_type not in ptypes:
raise TypeError('Illegal plugin_type: %s' % plugin_type)
def decorate(f):
f.is_plugin = True
f.is_enabled = enabled
f.plugin_name = name
f.plugin_desc = desc
f.plugin_type = plugin_type
f.ratelimit_class = ratelimit_class
return f
return decorate
ptypes_PARSE = 'parser'
ptypes_COMMAND = 'command'
ptypes = [ptypes_PARSE, ptypes_COMMAND]