diff --git a/README.md b/README.md index b40d40d..0e71413 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ gs_wuwa_daily_wife - `DailyWifeGalleryUsername`:画廊账号; - `DailyWifeGalleryPassword`:画廊密码; - `DailyWifeSendText`:是否发送“你今天的老婆是xxx”; +- `DailyWifeAtUser`:发送今日老婆和抢老婆成功图片时是否艾特对应用户; - `DailyWifeShowRoleId`:是否显示角色 ID; - `DailyWifeTextTemplate`:文字模板,可用变量 `{name}`、`{role_id}`; - `DailyWifeMasterUnlimited`:主人无限抽老婆,开启后 GSCore 主人不会固定当天结果; diff --git a/__init__.py b/__init__.py index 37b74f6..9399f20 100644 --- a/__init__.py +++ b/__init__.py @@ -355,7 +355,13 @@ async def _ensure_daily_wife_record(ev: Event, user_id: str | int | None = None) return record -async def _send_role_image(bot: Bot, role: RoleCandidate, image_url: str, text: str | None = None) -> None: +async def _send_role_image( + bot: Bot, + role: RoleCandidate, + image_url: str, + text: str | None = None, + user_id: str | int | None = None, +) -> None: try: image = await _download_image(image_url) except RuntimeError as exc: @@ -363,10 +369,13 @@ async def _send_role_image(bot: Bot, role: RoleCandidate, image_url: str, text: await bot.send(str(exc)) return + messages: list[Any] = [] + if user_id is not None and bool(_cfg('DailyWifeAtUser')): + messages.append(MessageSegment.at(user_id)) if text: - await bot.send([text, MessageSegment.image(image)]) - else: - await bot.send(MessageSegment.image(image)) + messages.append(text) + messages.append(MessageSegment.image(image)) + await bot.send(messages if len(messages) > 1 else messages[0]) async def _send_daily_wife(bot: Bot, ev: Event): @@ -392,7 +401,7 @@ async def _send_daily_wife(bot: Bot, ev: Event): ) text = _build_text(role) if bool(_cfg('DailyWifeSendText')) else None - await _send_role_image(bot, role, image, text) + await _send_role_image(bot, role, image, text, ev.user_id) async def _send_rob_wife(bot: Bot, ev: Event): @@ -428,9 +437,12 @@ async def _send_rob_wife(bot: Bot, ev: Event): role = target_record.to_role() text = _build_rob_success_text(role, target_user_id) if bool(_cfg('DailyWifeSendText')): - await _send_role_image(bot, role, target_record.image, text) + await _send_role_image(bot, role, target_record.image, text, robber_id) else: - await bot.send(text) + if bool(_cfg('DailyWifeAtUser')): + await bot.send([MessageSegment.at(robber_id), text]) + else: + await bot.send(text) @sv.on_fullmatch('今日老婆', block=True) diff --git a/config_default.py b/config_default.py index 0fb877f..fa6d19c 100644 --- a/config_default.py +++ b/config_default.py @@ -29,6 +29,11 @@ '开启后图片前附带“你今天的老婆是xxx”', True, ), + 'DailyWifeAtUser': GsBoolConfig( + '发送时艾特触发者', + '开启后发送今日老婆和抢老婆成功图片时会艾特对应用户', + True, + ), 'DailyWifeShowRoleId': GsBoolConfig( '显示角色 ID', '开启后在文字说明里额外显示本次角色对应的数字 ID',