diff --git a/README.md b/README.md index 8680a76f..4836af52 100644 --- a/README.md +++ b/README.md @@ -299,6 +299,11 @@ PS: **ARM平台** 请使用全量版 同时 **如果你的机器 RAM < 1G 可能 ## 更新 +### 2022/12/31 + +* 修复epic报错,优化简介 [@pull/1226](https://github.com/HibiKier/zhenxun_bot/pull/1226) +* 修复词条在某些回答下出错 + ### 2022/12/27 \[v0.1.6.6] * 添加权限检查依赖注入 diff --git a/basic_plugins/hooks/_utils.py b/basic_plugins/hooks/_utils.py index 0219b6be..a5ded1e5 100644 --- a/basic_plugins/hooks/_utils.py +++ b/basic_plugins/hooks/_utils.py @@ -144,7 +144,7 @@ class AuthChecker: try: plugin_name = matcher.plugin_name cost_gold = await self.auth_cost(plugin_name, bot, event) - if str(event.user_id) not in bot.config.superusers: + if hasattr(event, "user_id") and str(event.user_id) not in bot.config.superusers: await self.auth_basic(plugin_name, bot, event) self.auth_group(plugin_name, bot, event) await self.auth_admin(plugin_name, matcher, bot, event) diff --git a/basic_plugins/init_plugin_config/init_plugins_settings.py b/basic_plugins/init_plugin_config/init_plugins_settings.py index aecb185b..ef47798b 100755 --- a/basic_plugins/init_plugin_config/init_plugins_settings.py +++ b/basic_plugins/init_plugin_config/init_plugins_settings.py @@ -9,13 +9,13 @@ def init_plugins_settings(): """ 初始化插件设置,从插件中获取 __zx_plugin_name__,__plugin_cmd__,__plugin_settings__ """ - for x in plugins2settings_manager.keys(): - try: - _plugin = nonebot.plugin.get_plugin(x) - _module = _plugin.module - _module.__getattribute__("__zx_plugin_name__") - except (KeyError, AttributeError) as e: - logger.warning(f"配置文件 模块:{x} 获取 plugin_name 失败...{e}") + # for x in plugins2settings_manager.keys(): + # try: + # _plugin = nonebot.plugin.get_plugin(x) + # _module = _plugin.module + # _module.__getattribute__("__zx_plugin_name__") + # except (KeyError, AttributeError) as e: + # logger.warning(f"配置文件 模块:{x} 获取 plugin_name 失败...{e}") for matcher in get_matchers(True): try: if matcher.plugin_name not in plugins2settings_manager.keys(): diff --git a/plugins/word_bank/_model.py b/plugins/word_bank/_model.py index 223dd337..12475f45 100644 --- a/plugins/word_bank/_model.py +++ b/plugins/word_bank/_model.py @@ -194,8 +194,8 @@ class WordBank(db.Model): & (cls.answer == answer) ).gino.first() if query and query.placeholder: - type_list = re.findall(rf"\[(.*):placeholder_.*]", answer) - temp_answer = re.sub(rf"\[(.*):placeholder_.*]", "{}", answer) + type_list = re.findall(rf"\[(.*?):placeholder_.*?]", answer) + temp_answer = re.sub(rf"\[(.*?):placeholder_.*?]", "{}", answer) seg_list = [] for t, p in zip(type_list, query.placeholder.split(",")): if t == "image": @@ -207,7 +207,6 @@ class WordBank(db.Model): return MessageTemplate(temp_answer, Message).format(*seg_list) return answer - @classmethod async def check( cls, diff --git a/utils/image_utils.py b/utils/image_utils.py index d819cc17..4f48d684 100755 --- a/utils/image_utils.py +++ b/utils/image_utils.py @@ -192,7 +192,7 @@ class BuildImage: if plain_text: if not color: color = (255, 255, 255, 0) - ttf_w, ttf_h = self.getsize(plain_text) + ttf_w, ttf_h = self.getsize(str(plain_text)) self.w = self.w if self.w > ttf_w else ttf_w self.h = self.h if self.h > ttf_h else ttf_h self.markImg = Image.new(image_mode, (self.w, self.h), color) @@ -229,7 +229,7 @@ class BuildImage: self.size = self.w, self.h if plain_text: fill = font_color if font_color else (0, 0, 0) - self.text((0, 0), plain_text, fill) + self.text((0, 0), str(plain_text), fill) try: self.loop = asyncio.get_event_loop() except RuntimeError: