Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ gs_wuwa_daily_wife
- `DailyWifeGalleryUsername`:画廊账号;
- `DailyWifeGalleryPassword`:画廊密码;
- `DailyWifeSendText`:是否发送“你今天的老婆是xxx”;
- `DailyWifeAtUser`:发送今日老婆和抢老婆成功图片时是否艾特对应用户;
- `DailyWifeShowRoleId`:是否显示角色 ID;
- `DailyWifeTextTemplate`:文字模板,可用变量 `{name}`、`{role_id}`;
- `DailyWifeMasterUnlimited`:主人无限抽老婆,开启后 GSCore 主人不会固定当天结果;
Expand Down
26 changes: 19 additions & 7 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,18 +355,27 @@ 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:
logger.warning(f'[gs_wuwa_daily_wife] 下载画廊图片失败: {exc}')
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):
Expand All @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions config_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
'开启后图片前附带“你今天的老婆是xxx”',
True,
),
'DailyWifeAtUser': GsBoolConfig(
'发送时艾特触发者',
'开启后发送今日老婆和抢老婆成功图片时会艾特对应用户',
True,
),
Comment on lines +32 to +36
'DailyWifeShowRoleId': GsBoolConfig(
'显示角色 ID',
'开启后在文字说明里额外显示本次角色对应的数字 ID',
Expand Down