@@ -63,6 +63,11 @@ ADMIN_COMMANDS = { | |||
"args": ["插件名", "优先级"], | |||
"desc": "设置指定插件的优先级,越大越优先", | |||
}, | |||
"reloadp": { | |||
"alias": ["reloadp", "重载插件"], | |||
"args": ["插件名"], | |||
"desc": "重载指定插件配置", | |||
}, | |||
"enablep": { | |||
"alias": ["enablep", "启用插件"], | |||
"args": ["插件名"], | |||
@@ -216,6 +221,15 @@ class Godcmd(Plugin): | |||
result = "插件" + args[0] + "优先级已设置为" + args[1] | |||
else: | |||
result = "插件不存在" | |||
elif cmd == "reloadp": | |||
if len(args) != 1: | |||
ok, result = False, "请提供插件名" | |||
else: | |||
ok = PluginManager().reload_plugin(args[0]) | |||
if ok: | |||
result = "插件配置已重载" | |||
else: | |||
result = "插件不存在" | |||
elif cmd == "enablep": | |||
if len(args) != 1: | |||
ok, result = False, "请提供插件名" | |||
@@ -96,6 +96,16 @@ class PluginManager: | |||
self.listening_plugins[event].append(name) | |||
self.refresh_order() | |||
def reload_plugin(self, name): | |||
if name in self.instances: | |||
for event in self.listening_plugins: | |||
if name in self.listening_plugins[event]: | |||
self.listening_plugins[event].remove(name) | |||
del self.instances[name] | |||
self.activate_plugins() | |||
return True | |||
return False | |||
def load_plugins(self): | |||
self.load_config() | |||
self.scan_plugins() | |||
@@ -78,7 +78,7 @@ class SDWebUI(Plugin): | |||
options = {**self.default_options, **rule_options} | |||
params["prompt"] = params.get("prompt", "")+f", {prompt}" | |||
if len(options) > 0: | |||
logger.info("[SD] cover rule_options={}".format(rule_options)) | |||
logger.info("[SD] cover options={}".format(options)) | |||
self.api.set_options(options) | |||
logger.info("[SD] params={}".format(params)) | |||
result = self.api.txt2img( | |||