discord-dota-bot/matches.py
Ching e109649c95 feat(players.py, matches.py, utils.py): 补充比赛序列化方法,增加 utils
补充比赛序列化方法,增加 utils

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

19 lines
601 B
Python

import opendota
import datetime
import players
import utils
match_client = opendota.MatchesApi()
def serialize_match(match_id):
match = match_client.get_matches_by_match_id(match_id)
match_data = {
'players': [players.serialize_player(player) for player in match.players],
'dire_score': match.dire_score,
'radiant_score': match.radiant_score,
'start_time': datetime.datetime.fromtimestamp(match.start_time).strftime('%Y-%m-%d %H:%M:%S'),
'duration': '%d:%02d:%02d' % utils.convert_seconds_to_hms(match.duration),
'radiant_win': match.radiant_win,
}
return match_data