Skip to main content

Typed router for chatbot

Project description

ruff status workflow test status workflow build

Downloads Downloads Downloads

Chatrouter is an enhanced router for chatbots and easily integrates with any bot library.

key features

  1. turned complexity into simplicity.

from:

if user_session == "A":
    ...
elif user_session == "B":
    ...
elif user_session == "C":
    ...
else:
    ...

to:

chatbot = chatrouter.group(user_session)
r = chatrouter.run(chatbot, msg)
  1. Readable route.
@chatbot.add_command("call me {my_name}")
# or 
chatbot.add_command("call me {my_name} and {my_friend}")
# etc
  1. case sensitive and insensitive.

default case is insensitive but you can add strict=True to a route/command to make it case sensitive.

  1. public and private command.

command start with "/" and have description is public command, for example:

@chatbot.add_command("/test", description="test command", strict=True)
  1. invoke callback anywhere.
func = chatrouter.util.get_func("group_name", "command_name")

or

chatrouter.invoke("group", "route", *args, **kwargs)
  1. auto generated /start and /help command.

  2. object storage chatrouter.data_user.

  3. support route with regex.

  4. support autoloader chatrouter.autoloader("path").

  5. support Asynchronous.

  6. typed python.

installation

pip install chatrouter

Usage

for usage, please see examples directory.

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

chatrouter-1.0.8.tar.gz (7.2 kB view details)

Uploaded Source

File details

Details for the file chatrouter-1.0.8.tar.gz.

File metadata

  • Download URL: chatrouter-1.0.8.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.0

File hashes

Hashes for chatrouter-1.0.8.tar.gz
Algorithm Hash digest
SHA256 7465cb60f9fb176eeaf203164fb601f8bac8dfbffd1878fb2cdffb947e7221c2
MD5 80dcc211c23c76b583a049735a4e71ee
BLAKE2b-256 5ed951936c61e50a708c18934f99ea959d42c4683b4e969983819b5ebfb0966f

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