Giter Club home page Giter Club logo

menu-telegram-bot's Introduction

menu-telegram-bot

Related Projects

Setup

The telegram bot uses a local SQLite database with the Prisma ORM. In order to host the bot on your own you'll need to setup the ORM first. The easiest way to achieve this is by globally installing prisma if you haven't done this already. You'll need to have Node.js installed first in order to install Prisma.

# install prisma globally via npm
npm install -g prisma

After installing Prisma you can generate a new SQLite database using the Prisma CLI.

# generate a new database
prisma generate
# migrate changes to the database (if made any)
prisma migrate dev

Additionally you'll have to create a .env file which contains at least the following environment variables:

DATABASE_URL=   // local path to the database file. Default: "file:./menu_telegram_bot.db"
API_URL=        // your api url e.g. https://api.example.com

The following environment variables are optional:

WEBSITE_URL=    // your website url e.g. https://example.com

Deploy

Using Docker

The docker image for the telegram bot can be pulled from the github container registry:

docker pull ghcr.io/virtbad/menu-telegram-bot:latest

When running the as a container you'll have to mount a config into the container which contains the following entries:

{
  "token": "YOUR_TELEGRAM_BOT_TOKEN",
  "selfDescructingTimeout": 2000,
  "waitFoReplyTimeout": 30000
}

The config has to be mounted to /app/config.json inside the container. Additionally, you'll need to set the environment variables mentioned above for the container.

Since the telegram bot stores the chats it is part of in a sqlite database you'll idealy mount the database into the container as well. The location of the database is /app/prisma/<DATABASE_URL_FILE>.db.

An example for a run command would be:

docker run ghcr.io/virtbad/menu-telegram-bot:latest -v ./config.json:/app/config.json -v ./prisma/menu_telegram_bot.db:/app/prisma/menu_telegram_bot.db -e API_URL=http://localhost:80

The Classic Way

In order to deploy the telegram bot you'll still need to specify some configurations and install all project dependencies. When running the bot for the first time it will throw an error and initialize a config.json file containing placeholder and default values. You must replace the token entry in order to host the bot.

# install dependencies
npm install
# run the telegram bot
npm run start

menu-telegram-bot's People

Contributors

whysobad avatar

Watchers

 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.