Skip to content

Commit

Permalink
feat: add kick_survivor.py example (#6)
Browse files Browse the repository at this point in the history
Co-authored-by: thegamecracks <61257169+thegamecracks@users.noreply.github.com>
  • Loading branch information
Draowyr and thegamecracks committed Apr 6, 2024
1 parent ae821eb commit 4d820ef
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions examples/kick_survivor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Connects to an RCON server and kicks players with "Survivor" as their name."""
import asyncio
import math
import re

import berconpy as rcon

IP_ADDR = "XXX.XXX.XXX.XXX"
PORT = 9999
PASSWORD = "ASCII_PASSWORD"

client = rcon.AsyncRCONClient()


@client.dispatch.on_player_connect
async def on_player_connect(player: rcon.Player):
if re.match(r"Survivor(?: \(\d+\))?", player.name) is not None:
await player.kick("Name 'Survivor' not allowed")


async def main():
async with client.connect(IP_ADDR, PORT, PASSWORD):
await asyncio.sleep(math.inf)


if __name__ == "__main__":
asyncio.run(main())

0 comments on commit 4d820ef

Please sign in to comment.