Skip to main content

An RCON client library.

Project description

Documentation Status

rcon

An RCON client implementation.

Requirements

rcon requires Python 3.10 or higher.

Documentation

Documentation is available on readthedocs.

Installation

Install rcon from the AUR or via:

pip install rcon

Quick start

The RCON protocols are used to remotely control game servers, i.e. execute commands on a game server and receive the respective results.

Source RCON

from rcon.source import Client

with Client('127.0.0.1', 5000, passwd='mysecretpassword') as client:
    response = client.run('some_command', 'with', 'some', 'arguments')

print(response)

Async support

If you prefer to use Source RCON in an asynchronous environment, you can use rcon().

from rcon.source import rcon

response = await rcon(
    'some_command', 'with', 'some', 'arguments',
    host='127.0.0.1', port=5000, passwd='mysecretpassword'
)
print(response)

BattlEye RCon

from rcon.battleye import Client

with Client('127.0.0.1', 5000, passwd='mysecretpassword') as client:
    response = client.run('some_command', 'with', 'some', 'arguments')

print(response)

Handling server messages

Since the BattlEye RCon server will also send server messages to the client alongside command responses, you can register an event handler to process those messages:

from rcon.battleye import Client
from rcon.battleye.proto import ServerMessage

def my_message_handler(server_message: ServerMessage) -> None:
    """Print server messages."""
    
    print('Server message:', server_message)

with Client(
        '127.0.0.1',
        5000,
        passwd='mysecretpassword',
        message_handler=my_message_handler
) as client:
    response = client.run('some_command', 'with', 'some', 'arguments')

print('Response:', response)

Have a look at rcon.battleye.proto.ServerMessage for details on the respective objects.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rcon-2.4.9.tar.gz (45.2 kB view details)

Uploaded Source

Built Distribution

rcon-2.4.9-py3-none-any.whl (31.1 kB view details)

Uploaded Python 3

File details

Details for the file rcon-2.4.9.tar.gz.

File metadata

  • Download URL: rcon-2.4.9.tar.gz
  • Upload date:
  • Size: 45.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.7

File hashes

Hashes for rcon-2.4.9.tar.gz
Algorithm Hash digest
SHA256 d41a8311dc13352da35163f46a3cc13eb20f5cde1297b75b56e7645ef76d0a48
MD5 468b73b1ad63e7ebaec788679551493b
BLAKE2b-256 e445edde086b16cd38591794d328ef62c47f089ac04f32a63b4fcab0981d349a

See more details on using hashes here.

File details

Details for the file rcon-2.4.9-py3-none-any.whl.

File metadata

  • Download URL: rcon-2.4.9-py3-none-any.whl
  • Upload date:
  • Size: 31.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.7

File hashes

Hashes for rcon-2.4.9-py3-none-any.whl
Algorithm Hash digest
SHA256 c0d2477070f189a6b49774133c412473ece40bb452473f160c7373b162dc8929
MD5 fb275fd9cb658d15efd19e94f1727020
BLAKE2b-256 69d32668a6e6bd6d66046ebe811f3fac65402620762e31f80b8f88661a7f3e42

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page