rcon


Namercon JSON
Version 2.4.9 PyPI version JSON
download
home_pagehttps://github.com/conqp/rcon
SummaryAn RCON client library.
upload_time2024-11-05 18:26:59
maintainerNone
docs_urlNone
authorRichard Neumann
requires_python>=3.10
licenseGPLv3
keywords python rcon client
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Documentation Status](https://readthedocs.org/projects/rcon/badge/?version=latest)](https://rcon.readthedocs.io/en/latest/)

# rcon
An RCON client implementation.
* [Source RCON protocol](https://developer.valvesoftware.com/wiki/Source_RCON_Protocol)
* [BattlEye RCon protocol](https://www.battleye.com/downloads/BERConProtocol.txt)

## Requirements
`rcon` requires Python 3.10 or higher.

## Documentation
Documentation is available on [readthedocs](https://rcon.readthedocs.io/en/latest/).

## Installation
Install rcon from the [AUR](https://aur.archlinux.org/packages/python-rcon/) 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
```python
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()`.

```python
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
```python
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:

```python
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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/conqp/rcon",
    "name": "rcon",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "python rcon client",
    "author": "Richard Neumann",
    "author_email": "mail@richard-neumann.de",
    "download_url": "https://files.pythonhosted.org/packages/e4/45/edde086b16cd38591794d328ef62c47f089ac04f32a63b4fcab0981d349a/rcon-2.4.9.tar.gz",
    "platform": null,
    "description": "[![Documentation Status](https://readthedocs.org/projects/rcon/badge/?version=latest)](https://rcon.readthedocs.io/en/latest/)\n\n# rcon\nAn RCON client implementation.\n* [Source RCON protocol](https://developer.valvesoftware.com/wiki/Source_RCON_Protocol)\n* [BattlEye RCon protocol](https://www.battleye.com/downloads/BERConProtocol.txt)\n\n## Requirements\n`rcon` requires Python 3.10 or higher.\n\n## Documentation\nDocumentation is available on [readthedocs](https://rcon.readthedocs.io/en/latest/).\n\n## Installation\nInstall rcon from the [AUR](https://aur.archlinux.org/packages/python-rcon/) or via:\n\n    pip install rcon\n\n## Quick start\nThe `RCON` protocols are used to remotely control game servers, i.e. execute\ncommands on a game server and receive the respective results.\n\n### Source RCON\n```python\nfrom rcon.source import Client\n\nwith Client('127.0.0.1', 5000, passwd='mysecretpassword') as client:\n    response = client.run('some_command', 'with', 'some', 'arguments')\n\nprint(response)\n```\n\n#### Async support\nIf you prefer to use Source RCON in an asynchronous environment, you can use \n`rcon()`.\n\n```python\nfrom rcon.source import rcon\n\nresponse = await rcon(\n    'some_command', 'with', 'some', 'arguments',\n    host='127.0.0.1', port=5000, passwd='mysecretpassword'\n)\nprint(response)\n```\n\n### BattlEye RCon\n```python\nfrom rcon.battleye import Client\n\nwith Client('127.0.0.1', 5000, passwd='mysecretpassword') as client:\n    response = client.run('some_command', 'with', 'some', 'arguments')\n\nprint(response)\n```\n\n#### Handling server messages\nSince the BattlEye RCon server will also send server messages to the client \nalongside command responses, you can register an event handler to process \nthose messages:\n\n```python\nfrom rcon.battleye import Client\nfrom rcon.battleye.proto import ServerMessage\n\ndef my_message_handler(server_message: ServerMessage) -> None:\n    \"\"\"Print server messages.\"\"\"\n    \n    print('Server message:', server_message)\n\nwith Client(\n        '127.0.0.1',\n        5000,\n        passwd='mysecretpassword',\n        message_handler=my_message_handler\n) as client:\n    response = client.run('some_command', 'with', 'some', 'arguments')\n\nprint('Response:', response)\n```\n\nHave a look at `rcon.battleye.proto.ServerMessage` for details on the \nrespective objects.\n",
    "bugtrack_url": null,
    "license": "GPLv3",
    "summary": "An RCON client library.",
    "version": "2.4.9",
    "project_urls": {
        "Homepage": "https://github.com/conqp/rcon"
    },
    "split_keywords": [
        "python",
        "rcon",
        "client"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "69d32668a6e6bd6d66046ebe811f3fac65402620762e31f80b8f88661a7f3e42",
                "md5": "fb275fd9cb658d15efd19e94f1727020",
                "sha256": "c0d2477070f189a6b49774133c412473ece40bb452473f160c7373b162dc8929"
            },
            "downloads": -1,
            "filename": "rcon-2.4.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fb275fd9cb658d15efd19e94f1727020",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 31129,
            "upload_time": "2024-11-05T18:26:57",
            "upload_time_iso_8601": "2024-11-05T18:26:57.945132Z",
            "url": "https://files.pythonhosted.org/packages/69/d3/2668a6e6bd6d66046ebe811f3fac65402620762e31f80b8f88661a7f3e42/rcon-2.4.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e445edde086b16cd38591794d328ef62c47f089ac04f32a63b4fcab0981d349a",
                "md5": "468b73b1ad63e7ebaec788679551493b",
                "sha256": "d41a8311dc13352da35163f46a3cc13eb20f5cde1297b75b56e7645ef76d0a48"
            },
            "downloads": -1,
            "filename": "rcon-2.4.9.tar.gz",
            "has_sig": false,
            "md5_digest": "468b73b1ad63e7ebaec788679551493b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 45220,
            "upload_time": "2024-11-05T18:26:59",
            "upload_time_iso_8601": "2024-11-05T18:26:59.783869Z",
            "url": "https://files.pythonhosted.org/packages/e4/45/edde086b16cd38591794d328ef62c47f089ac04f32a63b4fcab0981d349a/rcon-2.4.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-05 18:26:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "conqp",
    "github_project": "rcon",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "rcon"
}
        
Elapsed time: 0.39575s