mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-10 22:30:02 +08:00
词条问题支持真寻的昵称开头与at真寻开头并优化回复
This commit is contained in:
@@ -139,6 +139,7 @@ async def _(
|
||||
|
||||
@add_word.got("problem_image", prompt="请发送该回答设置的问题图片")
|
||||
async def _(
|
||||
bot: Bot,
|
||||
event: MessageEvent,
|
||||
word_scope: Optional[str] = ArgStr("word_scope"),
|
||||
word_type: Optional[str] = ArgStr("word_type"),
|
||||
@@ -152,13 +153,19 @@ async def _(
|
||||
re.compile(problem)
|
||||
except re.error:
|
||||
await add_word.finish(f"添加词条失败,正则表达式 {problem} 非法!")
|
||||
if str(event.user_id) in bot.config.superusers and isinstance(event, PrivateMessageEvent):
|
||||
word_scope = "私聊"
|
||||
nickname = None
|
||||
if problem and bot.config.nickname:
|
||||
nickname = [nk for nk in bot.config.nickname if problem.startswith(nk)]
|
||||
await WordBank.add_problem_answer(
|
||||
event.user_id,
|
||||
event.group_id if isinstance(event, GroupMessageEvent) and (not word_scope or word_scope == '1') else 0,
|
||||
event.group_id if isinstance(event, GroupMessageEvent) and (not word_scope or word_scope == '私聊') else 0,
|
||||
scope2int[word_scope] if word_scope else 1,
|
||||
type2int[word_type] if word_type else 0,
|
||||
problem or problem_image,
|
||||
answer,
|
||||
nickname[0] if nickname else None
|
||||
)
|
||||
except Exception as e:
|
||||
if isinstance(e, FinishedException):
|
||||
|
||||
Reference in New Issue
Block a user