A python library for various chat services
Bokkichat is a python library that offers unified interfaces for interacting with different chat services.
As an example, it could be used to write a bot for both Whatsapp and Telegram without many service-specific alterations.
A project that extends this idea is kudubot.
Implemented Connection Types
Currently the following connection types are supported out of the box:
- Telegram (Bot)
Installing bokkichat is as simple as running
pip install bokkichat, or
python setup.py install when installing from source.
First, you'll need to initialize the correct Settings object, which can then be used to initialize the Connection.
from bokkichat.settings.impl.TelegramBotSettings import TelegramBotSettings from bokkichat.connection.impl.TelegramBotConnection import TelegramBotConnection settings = TelegramBotSettings("APIKEY") connection = TelegramBotConnection(settings)
Afterwards, you can send, receive and loop using the Connection object.
# Sending a message from bokkichat.settings.impl.TelegramBotSettings import TelegramBotSettings from bokkichat.connection.impl.TelegramBotConnection import TelegramBotConnection from bokkichat.entities.message.TextMessage import TextMessage from bokkichat.entities.Address import Address settings = TelegramBotSettings("APIKEY") connection = TelegramBotConnection(settings) receiver = Address("12345678") msg = TextMessage(connection.address, receiver, "BODY", "TITLE") connection.send(msg)
# Echo every received message from bokkichat.settings.impl.TelegramBotSettings import TelegramBotSettings from bokkichat.connection.impl.TelegramBotConnection import TelegramBotConnection from bokkichat.connection.Connection import Connection from bokkichat.entities.message.Message import Message settings = TelegramBotSettings("APIKEY") connection = TelegramBotConnection(settings) def echo(con: Connection, msg: Message): reply = msg.make_reply() con.send(reply) connection.loop(echo)
Implementing your own connection type
If the connection type you want to use is not implemented by bokkichat itself, you can always implement it yourself. To do so, you will need to implement two classes.
First off, you'll need to implement a subclass of the
and implement its abstract methods. Take a look at the implementation of
various Settings classes
for some inspiration.
The Settings class defines the authentication information required for the bot to function.
Afterwards, a subclass of the
Connection class must be implemented.
Again, implement the abstract methods and let yourself be inspired by
The Connection class defines how to communicate with the service itself.
These two classes define everything that's needed for a bokkichat connection.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size bokkichat-0.4.1-py3-none-any.whl (36.6 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size bokkichat-0.4.1.tar.gz (10.4 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for bokkichat-0.4.1-py3-none-any.whl