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