Skip to main content

Asynchronous implementation of the Hell Let Loose RCON protocol

Project description

hllrcon - Hell Let Loose RCON

Release PyPI Branch Coverage License GitHub contributors GitHub issues GitHub pull requests GitHub stars


hllrcon is an asynchronous Python implementation of the Hell Let Loose RCON protocol.
It allows you to interact with your HLL servers programmatically, supporting modern Python async features and robust error handling.

Features

  • Full async/await support
  • Command execution and response parsing
  • Collection of vanilla maps, factions, weapons, and more
  • Alternative interfaces for synchronous applications
  • Well-typed and tested

Installation

pip install hllrcon

Usage

import asyncio
from hllrcon import Rcon, Layer


async def main():
    # Initialize client
    rcon = Rcon(
        host="127.0.0.1",
        port=12345,
        password="your_rcon_password",
    )

    # Send commands. The client will (re)connect for you.
    await rcon.broadcast("Hello, HLL!")
    await rcon.change_map(Layer.STALINGRAD_WARFARE_DAY)
    players = await rcon.get_players()

    # Close the connection
    rcon.disconnect()


    # Alternatively, use the context manager interface to avoid
    # having to manually disconnect.
    async with rcon.connect():
        assert rcon.is_connected() is True
        await rcon.broadcast("Hello, HLL!")


if __name__ == "__main__":
    # Run the program
    asyncio.run(main())

For integration of synchronous applications, a SyncRcon class is provided.

from hllrcon.sync import SyncRcon

rcon = SyncRcon(
    host="127.0.0.1",
    port=12345,
    password="your_rcon_password",
)

# Connect and send a broadcast message
with rcon.connect():
    rcon.broadcast("Hello, HLL!")

The library contains a swathe of details about in-game maps, factions, weapons, vehicles, and more. Below is just an example of what it might be used for.

from hllron import Weapon

# Find a weapon by its ID
weapon_id = "COAXIAL M1919 [Stuart M5A1]"
weapon = Weapon.by_id(weapon_id)

# Print out whichever vehicle seat the attacker must have been in, if any
if weapon.vehicle:
    for seat in weapon.vehicle.seats:
        if weapon in seat.weapons:
            print("This weapon belongs to the", seat.type.name, "seat")
            break
from hllrcon import Rcon, Map, Team

# Get the AA Network capture zone (SMDM, 3rd sector, 2nd capture zone)
sector = Layer.STMARIEDUMONT_WARFARE_DAY.sectors[2]
capture_zone = sector.capture_zones[1]
assert capture_zone.strongpoint.name == "AA Network"

# Get the current online players
rcon = Rcon(...)
players = await rcon.get_players()

# Calculate each team's capture strength towards the sector
strength = {Team.ALLIES: 0, Team.AXIS: 0}
for player in players.players:
    if player.faction is None:
        continue

    if player.world_position == (0.0, 0.0, 0.0):
        # Player is dead. Note: Does not exclude players bleeding out
        continue

    # Grant 3 strength if inside the strongpoint
    if capture_zone.strongpoint.is_inside(player.world_position):
        strength[player.faction.team] += 3

    # Only grant 1 strength if inside the capture zone
    elif capture_zone.is_inside(player.world_position):
        strength[player.faction.team] += 1

# Print out the results
print("Allied cap weight:", strength[Team.ALLIES])
print("Axis cap weight:", strength[Team.AXIS])

Versioning

This project largely follows Semantic Versioning principles, i.e. MAJOR.MINOR.PATCH, with one notable difference in what can be guaranteed.

The SemVer specification states that breaking changes must only be implemented in major versions, whereas this library will have breaking changes in minor versions. Therefore, backwards compatibility cannot be guaranteed for minor releases.

  • MAJOR - Reserved for when sweeping changes need to happen to the library.
  • MINOR - Incremented whenever significant or breaking changes have to be made to the library, including adding support for major Hell Let Loose updates.
  • PATCH - Incremented for bug fixes and small game updates, generally guaranteeing backwards compatibility.

License

This project is licensed under the MIT License. See LICENSE for details.

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

hllrcon-1.0.1.tar.gz (142.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hllrcon-1.0.1-py3-none-any.whl (77.9 kB view details)

Uploaded Python 3

File details

Details for the file hllrcon-1.0.1.tar.gz.

File metadata

  • Download URL: hllrcon-1.0.1.tar.gz
  • Upload date:
  • Size: 142.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hllrcon-1.0.1.tar.gz
Algorithm Hash digest
SHA256 47e2913675f010ceaedf3d51df1f9213857f99c3aba6d002fcb534d7a30bf4a4
MD5 d3f63fff0a2037ef6611544e901cbaf3
BLAKE2b-256 ce81db1f40c6836b70cd534a19ce2b5c767500d3a06f65a4af4f014fca604f6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for hllrcon-1.0.1.tar.gz:

Publisher: python-publish.yaml on timraay/hllrcon

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hllrcon-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: hllrcon-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 77.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hllrcon-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c4e0ba877c8e8c417627cc171084309e1f7e03d8afa21ba197477af1e8590aab
MD5 0d9a929c2b1a2efcd33497ed98b8cafa
BLAKE2b-256 c383aecd5e5e17e299766d0a20881fe4e7314d3c42720ac06341be0934b81fc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for hllrcon-1.0.1-py3-none-any.whl:

Publisher: python-publish.yaml on timraay/hllrcon

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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