mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-21 20:20:05 +08:00
bugfix:修复notice事件扩散问题 (#2132)
* bugfix:修复notice事件扩散问题 * 优化并发调度 * bugfix:修复签到样式 * bugfix:功能调用统计修复 * bugfix:修复私聊时功能调用统计显示已退群问题 * 提高插件适配兼容性 * 优化发送队列 * 修改权限检查设计 * 继续修改权限检查设计 * 完善权限检查设计 * 优化sqlite配置 * 优化数据库初始化 * 代码整理,无用代码清理 * bugfix:修复启动时数据库校验问题 * bugfix:修复预算裁剪过于激进问题
This commit is contained in:
@@ -2,8 +2,8 @@ from typing import ClassVar
|
||||
|
||||
from tortoise import fields
|
||||
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.services.db_context import Model
|
||||
from zhenxun.services.db_context.schema_ops import AlterColumnType, DropColumn
|
||||
|
||||
|
||||
class GroupInfoUser(Model):
|
||||
@@ -35,9 +35,9 @@ class GroupInfoUser(Model):
|
||||
参数:
|
||||
group_id: 群号
|
||||
"""
|
||||
return set(
|
||||
await cls.filter(group_id=group_id).values_list("user_id", flat=True)
|
||||
) # type: ignore
|
||||
from zhenxun.services.hot_query_cache import get_group_user_ids
|
||||
|
||||
return await get_group_user_ids(group_id)
|
||||
|
||||
@classmethod
|
||||
async def get_user_all_group(cls, user_id: str) -> list[str]:
|
||||
@@ -46,60 +46,24 @@ class GroupInfoUser(Model):
|
||||
参数:
|
||||
user_id: 用户id
|
||||
"""
|
||||
return list(
|
||||
await cls.filter(user_id=user_id).values_list("group_id", flat=True)
|
||||
) # type: ignore
|
||||
from zhenxun.services.hot_query_cache import get_user_group_ids
|
||||
|
||||
return await get_user_group_ids(user_id)
|
||||
|
||||
@classmethod
|
||||
async def _run_script(cls):
|
||||
db_type = (BotConfig.get_sql_type() or "").lower()
|
||||
scripts = ["ALTER TABLE group_info_users DROP COLUMN nickname;"]
|
||||
|
||||
if "postgres" in db_type:
|
||||
scripts.extend(
|
||||
[
|
||||
(
|
||||
"ALTER TABLE group_info_users ADD COLUMN IF NOT EXISTS "
|
||||
"platform character varying(255);"
|
||||
),
|
||||
(
|
||||
"ALTER TABLE group_info_users ALTER COLUMN user_id "
|
||||
"TYPE character varying(255) USING user_id::character varying;"
|
||||
),
|
||||
(
|
||||
"ALTER TABLE group_info_users ALTER COLUMN group_id "
|
||||
"TYPE character varying(255) USING group_id::character varying;"
|
||||
),
|
||||
(
|
||||
"ALTER TABLE group_info_users ALTER COLUMN platform "
|
||||
"TYPE character varying(255) USING platform::character varying;"
|
||||
),
|
||||
]
|
||||
)
|
||||
elif "mysql" in db_type:
|
||||
scripts.extend(
|
||||
[
|
||||
(
|
||||
"ALTER TABLE group_info_users ADD COLUMN "
|
||||
"platform VARCHAR(255) NULL;"
|
||||
),
|
||||
(
|
||||
"ALTER TABLE group_info_users MODIFY COLUMN "
|
||||
"user_id VARCHAR(255) NOT NULL;"
|
||||
),
|
||||
(
|
||||
"ALTER TABLE group_info_users MODIFY COLUMN "
|
||||
"group_id VARCHAR(255) NOT NULL;"
|
||||
),
|
||||
(
|
||||
"ALTER TABLE group_info_users MODIFY COLUMN "
|
||||
"platform VARCHAR(255) NULL;"
|
||||
),
|
||||
]
|
||||
)
|
||||
elif "sqlite" in db_type:
|
||||
scripts.append(
|
||||
"ALTER TABLE group_info_users ADD COLUMN platform VARCHAR(255);"
|
||||
)
|
||||
|
||||
return scripts
|
||||
return [
|
||||
DropColumn("group_info_users", "nickname"),
|
||||
AlterColumnType(
|
||||
"group_info_users",
|
||||
"user_id",
|
||||
{"postgres": "character varying(255)", "mysql": "VARCHAR(255)"},
|
||||
nullable=False,
|
||||
),
|
||||
AlterColumnType(
|
||||
"group_info_users",
|
||||
"group_id",
|
||||
{"postgres": "character varying(255)", "mysql": "VARCHAR(255)"},
|
||||
nullable=False,
|
||||
),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user