bokkichat
| master | develop |
|---|---|
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:
- CLI
- Telegram (Bot)
Installation
Installing bokkichat is as simple as running pip install bokkichat, or
python setup.py install when installing from source.
Usage
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.
Some examples:
# 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 Settings class
and implement its abstract methods. Take a look at the implementation of
various Settings classes
here
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
previous implementations
The Connection class defines how to communicate with the service itself.
These two classes define everything that's needed for a bokkichat connection.
Further Information
Metadata
Release files for bokkichat 0.4.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| bokkichat-0.4.5.tar.gz | 23.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bokkichat-0.4.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 60.4 kB
Release files / bokkichat-0.4.5.tar.gz
| Download URL | bokkichat-0.4.5.tar.gz |
|---|---|
| Size | 23.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b2a65d207ab2be2a6b61aac6ba3390a7e7c9609d426e1690d22e6c1811d94849
|
|
BLAKE2b-256 checksum How to use checksums |
0a7621ca0acf9211b449e8ca5d3f36abec4045ce2716f3af12153a7b384496f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10
|
Release files / bokkichat-0.4.5-py3-none-any.whl
| Download URL | bokkichat-0.4.5-py3-none-any.whl |
|---|---|
| Size | 36.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
115cb0f547fe14f5072b6b052864875c2f55937b38019851f6294a4cbf5ee547
|
|
BLAKE2b-256 checksum How to use checksums |
b33bcb64a0aa45e90dc06948eaca6be4a436ebb7863dbe4c2f192554187dee84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10
|
Security for bokkichat 0.4.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.