bokkichat.connection.impl package

Submodules

bokkichat.connection.impl.CliConnection module

class bokkichat.connection.impl.CliConnection.CliConnection(settings: bokkichat.settings.Settings.Settings)

Bases: bokkichat.connection.Connection.Connection

Class that implements a CLI connection which can be used in testing

property address: bokkichat.entities.Address.Address

A CLI connection has no real entities, so a dummy entities is generated. :return: The entities of the connection

close()

Disconnects the Connection. :return: None

classmethod name()str

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

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

A CLI Connection receives messages by listening to the input :return: A list of pending Message objects

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

Prints a “sent” message :param message: The message to “send” :return: None

classmethod settings_cls()Type[bokkichat.settings.impl.CliSettings.CliSettings]

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

bokkichat.connection.impl.TelegramBotConnection module

class bokkichat.connection.impl.TelegramBotConnection.TelegramBotConnection(settings: bokkichat.settings.impl.TelegramBotSettings.TelegramBotSettings)

Bases: bokkichat.connection.Connection.Connection

Class that implements a Telegram bot connection

__init__(settings: bokkichat.settings.impl.TelegramBotSettings.TelegramBotSettings)

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

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.impl.TelegramBotSettings.TelegramBotSettings]

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

Module contents