Skip to content

Instantly share code, notes, and snippets.

@JuanPotato
Created June 3, 2015 20:57
Show Gist options
  • Save JuanPotato/4966ca69677df7bdbf3c to your computer and use it in GitHub Desktop.
Save JuanPotato/4966ca69677df7bdbf3c to your computer and use it in GitHub Desktop.
def loadPlugins():
pluginFiles = ["plugins/" + f for f in listdir(curPath + "\plugins") if re.search('^.+\.py$', f)]
global plugins
plugins = []
for file in pluginFiles:
values = {}
execfile(file, values)
plugin = values['plugin'] # get the variable "plugin"
print "Initializing plugin:", plugin['name']
plugins.append(plugin)
#to get the function call plugin["function"]()
def function():
return "1 + 1 = 2"
plugin = {
'name': "My calc",
'patterns': ["^/calc (.+)$"],
'function': function,
'elevated': False,
'usage' : "/calc <exp>",
'desc' : "calculator"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment