openbots

module
v1.17.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2024 License: MIT

README

Telegram Bot framework with declarative YAML specification.

CI Docker Pulls

Example

Write bot specification in bot.yml file:

bot:
  handlers:
    - on:
        message:
          command: start
      reply:
        - message:
            text: Hello
            markup:
              keyboard:
                - ["Hello!"]
                - ["How are you?"]
    - on:
        message: "Hello!"
      reply:
        - message:
            text: "Hi!"
    - on:
        message: "How are you?"
      reply:
        - message:
            text: "I'm fine, thank you"

Create new Telegram bot and get its token: https://core.telegram.org/bots#6-botfather

Provide this token to docker image as BOT_TOKEN environment.

Run your bot:

docker run \
    -v $PWD/bot.yml:/w/config.yml \
    --env BOT_TOKEN="$BOT_TOKEN" \
    g4s8/openbots:latest

Quick start

See quick start guide to create Telegram bot in minutes.

Documentation

The full documentation is available here: g4s8.github.io/openbots/documentation.

About

This is a Telegram bot framework which allows you to write low-code bot project. You delcare the bot in YAML specification file and start the bot using CLI or Docker image.

Full feature list:

  • handle text messages
  • handle bot commands
  • handle inline queries callbacks (buttons)
  • reply with text messages
  • reply callbacks
  • reply with inline buttons
  • change keyboard layout (reply markup)
  • reply with Markup, MarkupV2, HTML messages
  • switch context, handle context-based updates
  • keep state data and interpolate state in replies
  • edit message
  • reply with images
  • handle image messages
  • delete messages
  • API:
    • send message to particular user
  • call webhook on update
  • database storage
  • payments
  • validation
  • state operations

Persistence

Bot can keep its state in two modes:

  • memory - store all data in memory
  • database - connect PostgreSQL database

For persistence configuration see documentation.

Extending

This bot could be extended with custom handlers on Go.

Directories

Path Synopsis
cmd
bot
internal
db
pkg
api
Package api exposes HTTP API for bot service.
Package api exposes HTTP API for bot service.
bot
log
Package log provides logging tools for bot.
Package log provides logging tools for bot.
types
Package types provides base public types used by bot.
Package types provides base public types used by bot.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL