discord-dota-bot/matches.py
Ching 4b31d228c6 feat(matches): 增加 matches file,获取比赛详情
增加 matches file,获取比赛详情

Signed-off-by: Ching <loooching@gmail.com>
2023-09-15 00:48:40 +08:00

24 lines
557 B
Python

import opendota
match_client = opendota.MatchesApi()
def serialize_player(player):
player_data = {
'personaname': player.personaname,
'kills': player.kills,
'deaths': player.deaths,
'assists': player.assists,
'total_gold': player.total_gold,
'last_hits': player.last_hits,
'denies': player.denies,
}
return player_data
def serialize_match(match_id):
match = match_client.get_matches_by_match_id(match_id)
match_data = {
'players': [serialize_player(player) for player in match.players],
}
return match_data