Skip to content

cirebon-dev/chatrouter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.