Giter Site home page Giter Site logo

snussik / telegram-bot-template Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bot-base/telegram-bot-template

0.0 0.0 0.0 572 KB

A starter Telegram bot template based on grammY and prisma

Shell 1.70% TypeScript 94.28% Dockerfile 3.12% Fluent 0.90%

telegram-bot-template's Introduction

๐Ÿค– Telegram Bot Template

Bot starter template based on grammY bot framework and prisma ORM.
Uses PostgreSQL for data storage (MySQL, MongoDB, SQL Server, SQLite are also supported by prisma) and Redis for session storage.


Features

  • Config loading and validation
  • Logger
  • Sessions
  • Language picker and internationalization
  • Graceful shutdown
  • Metrics collection (in prometheus format)
  • Fast and low overhead fastify server
  • Ready-to-use Docker setup

Usage

Clone this repo or generate new repo using this template via link

git clone https://github.com/bot-base/telegram-bot-template
Launch
  1. Create environment variables file
cp .example.bot.env .env
  1. Edit environment variables in .env

  2. Launch bot

    Development mode:

    # install dependencies
    npm i
    
    # run migrations
    npx prisma migrate deploy
    
    # run bot
    npm run dev

    Production mode:

    # install dependencies
    npm i --only=prod
    
    # run migrations
    npx prisma migrate deploy
    
    # build bot
    npm run build
    
    # run bot
    npm start
Launch using Docker
  1. Create development and production environment variables files
# development
cp .example.bot.env docker-compose.dev.bot.env
cp .example.postgres.env docker-compose.dev.postgres.env

# production
cp .example.bot.env docker-compose.prod.bot.env
cp .example.postgres.env docker-compose.prod.postgres.env
  1. Edit environment variables in docker-compose.dev.bot.env and docker-compose.prod.bot.env

  2. Launch bot

    Development mode:

    # install dependencies
    npm i
    
    # run migrations
    docker-compose run bot npx prisma migrate deploy
    
    # run bot
    docker-compose up

    Production mode:

    # run migrations
    docker-compose -f docker-compose.yml -f docker-compose.prod.yml run bot npx prisma migrate deploy
    
    # run bot
    docker-compose -f docker-compose.yml -f docker-compose.prod.yml up

Environment variables reference

Variable Description
NODE_ENV Node environment
LOG_LEVEL Log level
CHECKPOINT_DISABLE Prisma Telemetry
DATABASE_URL Database URL
REDIS_URL Redis URL
BOT_SERVER_HOST Server address
BOT_SERVER_PORT Server port
BOT_ALLOWED_UPDATES List of update types to receive
BOT_TOKEN Token, get it from @BotFather
BOT_WEBHOOK
Webhook endpointUsed for setup a webhook in production mode.
BOT_ADMIN_USER_ID
Administrator user IDCommands, such as /stats or /setcommands, will only be available to the user with this ID.

telegram-bot-template's People

Contributors

deptyped avatar renovate-bot avatar renovate[bot] avatar spyke113 avatar

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.