Make your text-bot with only one handler.
Project description
textode
Textode is a simple tool to create text bots with only one handler. You can use it for Telegram, VK or any other social network.
What is it for
Textode helps you build static text bots.
Static text bots are bots that has concrete structure, like instruction on the pill bottle or a movie script. So, perfect examples of what you can do with this library is instruction bots, text quests, and so on.
What is it not for
It is not designed to build bots that use data provided by user (e.g. store user age).
What is the idea
In textode the main part of the bot is Node. It used to build bot structure.
For example, this is the basic bot in textode:
Keyboard(
"Hello! Here is your keyboard.",
buttons={
"About bot": Text("*about*"),
"Bot logo": Image("logo.png"),
},
)
With this structure bot handles "/start" message, responses with "Hello! Here is your keyboard." text and keyboard of two buttons - "About bot" that sends text about bot and "Bot logo" that sends image of bot logo.
The main advantage of this approach is that your bot is now defined by concrete schema. Instead of making handlers you are designing Node structure.
Another advantage is that instead of many handlers you now have one. It works because of Node identity, they all have the same basic fields:
- title (by parent) - message text that triggers node.
- text - text that sends back.
Because of that, you need to make only one handler that picking right node (depends on user input), handles if there is no node with this text, or handles node type (sends keyboard for Keyboard, image for ImageNode etc.).
Installation
via pip:
pip install textode
or poetry:
poetry add textode
Examples
Look here for usage examples (aiogram and vkbottle are presented) with schemas (built by Graphviz with JetBrains Mono font).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file textode-2.0.0.tar.gz
.
File metadata
- Download URL: textode-2.0.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95b17f826a0161873bd0d5112cea215de78d84e41a950051d1704476a7296630 |
|
MD5 | a1c7c8bdfc17f2c3af6f89a22a2eb157 |
|
BLAKE2b-256 | cef414701d376927032518ddf9ccfb6f5f59fd9979a02f01bcef2a9a262d8a9a |
File details
Details for the file textode-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: textode-2.0.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 634419d6ecc47b45db7deb5f202cf8079fb725c68c09edd89b401e2e022e76d6 |
|
MD5 | 6806d7ce6d749372739c8c2e24ddf158 |
|
BLAKE2b-256 | c578cfce2fa70bf2e9a306edcd4a39b693222164948a37ff458b4070d10eb381 |