blab_chatbot_bot_client.data_structures#

Contains definitions of useful data structures and enums.

Module Contents#

Classes#

MessageType

Represents a message type.

Message

Represents a message with data received from BLAB Controller.

OutgoingMessage

Represents a message that the bot will send to BLAB Controller.

class MessageType(*args, **kwds)#

Bases: enum.Enum

Represents a message type.

SYSTEM = 'S'#

System message

TEXT = 'T'#

Text message

VOICE = 'V'#

Voice message (recorded ad hoc)

AUDIO = 'a'#

Message with audio file

VIDEO = 'v'#

Message with video file

IMAGE = 'i'#

Message with video file

ATTACHMENT = 'A'#

Message with arbitrary attachment

class Message#

Represents a message with data received from BLAB Controller.

id: str#

Id of the message

time: datetime.datetime#

When the message was sent

type: MessageType#

Type of the message

sent_by_human: bool#

Whether the message was sent by a human user

options: list[str] | None#

List of options from which the user can choose, if any

local_id: str | None#

Local id of the message (generated by the sender)

text: str | None#

Text of the message, if any

sender_id: str | None#

Id of the message sender, if any

additional_metadata: dict[str, Any] | None#

Additional metadata (used in system messages)

event: str | None#

Event type (used in system messages instead of text)

quoted_message_id: str | None#

Id of the quoted message, if any

__post_init__()#
Return type:

None

classmethod from_dict(d)#

Create an instance using data from a dict.

Unknown or unsupported fields are ignored.

Parameters:

d (dict[str, Any]) – dictionary with the message data

Returns:

an instance with the provided data

Return type:

Message

class OutgoingMessage#

Represents a message that the bot will send to BLAB Controller.

local_id: str#

Local id of the message (generated by the sender)

type: MessageType#

Type of the message

text: str | None#

Text of the message, if any

quoted_message_id: str | None#

Id of the quoted message, if any

command: str | None#

Command embedded in the message (only for manager bots)

options: list[str]#

List of options from which the user can choose, if any

external_file_url: str | None#

URL of the external file attached to the message

to_dict()#

Generate a dict with the data in this message.

Returns

a dict with the values in this instance

Return type:

dict[str, Any]