|
@@ -24,18 +24,17 @@ class Banwords(Plugin):
|
|
|
def __init__(self):
|
|
def __init__(self):
|
|
|
super().__init__()
|
|
super().__init__()
|
|
|
try:
|
|
try:
|
|
|
- curdir = os.path.dirname(__file__)
|
|
|
|
|
- config_path = os.path.join(curdir, "config.json")
|
|
|
|
|
- # loading config from global plugin config
|
|
|
|
|
|
|
+ # load config
|
|
|
conf = super().load_config()
|
|
conf = super().load_config()
|
|
|
|
|
+ curdir = os.path.dirname(__file__)
|
|
|
if not conf:
|
|
if not conf:
|
|
|
|
|
+ # 配置不存在则写入默认配置
|
|
|
|
|
+ config_path = os.path.join(curdir, "config.json")
|
|
|
if not os.path.exists(config_path):
|
|
if not os.path.exists(config_path):
|
|
|
conf = {"action": "ignore"}
|
|
conf = {"action": "ignore"}
|
|
|
with open(config_path, "w") as f:
|
|
with open(config_path, "w") as f:
|
|
|
json.dump(conf, f, indent=4)
|
|
json.dump(conf, f, indent=4)
|
|
|
- else:
|
|
|
|
|
- with open(config_path, "r") as f:
|
|
|
|
|
- conf = super().load_config() or json.load(f)
|
|
|
|
|
|
|
+
|
|
|
self.searchr = WordsSearch()
|
|
self.searchr = WordsSearch()
|
|
|
self.action = conf["action"]
|
|
self.action = conf["action"]
|
|
|
banwords_path = os.path.join(curdir, "banwords.txt")
|
|
banwords_path = os.path.join(curdir, "banwords.txt")
|