def load(self, context, args): context.exceptrights('admin') plugin = args.getstr("plugin") if plugin in self.server.plugins: return "That plugin is already loaded." try: if not self.server.loadplugin(plugin): return "Cannot load plugin: %s" % plugin except bot.ModuleError as e: return str(e) if not args.getbool('temp'): plist = self.server.settings.get("server.autoload") tod = [] nl = self.server.settings.get("server.noautoload") for n in nl: for p in [plugin, plugin.split('/')[0]] + [ (plugin.split('/')[0] + '/' + x) for x in bot.newmodules ]: if n == p or n == p.split('/')[0]: if n not in tod: tod.append(n) for n in tod: nl.pop(nl.index(n)) self.server.settings.set("server.noautoload", nl) if not self.willautoload(plugin, True): plist.append(plugin) self.server.settings.set("server.autoload", plist) ynstr = utils.ynstr(self.willautoload(plugin), "will", "won't") return "Loaded plugin: %s (%s autoload)" % (plugin, ynstr)
def setnick(self, context, args): context.exceptrights(["admin"]) args.default('nick', self.server.settings.get('server.user.nick')) if args.getstr('nick') == self.server.nick: return "%s is already the nick." % self.server.nick self.server.wantnick = args.getstr('nick') self.server.setnick(self.server.wantnick) ret = "Set nick to %s ({w} set at login)." % (args.getstr('nick')) self.npending = (lambda server: context.reply(ret.format(w=( utils.ynstr(args.getstr('nick') == server.settings.get("server.user.nick"), "will", "won't") ))), lambda: context.reply( "Cannot set nick to %s" % args.getstr('nick')), args.getstr('nick') if not args.getbool('temp') else '')
def unload(self, context, args): context.exceptrights('admin') plugin = args.getstr("plugin") module = "" if len(plugin.split('/')) > 1: module = plugin.split('/')[-1] if plugin in self.server.protected: return "You cannot unload the core plugins." plugin = plugin.split('/')[0] if pms(plugin, module) in self.server.protected: return "You cannot unload the core plugins." if plugin not in self.server.plugins: return "That plugin is not loaded." if module and module not in self.server.plugins[plugin]: return "That module is not loaded." plist = self.server.settings.get("server.autoload") aname = "" for p in plist: bplugin = p.split('/')[0] bmodule = "" if len(p.split('/')) > 1: bmodule = p.split('/')[-1] if plugin == bplugin and module == bmodule: aname = p if not args.getbool('temp') and p: plist.pop(plist.index(p)) break aname = aname or pms(plugin, module) self.server.settings.set("server.autoload", plist) self.server.unloadplugin(pms(plugin, module)) nl = self.server.settings.get("server.noautoload") cname = aname if len(cname.split('/')) > 1: cname = cname.split('/')[0] + '/' + cname.split('/')[-1] if cname not in nl and cname.split('/')[0] not in nl: nl.append(cname) self.server.settings.set("server.noautoload", nl) ynstr = utils.ynstr(self.willautoload(aname), "will", "won't") return "Unloaded plugin: %s (%s autoload)" % (aname, ynstr)
def ynchannelauto(self, channel): return utils.ynstr(channel in self.server.settings.get("server.channels"), "will", "won't")