Skip to content

Commit

Permalink
Support Ark: Survival Ascended
Browse files Browse the repository at this point in the history
Co-Authored-By: Kozejin <[email protected]>
  • Loading branch information
BattlefieldDuck and dkoz committed Nov 16, 2023
1 parent a33b5f3 commit 8372259
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
1 change: 1 addition & 0 deletions discordgsm/games.csv
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ arma3,ARMA 3 (2013),source,port=2302;port_query_offset=1
armacwa,ARMA: Cold War Assault (2011),gamespy1,port=2302;port_query_offset=1
armar,ARMA: Resistance (2011),gamespy1,port=2302;port_query_offset=1
armareforger,Arma Reforger (2022),source,port=2001;port_query=17777
asa,Ark: Survival Ascended (2023),asa,port=7777
assettocorsa,Assetto Corsa (2014),assettocorsa,port=9610
atlas,Atlas (2018),source,port=5761;port_query_offset=51800
avp2,Aliens versus Predator 2 (2001),gamespy1,port=27888
Expand Down
1 change: 1 addition & 0 deletions discordgsm/protocols/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# flake8: noqa
from .asa import ASA
from .ase import ASE
from .assettocorsa import AssettoCorsa
from .battlefield import Battlefield
Expand Down
45 changes: 45 additions & 0 deletions discordgsm/protocols/asa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import time
from typing import TYPE_CHECKING

import opengsq

from discordgsm.protocols.protocol import Protocol

if TYPE_CHECKING:
from discordgsm.gamedig import GamedigResult


class ASA(Protocol):
name = 'asa'

__client_id = 'xyza7891muomRmynIIHaJB9COBKkwj6n'
__client_secret = 'PP5UGxysEieNfSrEicaD1N2Bb3TdXuD7xHYcsdUHZ7s'
__deployment_id = 'ad9a8feffb3b4b2ca315546f038c3ae2'

async def query(self):
host, port = str(self.kv['host']), int(str(self.kv['port']))
eos = opengsq.EOS(host, port, self.timeout, self.__client_id,
self.__client_secret, self.__deployment_id)
start = time.time()
info = await eos.get_info()
ping = int((time.time() - start) * 1000)

# Credits: @dkoz https://github.com/DiscordGSM/GameServerMonitor/pull/54/files
attributes = dict(info.get('attributes', {}))
settings = dict(info.get('settings', {}))

result: GamedigResult = {
'name': attributes.get('CUSTOMSERVERNAME_s', 'Unknown Server'),
'map': attributes.get('MAPNAME_s', 'Unknown Map'),
'password': attributes.get('SERVERPASSWORD_b', False),
'numplayers': info.get('totalPlayers', 0),
'numbots': 0,
'maxplayers': settings.get('maxPublicPlayers', 0),
'players': None,
'bots': None,
'connect': attributes.get('ADDRESS_s', '') + ':' + str(port),
'ping': ping,
'raw': info
}

return result
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ backports.zoneinfo==0.2.1;python_version<"3.9"
discord.py==2.3.2
flask[async]==3.0.0
gunicorn==21.2.0
opengsq==2.1.2
opengsq==2.2.2
psycopg2-binary==2.9.9
pymongo==4.5.0
python-dotenv==1.0.0
Expand Down

0 comments on commit 8372259

Please sign in to comment.