@Command(value = "\\.unload(\\??) (" + MODULE_REGEX + ")", allowPM = false) public void unloadModules(CommandContext ctx, String qm, String moduleNames) { final boolean showErrors = qm.isEmpty(); for (String moduleName : moduleNames.split(" ")) { // Don't allow unloading Core if (moduleName.equals(this.getClass().getSimpleName())) { this.bot.sendNoticeTo( ctx.getResponseTarget(), "#error .unload cannot unload the %(#module)s module", this.getFriendlyName()); continue; } try { this.bot.unloadModule(moduleName, false); try { this.bot.saveModules(); } catch (ModuleSaveException e) { Log.e(e); } this.bot.sendNoticeTo(ctx.getResponseTarget(), "Module %(#module)s unloaded", moduleName); } catch (ModuleUnloadException e) { Log.e(e); if (showErrors) { this.bot.sendNoticeTo(ctx.getResponseTarget(), "#error %s", e.getMessage()); } } } }
@Command(value = "\\.load(\\??) (" + MODULE_REGEX + ")", allowPM = false) public void loadModules(CommandContext ctx, String qm, String moduleNames) { final boolean showErrors = qm.isEmpty(); for (String moduleName : moduleNames.split(" ")) { try { this.bot.loadModule(moduleName); try { this.bot.saveModules(); } catch (ModuleSaveException e) { Log.e(e); } this.bot.sendNoticeTo(ctx.getResponseTarget(), "Module %(#module)s loaded", moduleName); } catch (ModuleInitException e) { Log.e(e); if (showErrors) { this.bot.sendNoticeTo(ctx.getResponseTarget(), "#error %s", e.getMessage()); } } } }