pyplanet.contrib.chat

Sending chat messages

We implemented an abstraction that will provide auto multicall and auto prefixing for you. You can use the following statements for example:

# Send chat message to all players.
await self.instance.chat('Test')

# Send chat message to specific player or multiple players.
await self.instance.chat('Test', 'player_login')  # Sends to single player.
await self.instance.chat('Test', 'player_login', player_instance)  # Sends to both players.

# Execute in chain (Multicall).
await self.instance.chat.execute(
  'global_message',
  self.instance.chat('Test', 'player_login'),
  self.instance.chat('Test2', 'player_login2'),
)

# You can combine this with other calls in a GBX multicall:
await self.instance.gbx.multicall(
  self.instance.gbx.prepare('SetServerName', 'Test'),
  self.instance.chat('Test2', 'player_login2'),
)

API Documentation

The chat contrib makes it possible to send chat messages way more easy and faster. It also maintains some other features related to the chat.

class pyplanet.contrib.chat.ChatManager(instance)[source]

The Chat manager is available with: instance.chat shortcut.

execute(*queries)[source]

Execute and send one or multiple chat messages (prepared queries or raw strings) with a multicall.

Parameters

queries – One or more query instances or one or multiple strings that gets send as global messages.

Returns

The results of the multicall.

prepare(message=None, raw=False)[source]

Prepare a Chat Query by returning a Chat Query object.

Parameters
  • message – Messsage predefined or build later.

  • raw – Don’t append prefixes or add any automatic message parts.

Returns

Query instance

Return type

pyplanet.contrib.chat.query.ChatQuery

prepare_raw(message=None)[source]

Prepare raw message query without prefixes!

Parameters

message – Predefined message.

Returns

Query instance

Return type

pyplanet.contrib.chat.query.ChatQuery