fix: resolve streak notification issues
- Initialize global streak_updates variable to prevent NameError - Fix streak notifications only showing for first match - Ensure notifications appear once per batch instead of being lost
This commit is contained in:
parent
c85eeb9d74
commit
7498f413bf
@ -44,6 +44,9 @@ async def send_message(channel):
|
||||
logger.error(f"Error in send_message task: {e}")
|
||||
return
|
||||
|
||||
# 用于标记是否是第一场比赛
|
||||
first_match = True
|
||||
|
||||
for match_ in matches:
|
||||
data = await dota.serialize_match_for_discord(match_)
|
||||
logger.info(f"sending match {match_['match_id']}, {data}")
|
||||
@ -58,13 +61,12 @@ async def send_message(channel):
|
||||
if 'value' in field and field['value']:
|
||||
friends_info = f"**{field['value']}** 的比赛:\n\n"
|
||||
|
||||
# 将朋友信息和连胜连败消息放在内容开头
|
||||
# 将朋友信息放在内容开头,连胜连败消息只在第一场比赛时添加
|
||||
content = data['content']
|
||||
if streak_notifications:
|
||||
if first_match and streak_notifications:
|
||||
streak_msg = '\n'.join(streak_notifications) + '\n\n'
|
||||
content = friends_info + streak_msg + content
|
||||
# 发送后清空通知列表,避免重复发送
|
||||
streak_notifications = []
|
||||
first_match = False # 标记已经处理过第一场比赛
|
||||
else:
|
||||
content = friends_info + content
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user