No description
| app | ||
| discordbot | ||
| kubernetes | ||
| .gitignore | ||
| build.sh | ||
| nations.ods | ||
| README.md | ||
| server_info.py | ||
| test_celery.py | ||
Reads connection information from a Dominions 6 server version 6.30
Direct usage
Direct usage example
from server_info import ServerInfo, NationInfoTurn
info = ServerInfo()
info.connect('my.dom5server.net', 1234) # supply host and port here
print(info) # prints game name, turn number and turn timer
for nation in info.nation_info.values():
print(nation)
if nation.turn != NationInfoTurn.played:
print(f"Nation {nation.nation_name} needs to do its turn")
Celery integration
For an integration in an existing celery queue use this setup
app = Celery(
"dominionsInformer",
broker="redis://celery-broker-redis:6379",
backend="redis://celery-broker-redis:6379",
)
app.conf.task_routes = {"dom6info.*": {"queue": "dom6info"}}
get_info = app.signature("dom6info.get_info")
and retrieve data with a call to the get_info with the supplied server and server password
serverinfo = get_info.delay(
server_name=dom_servername, password=dom_password
).get()
The returned data is structured in a map
server_info = {
"name": "name of the server",
"motto": "motd",
"turn": "current turn number",
"nations": {
"id": "internal nation id byte",
"name": "readable nation name case sensitive",
"motto": "nation title",
"playertype": "internal player info byte",
"playertype-text": "human or ai",
"turninfo": "internal turn info byte",
"turninfo-text": "open or done",
}
}