import cat
db = DBConnection()
-plugins = Plugins()
token_file = 'TOKEN'
if len(sys.argv) > 1:
bot.log = log
bot.db = db
log.setLevel(logging.DEBUG if bot.get('debug') else logging.INFO)
-plugins.log_level(log.level)
+plugins = Plugins(log.level)
idletime = multiprocessing.Value('i', 900)
threads_ready = multiprocessing.Value('b', False)
@asyncio.coroutine
def builtin_commands(message, command, raw):
if command == 'plugins':
+ args = shlex.split(raw)
+ if len(args) > 1:
+ if args[1] == 'reload':
+ plugins.refresh()
+ return True
+ return False
all_plugins = list(plugins.plugins())
if len(all_plugins):
lines = []
exclusive = 4
class Plugins(object):
- def __init__(self):
+ def __init__(self, level):
self.loaded = {}
+ self.log_level(level)
self.refresh()
+ self.log_level(level)
def refresh(self):
for py in glob.glob('plugin/*/*.py'):
self.loaded[name] = { 'module': module, 'plugin': getattr(module, plugin)() }
except:
log.exception('refresh')
+ log.info('Loaded plugins: {}'.format(', '.join(self.plugins())))
def plugins(self):
return self.loaded.keys()
log.debug("Plugin {} doesn't handle help for {} command.".format(name, command))
continue
result = yield from self.call_coroutine(name, 'handle_help', message, command, *args)
+ if result is not None:
+ if not result or result is not PluginCommand.exclusive:
+ continue
return True
return False