Skip to content

Commit

Permalink
Update protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
BattlefieldDuck committed Nov 4, 2023
1 parent 7b7b879 commit 7f63909
Show file tree
Hide file tree
Showing 28 changed files with 43 additions and 38 deletions.
2 changes: 1 addition & 1 deletion discordgsm/protocols/ase.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async def query(self):
'numbots': 0,
'maxplayers': int(status['maxplayers']),
'players': [{'name': player['name'], 'raw': player} for player in status['players']],
'bots': [],
'bots': None,
'connect': f"{host}:{status.get('gameport', port)}",
'ping': ping,
'raw': status
Expand Down
2 changes: 1 addition & 1 deletion discordgsm/protocols/assettocorsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async def query(self):
'numbots': 0,
'maxplayers': info['maxclients'],
'players': players,
'bots': [],
'bots': None,
'connect': f'{host}:{info["port"]}',
'ping': ping,
'raw': {
Expand Down
2 changes: 1 addition & 1 deletion discordgsm/protocols/battlefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async def query(self):
'numbots': 0,
'maxplayers': info['maxplayers'],
'players': [{'name': player['name'], 'raw': player} for player in players],
'bots': [],
'bots': None,
'connect': info['ip_port'],
'ping': ping,
'raw': info
Expand Down
2 changes: 1 addition & 1 deletion discordgsm/protocols/beammp.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def query(self):
'numbots': 0,
'maxplayers': int(server['maxplayers']),
'players': [{'name': name, 'raw': {}} for name in str(server['playerslist']).split(';')],
'bots': [],
'bots': None,
'connect': key,
'ping': 0,
'raw': server
Expand Down
2 changes: 1 addition & 1 deletion discordgsm/protocols/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def query(self):
'numbots': 0,
'maxplayers': -1,
'players': [{'name': player['username'], 'raw': player} for player in data['members']],
'bots': [],
'bots': None,
'connect': data['instant_invite'],
'ping': ping,
'raw': {}
Expand Down
7 changes: 4 additions & 3 deletions discordgsm/protocols/doom3.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class Doom3(Protocol):
name = 'doom3'

async def query(self):
doom3 = opengsq.Doom3(self.address, self.query_port, self.timeout)
host, port = str(self.kv['host']), int(str(self.kv['port']))
doom3 = opengsq.Doom3(host, port, self.timeout)
start = time.time()
info = await doom3.get_info()
ping = int((time.time() - start) * 1000)
Expand All @@ -27,8 +28,8 @@ async def query(self):
'numbots': 0,
'maxplayers': int(info.get('si_maxplayers', info.get('si_maxPlayers', '0'))),
'players': [{'name': player['name'], 'raw': player} for player in players],
'bots': [],
'connect': f'{self.address}:{self.query_port}',
'bots': None,
'connect': f'{host}:{port}',
'ping': ping,
'raw': info
}
Expand Down
2 changes: 1 addition & 1 deletion discordgsm/protocols/eco.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def query(self):
'numbots': 0,
'maxplayers': data['MaxActivePlayers'],
'players': [{'name': player, 'raw': player} for player in data['OnlinePlayersNames']],
'bots': [],
'bots': None,
'connect': data['JoinUrl'],
'ping': ping,
'raw': data
Expand Down
2 changes: 1 addition & 1 deletion discordgsm/protocols/factorio.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def query(self):
'numbots': 0,
'maxplayers': server['max_players'],
'players': [{'name': player, 'raw': player} for player in players],
'bots': [],
'bots': None,
'connect': server['host_address'],
'ping': 0,
'raw': server
Expand Down
2 changes: 1 addition & 1 deletion discordgsm/protocols/fivem.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def query(self):
'numbots': 0,
'maxplayers': int(info.get('sv_maxclients', '0')),
'players': [{'name': player['name'], 'raw': player} for player in players],
'bots': [],
'bots': None,
'connect': f'{host}:{port}',
'ping': ping,
'raw': info
Expand Down
4 changes: 2 additions & 2 deletions discordgsm/protocols/front.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ async def query(self):
'numplayers': server.online,
'numbots': 0,
'maxplayers': server.info.get('maxplayer'),
'players': [],
'bots': [],
'players': None,
'bots': None,
'connect': host_address,
'ping': ping,
'raw': server.__dict__
Expand Down
2 changes: 1 addition & 1 deletion discordgsm/protocols/gamespy1.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async def query(self):
'numbots': 0,
'maxplayers': int(info['maxplayers']),
'players': [{'name': player['player'], 'raw': player} for player in players],
'bots': [],
'bots': None,
'connect': f"{host}:{info.get('hostport', port)}",
'ping': ping,
'raw': info
Expand Down
2 changes: 1 addition & 1 deletion discordgsm/protocols/gamespy2.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def query(self):
'numbots': 0,
'maxplayers': int(info['maxplayers']),
'players': [{'name': player['player'], 'raw': player} for player in players],
'bots': [],
'bots': None,
'connect': f"{host}:{info.get('hostport', port)}",
'ping': ping,
'raw': info
Expand Down
2 changes: 1 addition & 1 deletion discordgsm/protocols/gamespy3.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def query(self):
'numbots': 0,
'maxplayers': int(info['maxplayers']),
'players': [{'name': player['player'], 'raw': player} for player in players],
'bots': [],
'bots': None,
'connect': f"{host}:{info.get('hostport', port)}",
'ping': ping,
'raw': info
Expand Down
4 changes: 2 additions & 2 deletions discordgsm/protocols/gportal.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ async def query(self):
'numplayers': data['currentPlayers'],
'numbots': 0,
'maxplayers': data['maxPlayers'],
'players': [],
'bots': [],
'players': None,
'bots': None,
'connect': f"{data['ipAddress']}:{data['port']}",
'ping': int((end - start) * 1000),
'raw': data
Expand Down
2 changes: 1 addition & 1 deletion discordgsm/protocols/minecraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async def query(self):
'numbots': 0,
'maxplayers': int(status.get('players', {}).get('max', '0')),
'players': players,
'bots': [],
'bots': None,
'connect': f'{host}:{port}',
'ping': ping,
'raw': status
Expand Down
4 changes: 2 additions & 2 deletions discordgsm/protocols/nwn1.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ async def query(self):
'numplayers': int(server.active_player_count),
'numbots': 0,
'maxplayers': int(server.maximum_player_count),
'players': [],
'bots': [],
'players': None,
'bots': None,
'connect': key,
'ping': 0,
'raw': server.__dict__
Expand Down
4 changes: 2 additions & 2 deletions discordgsm/protocols/nwn2.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ async def query(self):
'numplayers': int(server.active_player_count),
'numbots': 0,
'maxplayers': int(server.maximum_player_count),
'players': [],
'bots': [],
'players': None,
'bots': None,
'connect': key,
'ping': 0,
'raw': server.__dict__
Expand Down
4 changes: 2 additions & 2 deletions discordgsm/protocols/raknet.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ async def query(self):
'numplayers': int(status.get('num_players', '')),
'numbots': 0,
'maxplayers': int(status.get('max_players', '')),
'players': [],
'bots': [],
'players': None,
'bots': None,
'connect': f"{host}:{status.get('port_ipv4', port)}",
'ping': ping,
'raw': status
Expand Down
2 changes: 1 addition & 1 deletion discordgsm/protocols/samp.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def get_players():
'numbots': 0,
'maxplayers': status['maxplayers'],
'players': [{'name': player['name'], 'raw': player} for player in players],
'bots': [],
'bots': None,
'connect': f'{host}:{port}',
'ping': ping,
'raw': {
Expand Down
4 changes: 2 additions & 2 deletions discordgsm/protocols/satisfactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ async def query(self):
'numplayers': 0,
'numbots': 0,
'maxplayers': 0,
'players': [],
'bots': [],
'players': None,
'bots': None,
'connect': f'{host}:{port}',
'ping': ping,
'raw': status
Expand Down
4 changes: 2 additions & 2 deletions discordgsm/protocols/scum.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ async def query(self):
'numplayers': server['numplayers'],
'numbots': 0,
'maxplayers': server['maxplayers'],
'players': [],
'bots': [],
'players': None,
'bots': None,
'connect': f"{host}:{server['port'] - 2}",
'ping': 0,
'raw': server
Expand Down
2 changes: 1 addition & 1 deletion discordgsm/protocols/teamspeak3.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def query(self):
'numbots': 0,
'maxplayers': int(info.get('virtualserver_maxclients', '0')),
'players': players,
'bots': [],
'bots': None,
'connect': f'{host}:{voice_port}',
'ping': ping,
'raw': {
Expand Down
2 changes: 1 addition & 1 deletion discordgsm/protocols/terraria.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def query(self):
'numbots': 0,
'maxplayers': data['maxplayers'],
'players': [{'name': player['nickname'], 'raw': player} for player in data['players']],
'bots': [],
'bots': None,
'connect': f"{host}:{data['port']}",
'ping': int((end - start) * 1000),
'raw': {}
Expand Down
2 changes: 1 addition & 1 deletion discordgsm/protocols/unreal2.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def query(self):
'numbots': 0,
'maxplayers': int(details['MaxPlayers']),
'players': [{'name': player['Name'], 'raw': player} for player in players],
'bots': [],
'bots': None,
'connect': f"{host}:{details.get('GamePort', port)}",
'ping': ping,
'raw': details
Expand Down
2 changes: 1 addition & 1 deletion discordgsm/protocols/ut3.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def query(self):
'numbots': 0,
'maxplayers': int(info['maxplayers']),
'players': [{'name': player['player'], 'raw': player} for player in players],
'bots': [],
'bots': None,
'connect': f"{host}:{info.get('hostport', port)}",
'ping': ping,
'raw': info
Expand Down
2 changes: 1 addition & 1 deletion discordgsm/protocols/vcmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def get_players():
'numbots': 0,
'maxplayers': status['maxplayers'],
'players': players,
'bots': [],
'bots': None,
'connect': f'{host}:{port}',
'ping': ping,
'raw': status
Expand Down
6 changes: 5 additions & 1 deletion discordgsm/styles/large.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def embed(self) -> Embed:
return embed

def add_player_list_fields(self, embed: Embed, field_name: str, players: List[GamedigPlayer]):
if players is None:
embed.add_field(name=field_name, value='The game does not support this feature.')
return embed

empty_value = '*​*'
filtered_players = [
player for player in players if player['name'].strip()]
Expand All @@ -39,7 +43,7 @@ def add_player_list_fields(self, embed: Embed, field_name: str, players: List[Ga
player_count = 0

for i, player in enumerate(filtered_players):
name = player['name'].ljust(23)[:23]
name = player['name'][:23]

if len(player['name']) > 23:
name = name[:-3] + '...'
Expand Down
4 changes: 2 additions & 2 deletions discordgsm/styles/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ def set_footer(self, embed: Embed):
embed.set_footer(text=f'DiscordGSM {__version__} | {advertisement} | {last_update}', icon_url=icon_url)

def set_image_and_thumbnail(self, embed: Embed):
image_url = self.server.style_data.get('image_url', '')
thumbnail_url = self.server.style_data.get('thumbnail_url', '')
image_url = str(self.server.style_data.get('image_url', ''))
thumbnail_url = str(self.server.style_data.get('thumbnail_url', ''))

if image_url.startswith('http://') or image_url.startswith('https://'):
embed.set_image(url=image_url)
Expand Down

0 comments on commit 7f63909

Please sign in to comment.