chat.consumers#

Contains Websocket consumers.

Module Contents#

Classes#

ConversationConsumer

Websocket consumer for conversations and messages.

class ConversationConsumer(*args, **kwargs)#

Bases: channels.generic.websocket.AsyncWebsocketConsumer

Websocket consumer for conversations and messages.

async connect()#
Return type:

None

async deliver_message(event)#

Deliver message to this participant.

Parameters:

event (dict[str, Any]) – message represented as a dictionary

Return type:

None

async deliver_state(event)#

Deliver state data to this participant.

Parameters:

event (dict[str, Any]) – state represented as a dictionary

Return type:

None

async classmethod broadcast_state(conversation_id, state)#

Deliver state data to all participants.

Parameters:
  • conversation_id (str) – id of the conversation

  • state (dict[str, Any]) – state represented as a dictionary

Return type:

None

async classmethod broadcast_message(message, only_human=False)#

Send a message to all participants, possibly excluding bots.

Parameters:
  • message (Message) – message to be sent

  • only_human (bool) – do not send message to bots

Return type:

None

async classmethod deliver_message_to_bot(message, bot_name_or_participant_id, field_overrides=None)#

Deliver a message only to a bot.

Parameters:
  • message (Message) – message to be delivered

  • bot_name_or_participant_id (str) – bot name or the id of the participant

  • field_overrides (dict[str, Any] | None) – dict from field names to the values that should replace the actual values

Return type:

None

async classmethod deliver_message_to_bot_manager(message)#

Deliver a message to the bot manager.

Parameters:

message (Message) – message to be sent

Return type:

None

async disconnect(code)#

Called when a WebSocket connection is closed.

Parameters:

code (int) –

Return type:

None

async receive(text_data=None, bytes_data=None)#

Called with a decoded WebSocket frame.

Parameters:
  • text_data (str | None) –

  • bytes_data (bytes | None) –

Return type:

None