Skip to main content

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 is 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:

KeyboardNode(
    title="/start",
    text="Hello! Here is your keyboard.",
    buttons=[
        TextNode(title="About bot", text="*about*"),
        ImageNode(title="Bot logo", path="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 - 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 KeyboardNode, 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).

About usage

Note NodeDict imports

If my_node.py contains your node, you must import NodeDict in this file, and then import NodeDict from my_node.py to file with bot.

If your node and your bot are placed in one file, you only need to use from textode import NodeDict.

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

textode-1.3.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

textode-1.3.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file textode-1.3.1.tar.gz.

File metadata

  • Download URL: textode-1.3.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for textode-1.3.1.tar.gz
Algorithm Hash digest
SHA256 f7207028563c01e2931005db951d223aa1302d9ce6f3889b458f98b3ee56d690
MD5 b59342f63379a3b2cbd1a0e799dc92ae
BLAKE2b-256 03741783ddebabc2318c7bcaf06c2557329de7c06279b5285f35038019863719

See more details on using hashes here.

File details

Details for the file textode-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: textode-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for textode-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0b834bbbfe916de5e940875e5b22ccaffacb9cbd350f6e1f13e514dc28880152
MD5 0fb3e83c5990f650e692cdf76019dd9d
BLAKE2b-256 abdfa48ea9de86ea33d6b242cd0d222b227f4f19ac49bf75cbe13c1751a0b8f3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page