berconpy.player.Player

class berconpy.player.Player(cache, id, name, guid, addr, ping, is_guid_valid, in_lobby)

Bases: ABC

Represents a player in the server.

Methods

ban_guid([duration, reason])

Bans this player from the server using their GUID.

ban_ip([duration, reason])

Bans this player from the server using their IP.

is_connected()

Checks if this player is still in the client's cache.

kick([reason])

Kicks this player from the server.

send(message)

Sends a message to this player.

Attributes

id

The ID assigned to this player by the server.

name

The player's name.

guid

The player's GUID.

addr

The IP address and port this player connected from.

ping

The player's ping on the server.

is_guid_valid

Whether the server has confirmed the validity of this player's GUID.

in_lobby

Whether the player is in the server lobby or not.

cache

The cache that created this object.

client

Returns the client associated with the cache.

ip

Returns the IP address of the player.

abstract ban_guid(duration=None, reason='')

Bans this player from the server using their GUID.

Parameters:
  • duration (Optional[int]) – How long the player should be banned. Can be None to indicate a permanent ban.

  • reason (str) – The reason to display when the player is banned.

Return type:

Union[str, Awaitable[str]]

Returns:

The response from the server, if any.

abstract ban_ip(duration=None, reason='')

Bans this player from the server using their IP.

Parameters:
  • duration (Optional[int]) – How long the player should be banned. Can be None to indicate a permanent ban.

  • reason (str) – The reason to display when the player is banned.

Return type:

Union[str, Awaitable[str]]

Returns:

The response from the server, if any.

abstract is_connected()

Checks if this player is still in the client’s cache.

Return type:

bool

abstract kick(reason='')

Kicks this player from the server.

Parameters:

reason (str) – The reason to display when kicking the player.

Return type:

Union[str, Awaitable[str]]

Returns:

The response from the server, if any.

abstract send(message)

Sends a message to this player.

Parameters:

message (str) – The string to use as the message.

Return type:

Union[str, Awaitable[str]]

Returns:

The response from the server, if any.

addr: str

The IP address and port this player connected from.

property cache: RCONClientCache

The cache that created this object.

property client: RCONClient | None

Returns the client associated with the cache.

guid: str

The player’s GUID. This may be an empty string if the client has not yet received the GUID from the server.

id: int

The ID assigned to this player by the server.

in_lobby: bool

Whether the player is in the server lobby or not.

This data is only accurate after calling the RCONClient.fetch_players() method since it cannot be determined during connection.

property ip: str

Returns the IP address of the player.

This property is derived from addr.

is_guid_valid: bool

Whether the server has confirmed the validity of this player’s GUID.

name: str

The player’s name.

ping: int | None

The player’s ping on the server.

This data may not be available or may be out-of-date since it is only provided when the RCONClient.fetch_players() is called.