Giter Site home page Giter Site logo

aulasoftwarelibre / telegram-bot-template Goto Github PK

View Code? Open in Web Editor NEW
14.0 4.0 12.0 393 KB

Telegram Bot Template

License: European Union Public License 1.2

Python 92.39% Makefile 7.61%
pytelegrambotapi fastapi telegram telegram-bot tortoise-orm typer typer-cli

telegram-bot-template's Introduction

Telegram Bot Template

This project provides a template for creating a Telegram bot using Python. It includes a CLI for managing the bot, a web controller using FastAPI for webhook integration.

Local Installation

While the production environment can be hosted on an external server, a local development environment is also recommended for testing the bot. It is crucial not to share the same bot token for production and development. It is recommended that each team member creates their own development bot.

To install locally python3.10, and poetry installed.

Configuration

To configure the required variables locally, copy the following file:

cp .env.dist .env

Then, configure the BOT_TOKEN and SECRET_TOKEN variables. The WEBHOOK_HOST variable is only necessary if an external server is being used.

Settings Class

A Settings class is included that allows storing values in a table. You can specify the associated chat (chat), the name of the data (key), and its value (value). If you want data that exists for any chat, you can use 0 (zero) as the chat identifier.

Execution

Locally

The first step is to install the dependencies:

poetry install

Then, you can start the service in polling mode:

make dev

The bot should now be able to respond.

In a server

The first step is to install the dependencies:

poetry install

And configure the webhook to receive the updates:

make configure

Then, you can start the service in push mode:

make server

The bot should now be able to respond.

Commands

The bot supports the following commands. If anything else is sent, the bot will respond in echo mode (returns what is sent to it).

Command /start

Returns a greeting message.

References

For obtaining open APIs, you can refer to the following GitHub repository:

telegram-bot-template's People

Contributors

sgomez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

telegram-bot-template's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.