bokkichat.connection package

Subpackages

Submodules

bokkichat.connection.Connection module

class bokkichat.connection.Connection.Connection(settings: bokkichat.settings.Settings.Settings)

Bases: object

Class that defines methods a Connection must implement. A connection is the central class in bokkichat and handles all communications with the chat services.

__init__(settings: bokkichat.settings.Settings.Settings)

Initializes the connection, with credentials provided by a Settings object. :param settings: The settings for the connection

property address: bokkichat.entities.Address.Address

A connection must be able to specify its own entities :return: The entities of the connection

close()

Disconnects the Connection. :return: None

classmethod from_serialized_settings(serialized: str)bokkichat.connection.Connection.Connection

Generates a Connection using serialized settings :param serialized: The serialized settings :return: The generated connection

loop(callback: Callable, sleep_time: int = 1)

Starts a loop that periodically checks for new messages, calling a provided callback function in the process. :param callback: The callback function to call for each

received message. The callback should have the following format:

lambda connection, message: do_stuff()

Parameters

sleep_time – The time to sleep between loops

Returns

None

classmethod name()str

The name of the connection class :return: The connection class name

receive()List[bokkichat.entities.message.Message.Message]

Receives all pending messages. :return: A list of pending Message objects

send(message: bokkichat.entities.message.Message.Message)

Sends a message. A message may be either a TextMessage or a MediaMessage. :param message: The message to send :return: None

classmethod settings_cls()Type[bokkichat.settings.Settings.Settings]

The settings class used by this connection :return: The settings class

Module contents