Skip to main content

squadrcon

CI PyPI Python versions License: MIT

Lightweight RCON client and CLI for Squad game servers. Pure Python, zero runtime dependencies.

Features

  • Connect and authenticate over Squad's RCON protocol
  • List players / squads with parsed, typed output
  • Kick, ban, warn, and switch a player's team
  • Live event stream for chat, kicks, bans, warns
  • Small CLI for quick server admin from the terminal
  • Fully type-hinted, ships a py.typed marker

Install

pip install squadrcon

From source:

git clone https://github.com/g0vguy/squadrcon.git
cd squadrcon
pip install .

CLI usage

squadrcon --host 1.2.3.4 --port 27165 --pass yourRconPass --list
squadrcon --host 1.2.3.4 --port 27165 --pass yourRconPass --kick "PlayerName" --reason "Team killing"
squadrcon --host 1.2.3.4 --port 27165 --pass yourRconPass --kick 76561198000000000 --reason "AFK"
squadrcon --host 1.2.3.4 --port 27165 --pass yourRconPass --switch-team "PlayerName"

Env vars work too:

export SQUAD_HOST=1.2.3.4
export SQUAD_PORT=27165
export SQUAD_PASS=yourRconPass
squadrcon --list

Library usage

from squadrcon import Rcon, RconConfig, events

r = Rcon(RconConfig(host="127.0.0.1", password="123456", port="27165"))

r.emitter.on(events.CHAT_MESSAGE, lambda msg: print("chat:", msg))
r.emitter.on(events.PLAYER_KICKED, lambda k: print("kicked:", k.player_name))

players = r.list_players()
for p in players.players:
    print(p.name, p.steam_id, p.team_id, p.squad_id)

r.kick("SomePlayerName", "AFK")
r.ban("76561198000000000", "1d", "Team killing")
r.switch_team("SomePlayerName")

r.close()

More runnable examples are in examples/:

API overview

Method RCON command Description
list_players() ListPlayers Returns a Players object with parsed Player entries
list_squads() ListSquads Returns a Squads object with parsed Squad entries
kick(target, reason) AdminKick Kicks by name or SteamID64
ban(target, duration, reason) AdminBan Bans by name or SteamID64
warn(target, message) AdminWarn Sends an in-game warning
switch_team(target) AdminForceTeamChange Moves a player to the opposite team
execute(command) any Sends a raw RCON command, returns raw text

Events available on r.emitter:

CONNECTED, RECONNECTING, CLOSE, ERROR, DATA, CHAT_MESSAGE, PLAYER_WARNED, PLAYER_KICKED, PLAYER_BANNED

Layout

squadrcon/
  protocol.py   packet framing
  emitter.py    event emitter
  events.py     event name constants
  types.py      parsed data classes
  parsers.py    text -> object parsers
  client.py     the rcon client
  cli.py        command line tool (entry point: squadrcon)
tests/          pytest suite
examples/       runnable usage examples

Development

pip install -e ".[dev]"
pytest
ruff check .

See CONTRIBUTING.md.

Notes

Player/squad list parsing and broadcast-line parsing are regex based, matched against Squad's current RCON text output format. If your server version formats things differently, parsers.py is the place to adjust — please open an issue with a raw sample line and it'll get fixed.

License

MIT — see LICENSE.

Download files

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

Source Distribution

squadrcon-0.1.0.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

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

squadrcon-0.1.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file squadrcon-0.1.0.tar.gz.

File metadata

  • Download URL: squadrcon-0.1.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for squadrcon-0.1.0.tar.gz
Algorithm Hash digest
SHA256 35fdaadf61641ca7fa9e7012b343ff3503a4e9ccd4cb2cfd420c95ce56d54ef1
MD5 ce2f375398bad8deb921899ebc7b69a4
BLAKE2b-256 0a019930d48c74710b57bf477ea114fdf9641bd2198c6458f2782ade2ec8d112

See more details on using hashes here.

File details

Details for the file squadrcon-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: squadrcon-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for squadrcon-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ac68b912d7f72e3a0423a600c0bb9e50b2b08ffe79e3ffd46521f8801ab4a7c
MD5 68c94a858f8b4fd7ae96aa9f289a92a2
BLAKE2b-256 763a5106c64b913bd109d392ebde4668968d83b5dea847c3dd9197222b47494b

See more details on using hashes here.

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