fix: Adjust match limit and embed image placement logic
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
d2b9e18438
commit
ed0a0c3f79
10
dota.py
10
dota.py
@ -134,8 +134,8 @@ class Friend(BaseModel):
|
|||||||
# ],
|
# ],
|
||||||
# }
|
# }
|
||||||
matches = []
|
matches = []
|
||||||
if limit > 10:
|
# if limit > 10:
|
||||||
limit = 10
|
# limit = 10
|
||||||
for friend in friends:
|
for friend in friends:
|
||||||
matches_ = friend.serialize_recent_matches(limit=limit)
|
matches_ = friend.serialize_recent_matches(limit=limit)
|
||||||
if not matches_:
|
if not matches_:
|
||||||
@ -151,7 +151,7 @@ class Friend(BaseModel):
|
|||||||
'embeds': [],
|
'embeds': [],
|
||||||
}
|
}
|
||||||
|
|
||||||
for match_ in matches[:limit]:
|
for match_ in matches[:min(limit, 9)]:
|
||||||
duration = '%d:%02d:%02d' % utils.convert_seconds_to_hms(match_['duration'])
|
duration = '%d:%02d:%02d' % utils.convert_seconds_to_hms(match_['duration'])
|
||||||
summary = f"{duration}"
|
summary = f"{duration}"
|
||||||
if match_['party_size'] == None:
|
if match_['party_size'] == None:
|
||||||
@ -188,7 +188,7 @@ class Friend(BaseModel):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"生成最近比赛报告图片失败: {str(e)}")
|
logger.error(f"生成最近比赛报告图片失败: {str(e)}")
|
||||||
|
|
||||||
# 如果成功生成了图片,添加到第一个embed中
|
# 如果成功生成了图片,添加到最后一个embed中
|
||||||
if image_url:
|
if image_url:
|
||||||
data['embeds'].append({
|
data['embeds'].append({
|
||||||
'image': {
|
'image': {
|
||||||
@ -330,7 +330,7 @@ async def serialize_match_for_discord(match_):
|
|||||||
image_url = await image_generator.generate_match_report(match_)
|
image_url = await image_generator.generate_match_report(match_)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"生成比赛报告图片失败: {str(e)}")
|
logger.error(f"生成比赛报告图片失败: {str(e)}")
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"content": content,
|
"content": content,
|
||||||
"tts": False,
|
"tts": False,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user