乱点提示 @点击者:markdown 内联提及 <@openid>
This commit is contained in:
1 parent
755013b9db
commit
3fed0b0db1
3 files changed
+79
-9
No files matched your search
+24
-4
@@ -96,10 +96,26 @@ async def set_member_mute(
|
||||
return False
|
||||
|
||||
|
||||
async def _reply_text(api: BotApi, group_openid: str, text: str, *, event_id: str | None = None, msg_id: str | None = None) -> None:
|
||||
"""被动回复文本;窗口过期等失败降级为日志,不影响主流程。"""
|
||||
async def _reply_text(
|
||||
api: BotApi, group_openid: str, text: str, *,
|
||||
event_id: str | None = None, msg_id: str | None = None,
|
||||
mention: str | None = None,
|
||||
) -> None:
|
||||
"""被动回复文本;mention 传 openid 时改为 markdown 内联提及 @对方。
|
||||
|
||||
窗口过期等失败降级为日志,不影响主流程。提及必须走 markdown
|
||||
(纯文本 content 不解析 <@> 语法)。
|
||||
"""
|
||||
try:
|
||||
await api.post_group_message(group_openid, content=text, event_id=event_id, msg_id=msg_id)
|
||||
if mention:
|
||||
await api.post_group_message(
|
||||
group_openid, markdown=f"<@{mention}> {text}",
|
||||
event_id=event_id, msg_id=msg_id,
|
||||
)
|
||||
else:
|
||||
await api.post_group_message(
|
||||
group_openid, content=text, event_id=event_id, msg_id=msg_id,
|
||||
)
|
||||
except ApiError as e:
|
||||
logger.warning(f"回复消息失败 (group={group_openid}): {e}")
|
||||
|
||||
@@ -194,6 +210,7 @@ async def _handle_foreign_click(
|
||||
f"这道题不是给你的~(再乱点 {remaining} 次将被禁言 "
|
||||
f"{cfg.foreign_click_mute_minutes} 分钟)",
|
||||
event_id=event_id,
|
||||
mention=member_openid,
|
||||
)
|
||||
return
|
||||
|
||||
@@ -215,6 +232,7 @@ async def _handle_foreign_click(
|
||||
api, group_openid,
|
||||
f"多次乱点他人的验证按钮,已禁言 {cfg.foreign_click_mute_minutes} 分钟。",
|
||||
event_id=event_id,
|
||||
mention=member_openid,
|
||||
)
|
||||
else:
|
||||
await _reply_text(
|
||||
@@ -222,6 +240,7 @@ async def _handle_foreign_click(
|
||||
"多次乱点他人的验证按钮!禁言未能生效(群主/管理员无法被禁言),"
|
||||
"请管理员处理。",
|
||||
event_id=event_id,
|
||||
mention=member_openid,
|
||||
)
|
||||
|
||||
|
||||
@@ -350,7 +369,8 @@ def setup(bot: Bot, cfg: AuthConfig) -> VerifyState:
|
||||
else:
|
||||
# 旧题/已失效按钮,礼貌忽略不计处罚
|
||||
await _reply_text(api, inter.group_openid, "这道题不是给你的~",
|
||||
event_id=event.event_id)
|
||||
event_id=event.event_id,
|
||||
mention=inter.group_member_openid)
|
||||
return
|
||||
if not is_subject:
|
||||
await _reply_text(api, inter.group_openid, "这题已经被换掉啦,请回答最新一题",
|
||||
|
||||
Reference in new issue
Block a user