Skip to content

Commit

Permalink
Support The Front
Browse files Browse the repository at this point in the history
  • Loading branch information
BattlefieldDuck committed Oct 24, 2023
1 parent 9432b1d commit 4ec29aa
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions discordgsm/protocols/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ async def get_players():
return []

start = time.time()
info, players = await asyncio.gather(source.get_info(), get_players())

# The Front incorrect info server name fix
if self.kv['type'] == 'front':
info, players, rules = await asyncio.gather(source.get_info(), get_players(), source.get_rules())
info['Name'] = rules['ServerName_s'] # Override the info server name
else:
info, players = await asyncio.gather(source.get_info(), get_players())

ping = int((time.time() - start) * 1000)
players.sort(key=lambda x: x['Duration'], reverse=True)
players, bots = players[info['Bots']:], players[:info['Bots']]
Expand All @@ -50,9 +57,11 @@ async def get_players():

if game_id := info.get('GameID'):
if game_id == 629760: # mordhau, fix numplayers
result['numplayers'] = int(next((tag[2:] for tag in result['raw']['tags'] if tag[:2] == 'B:'), '0'))
result['numplayers'] = int(
next((tag[2:] for tag in result['raw']['tags'] if tag[:2] == 'B:'), '0'))
elif game_id == 252490: # rust, fix maxplayers
result['maxplayers'] = int(next((tag[2:] for tag in result['raw']['tags'] if tag[:2] == 'mp'), result['maxplayers']))
result['maxplayers'] = int(next(
(tag[2:] for tag in result['raw']['tags'] if tag[:2] == 'mp'), result['maxplayers']))
elif game_id == 346110: # arkse, fix numplayers
result['numplayers'] = len(result['players'])

Expand Down

0 comments on commit 4ec29aa

Please sign in to comment.