feat: Add end time to Match class
This commit is contained in:
parent
864c3ddce1
commit
203d30a8c6
9
dota.py
9
dota.py
@ -61,6 +61,7 @@ class Match(BaseModel):
|
||||
'radiant_score': match_.radiant_score,
|
||||
# isoformat utc+8
|
||||
'start_time': datetime.datetime.fromtimestamp(match_.start_time).strftime('%Y-%m-%dT%H:%M:%S.000+08:00'),
|
||||
'end_time': datetime.datetime.fromtimestamp(match_.start_time + match_.duration).strftime('%Y-%m-%dT%H:%M:%S.000+08:00'),
|
||||
'duration': '%d:%02d:%02d' % utils.convert_seconds_to_hms(match_.duration),
|
||||
'radiant_win': match_.radiant_win,
|
||||
'party_size': self.party_size,
|
||||
@ -97,6 +98,7 @@ class Friend(BaseModel):
|
||||
'assists': match_.assists,
|
||||
'party_size': match_.party_size,
|
||||
'start_time': match_.start_time,
|
||||
'end_time': match_.start_time + match_.duration,
|
||||
'duration': match_.duration,
|
||||
'average_rank': utils.get_ranking(match_.average_rank),
|
||||
'hero_id': match_.hero_id,
|
||||
@ -142,14 +144,15 @@ class Friend(BaseModel):
|
||||
if match_['average_rank']:
|
||||
summary += '\n' + match_['average_rank']
|
||||
|
||||
start_time = datetime.datetime.fromtimestamp(match_['start_time']).strftime('%Y-%m-%dT%H:%M:%S.000+08:00')
|
||||
# start_time = datetime.datetime.fromtimestamp(match_['start_time']).strftime('%Y-%m-%dT%H:%M:%S.000+08:00')
|
||||
end_time = datetime.datetime.fromtimestamp(match_['end_time']).strftime('%Y-%m-%dT%H:%M:%S.000+08:00')
|
||||
hero_name = Hero.get(hero_id=match_['hero_id']).localized_name
|
||||
data['embeds'].append({
|
||||
'title': f"{hero_name} {match_['kills']} 杀 {match_['deaths']} 死 {match_['assists']} 助 ",
|
||||
'description': summary,
|
||||
'color': 6732650 if match_['win'] else 16724787, # 66bb6a or FF3333
|
||||
'fields': [],
|
||||
'timestamp': start_time,
|
||||
'timestamp': end_time,
|
||||
'url': f"https://www.opendota.com/matches/{match_['match_id']}",
|
||||
})
|
||||
return data
|
||||
@ -295,7 +298,7 @@ def serialize_match_for_discord(match_):
|
||||
"name": "opendota",
|
||||
"url": "https://www.opendota.com/matches/%s" % match_['match_id']
|
||||
},
|
||||
"timestamp": match_['start_time']
|
||||
"timestamp": match_['end_time']
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user