Chatrouter is an enhanced router for chatbots and easily integrates with any bot library.
key features
- 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)
- Readable route.
@chatbot.add_command("call me {my_name}") # or chatbot.add_command("call me {my_name} and {my_friend}") # etc
- case sensitive and insensitive.
default case is insensitive but you can add strict=True to a route/command to make it case sensitive.
- public and private command.
command start with "/" and have description is public command, for example:
@chatbot.add_command("/test", description="test command", strict=True)- invoke callback anywhere.
func = chatrouter.util.get_func("group_name", "command_name")
or
chatrouter.invoke("group", "route", *args, **kwargs)
-
auto generated
/startand/helpcommand. -
object storage
chatrouter.data_user. -
support route with regex.
-
support autoloader
chatrouter.autoloader("path"). -
support Asynchronous.
-
typed python.
installation
Usage
for usage, please see examples directory.