From 21c7b956530ff4b5d52a04b7a6f8017286fabb8b Mon Sep 17 00:00:00 2001 From: Ching L Date: Thu, 24 Jul 2025 11:49:55 +0800 Subject: [PATCH] feat: Update match result messaging to include streak notifications in the content --- discord_bot.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/discord_bot.py b/discord_bot.py index 6cb6cc5..e8dd91f 100644 --- a/discord_bot.py +++ b/discord_bot.py @@ -48,15 +48,16 @@ async def send_message(channel): data = await dota.serialize_match_for_discord(match_) logger.info(f"sending match {match_['match_id']}, {data}") try: - # 发送比赛结果 - await channel.send(content=data['content'], embeds=[discord.Embed.from_dict(embed) for embed in data['embeds']]) - - # 如果有连胜连败消息,一并发送 + # 将连胜连败消息放在内容开头 + content = data['content'] if streak_notifications: - for notification in streak_notifications: - await channel.send(content=notification) + streak_msg = '\n'.join(streak_notifications) + '\n\n' + content = streak_msg + content # 发送后清空通知列表,避免重复发送 streak_notifications = [] + + # 发送比赛结果(连胜信息已包含在content开头) + await channel.send(content=content, embeds=[discord.Embed.from_dict(embed) for embed in data['embeds']]) except Exception as e: logger.error(f"send match error {e}")