Skip to main content

No project description provided

Project description


Python chat-bot framework. Uses very much concepts from django.


Current state

Under heavy development. Chaban supposed to be framework for developing bots for many platforms. Now working on telegram bots. Also this project needs to have strong CLI, which is also in development.


pip install chaban


Project structure

To bootstrap a new project, I recommend using cookiecutter.

pip install cookiecutter

For now, CLI is not developed, but I hope it will be available soon.

Now, run this command to get your chaban template:

cookiecutter gh:ibrag8998/cookiecutter-chaban

And answer to the question it asks :D.

The project looks like this:

+-- project_slug
|   +--
|   +--
|   +--
|   +--
+-- settings
|   +--
|   +--
|   +--
+-- requirements
|   +-- base.txt
|   +-- testing.txt
|   +-- local.txt
+-- scripts
|   +--
|   +--
+-- ...

Now run script to make .env file which stores some configuration and secret keys:

cd scripts
  • settings/ contains any settings you want, but there some required ones, like DEBUG. Put base settings in and development-only ones in, the rest will be done for you. How? Read settings/ file.

  • requirements/ contains separate requirements. base.txt are base, project will not work without them. testing.txt only used for tests. local.txt contains requirements for direct developer, for example: linter, formatter.

  • scripts/ contains bash scripts to manage your project.

  • is a file that you will run to start up your bot.

  • project_slug/ is actual core:

    • contains message handlers.
    • contains logic that will be invoked by message handler.
    • contains text snippet to send in messages.

Actual code

First, define a message handler in like this:

from chaban.handlers import CommandMH

class StartCommandMH(CommandMH):
    command = 'start'

Now, when a message comes, and your handler looks like the message can be handled by it (checked by using regex, more info in source code), the action will be called. But wait. We didn't define any action! Head over to and add one:

from chaban.actions import Action

class StartCommandAction(Action):
    def act(self, message: dict) -> None:
        self.tbot.send_message(message['chat']['id'], 'Welcome!')

Well, action is defined, now let's link the handler with the action. Open file and action attribute like this:

from .actions import StartCommandAction

class StartCommandMH(CommandMH):
    action = StartCommandAction()

That's all for basics :D. Now open up your terminal and start bot:


Write to your bot with message "/start" and see it works.


Please, help.

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

chaban-0.1.1.tar.gz (9.5 kB view hashes)

Uploaded Source

Built Distribution

chaban-0.1.1-py3-none-any.whl (12.3 kB view hashes)

Uploaded Python 3

Supported by

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