diff --git a/README.md b/README.md index 9e84e754..e7d36bc7 100644 --- a/README.md +++ b/README.md @@ -331,11 +331,16 @@ PS: **ARM平台** 请使用全量版 同时 **如果你的机器 RAM < 1G 可能 ## 更新 -### 2022/2/19 +### 2023/2/20 + +* chat_history部分字段调整为可null [@pull/1270](https://github.com/HibiKier/zhenxun_bot/pull/1270) + +### 2023/2/19 * 修正了`重载插件`的帮助提示 +* 修改BUG -### 2022/2/18 +### 2023/2/18 * 数据库舍弃`gino`使用`tortoise` * 昵称提供命令`全局昵称设置` @@ -344,11 +349,11 @@ PS: **ARM平台** 请使用全量版 同时 **如果你的机器 RAM < 1G 可能 * 解决开红包经常误触的问题,有红包和未领取的时候才会触发“开”命令 [@pull/1257](https://github.com/HibiKier/zhenxun_bot/pull/1257) * 细节优化,原神今日素材重写 [@pull/1258](https://github.com/HibiKier/zhenxun_bot/pull/1258) -### 2022/1/31 +### 2023/1/31 * 修复B站转发卡片BUG [@pull/1249](https://github.com/HibiKier/zhenxun_bot/pull/1249) -### 2022/1/27 +### 2023/1/27 * 替换pixiv反向代理地址 [@pull/1244](https://github.com/HibiKier/zhenxun_bot/pull/1244) diff --git a/basic_plugins/admin_bot_manage/_data_source.py b/basic_plugins/admin_bot_manage/_data_source.py index e4c7dff4..8f6cb6ee 100644 --- a/basic_plugins/admin_bot_manage/_data_source.py +++ b/basic_plugins/admin_bot_manage/_data_source.py @@ -315,9 +315,9 @@ async def update_member_info(group_id: int, remind_superuser: bool = False) -> b ) if str(user_info["user_id"]) in bot.config.superusers: await LevelUser.set_level(user_info["user_id"], user_info["group_id"], 9) - user = await GroupInfoUser.filter( + user = await GroupInfoUser.get_or_none( user_qq=user_info["user_id"], group_id=user_info["group_id"] - ).first() + ) if user: if user.user_name != nickname: user.user_name=nickname diff --git a/models/chat_history.py b/models/chat_history.py index 9816fa5b..0cd015ae 100644 --- a/models/chat_history.py +++ b/models/chat_history.py @@ -50,7 +50,7 @@ class ChatHistory(Model): .group_by("user_qq") .limit(limit) .values_list("user_qq", "count") - ) + ) # type: ignore @classmethod async def get_group_first_msg_datetime(cls, group_id: int) -> Optional[datetime]: @@ -103,4 +103,13 @@ class ChatHistory(Model): ) elif isinstance(days, tuple): query = query.filter(create_at__range=days) - return await query.all() + return await query.all() # type: ignore + + @classmethod + async def _run_script(cls): + await cls.raw("alter table chat_history alter group_id drop not null;") + """允许 group_id 为空""" + await cls.raw("alter table chat_history alter text drop not null;") + """允许 text 为空""" + await cls.raw("alter table chat_history alter plain_text drop not null;") + """允许 plain_text 为空"""