An asynchronous interface for the Source RCON Protocol.
The easiest way is to install via pip:
pip install aiorcon
Using aiorcon is pretty simple. First you have to create a RCON Object with the create method. The RCON Object itself is now callable with the command you want to send. After awaiting the call you get the output of the command.
import aiorcon
import asyncio
async def main(loop):
# initialize the RCON connection with ip, port, password and the event loop.
rcon = await aiorcon.RCON.create("192.168.2.137", 27015, "rconpassword", loop)
# send a command
stats = await(rcon("stats"))
print(stats)
# close the connection in the end
rcon.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(main(loop))