mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-09-29 16:50:02 +08:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
881ec1819e | ||
|
|
6ba511f4d6 |
@@ -7,7 +7,7 @@ ci:
|
|||||||
autoupdate_commit_msg: ":arrow_up: auto update by pre-commit hooks"
|
autoupdate_commit_msg: ":arrow_up: auto update by pre-commit hooks"
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.8.2
|
rev: v0.16.6
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
args: [--fix]
|
args: [--fix]
|
||||||
|
|||||||
@@ -76,8 +76,7 @@ async def auth_admin(
|
|||||||
raise SkipPluginException(
|
raise SkipPluginException(
|
||||||
f"{plugin.name}({plugin.module}) 管理员权限不足...",
|
f"{plugin.name}({plugin.module}) 管理员权限不足...",
|
||||||
tip_message=(
|
tip_message=(
|
||||||
f"你的权限不足喔,该功能需要的权限等级: "
|
f"你的权限不足喔,该功能需要的权限等级: {plugin.admin_level}"
|
||||||
f"{plugin.admin_level}"
|
|
||||||
),
|
),
|
||||||
tip_background=True,
|
tip_background=True,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -181,8 +181,7 @@ def event_cache_key(
|
|||||||
channel_id = entity.channel_id or ""
|
channel_id = entity.channel_id or ""
|
||||||
scope = platform_scope or platform
|
scope = platform_scope or platform
|
||||||
return (
|
return (
|
||||||
f"{scope}:{platform}:{bot_id}:{entity.user_id}:"
|
f"{scope}:{platform}:{bot_id}:{entity.user_id}:{group_id}:{channel_id}:{msg_id}"
|
||||||
f"{group_id}:{channel_id}:{msg_id}"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -121,14 +121,16 @@ async def get_chat_history(
|
|||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
filter_date = now - timedelta(days=7)
|
filter_date = now - timedelta(days=7)
|
||||||
date_list = await _read_db(
|
date_list = await _read_db(
|
||||||
lambda: ChatHistory.filter(
|
lambda: (
|
||||||
|
ChatHistory.filter(
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
group_id=group_id,
|
group_id=group_id,
|
||||||
create_time__gte=filter_date,
|
create_time__gte=filter_date,
|
||||||
)
|
)
|
||||||
.annotate(date=RawSQL("DATE(create_time)"), count=Count("id"))
|
.annotate(date=RawSQL("DATE(create_time)"), count=Count("id"))
|
||||||
.group_by("date")
|
.group_by("date")
|
||||||
.values("date", "count"),
|
.values("date", "count")
|
||||||
|
),
|
||||||
"MyInfo.chat_history_chart",
|
"MyInfo.chat_history_chart",
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ async def _prune_stale_tags():
|
|||||||
deleted_count = await tag_manager.prune_stale_group_links()
|
deleted_count = await tag_manager.prune_stale_group_links()
|
||||||
if deleted_count > 0:
|
if deleted_count > 0:
|
||||||
logger.info(
|
logger.info(
|
||||||
f"定时任务:成功清理了 {deleted_count} 个无效的群组标签" f"关联。",
|
f"定时任务:成功清理了 {deleted_count} 个无效的群组标签关联。",
|
||||||
"群组标签管理",
|
"群组标签管理",
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ from .config import (
|
|||||||
lik2relation,
|
lik2relation,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert (
|
assert len(level2attitude) == len(lik2level) == len(lik2relation), (
|
||||||
len(level2attitude) == len(lik2level) == len(lik2relation)
|
"好感度态度、等级、关系长度不匹配!"
|
||||||
), "好感度态度、等级、关系长度不匹配!"
|
)
|
||||||
|
|
||||||
AVA_URL = "http://q1.qlogo.cn/g?b=qq&nk={}&s=160"
|
AVA_URL = "http://q1.qlogo.cn/g?b=qq&nk={}&s=160"
|
||||||
|
|
||||||
|
|||||||
@@ -426,8 +426,9 @@ async def handle_delete(names: Match[list[str]]):
|
|||||||
async def handle_clear():
|
async def handle_clear():
|
||||||
confirm = await prompt_until(
|
confirm = await prompt_until(
|
||||||
"【警告】此操作将删除所有群组标签,是否继续?\n请输入 `是` 或 `确定` 确认操作",
|
"【警告】此操作将删除所有群组标签,是否继续?\n请输入 `是` 或 `确定` 确认操作",
|
||||||
lambda msg: msg.extract_plain_text().lower()
|
lambda msg: (
|
||||||
in ["是", "确定", "yes", "confirm"],
|
msg.extract_plain_text().lower() in ["是", "确定", "yes", "confirm"]
|
||||||
|
),
|
||||||
timeout=30,
|
timeout=30,
|
||||||
retry=1,
|
retry=1,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -88,8 +88,7 @@ class FallbackRouter(BaseModelRouter):
|
|||||||
)
|
)
|
||||||
raise e
|
raise e
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"⚠️ 节点 '{m_name}' "
|
f"⚠️ 节点 '{m_name}' 错误 ({e.__class__.__name__}),触发故障转移..."
|
||||||
f"错误 ({e.__class__.__name__}),触发故障转移..."
|
|
||||||
)
|
)
|
||||||
errors.append(f"{m_name}({e.__class__.__name__})")
|
errors.append(f"{m_name}({e.__class__.__name__})")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -99,7 +98,7 @@ class FallbackRouter(BaseModelRouter):
|
|||||||
if all_nodes_bypassed and len(model_names) > 1:
|
if all_nodes_bypassed and len(model_names) > 1:
|
||||||
fallback_model = health_manager.get_best_fallback_route(model_names)
|
fallback_model = health_manager.get_best_fallback_route(model_names)
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"⚠️ 路由组所有节点均已宕机!" f"强制放行 '{fallback_model}' 探活..."
|
f"⚠️ 路由组所有节点均已宕机!强制放行 '{fallback_model}' 探活..."
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
async with await get_model_instance(
|
async with await get_model_instance(
|
||||||
|
|||||||
@@ -339,9 +339,7 @@ def _index_sql(table: str, columns: tuple[str, ...], dialect: Dialect) -> str |
|
|||||||
index_sql = _quote_identifier(_index_name(table, columns), dialect)
|
index_sql = _quote_identifier(_index_name(table, columns), dialect)
|
||||||
columns_sql = ", ".join(_quote_identifier(column, dialect) for column in columns)
|
columns_sql = ", ".join(_quote_identifier(column, dialect) for column in columns)
|
||||||
if dialect in {"sqlite", "postgres"}:
|
if dialect in {"sqlite", "postgres"}:
|
||||||
return (
|
return f"CREATE INDEX IF NOT EXISTS {index_sql} ON {table_sql}({columns_sql})"
|
||||||
f"CREATE INDEX IF NOT EXISTS {index_sql} " f"ON {table_sql}({columns_sql})"
|
|
||||||
)
|
|
||||||
if dialect == "mysql":
|
if dialect == "mysql":
|
||||||
return f"CREATE INDEX {index_sql} ON {table_sql}({columns_sql})"
|
return f"CREATE INDEX {index_sql} ON {table_sql}({columns_sql})"
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user