Coder Social home page Coder Social logo

pifiabot's Introduction

pifiabot

This app uses Telegram's Bot API to deliver random results based on dice notation. The app sets a webhook as an entry point for Telegram messages.

Deployment

The app requires two environmental variables to work. It runs as a server receiving requests from Telegram services on the webhook endpoint, and sending callback requests using API methods. For authentication it uses a self-signed certificate in PEM format following API documentation.

Env variables

ENDPOINT

It is the external IP Address of the machine where the app is running. It is used to setup the webhook.

PORT

It's the port of the service exposed to the webhook callbacks. It is used to set the webhook.

BOT_TOKEN

It is the identifier that Telegram's Bot API sets on bot creation. It is used to communicate with the API.

Certificate

The server runs under HTTPS protocol and uses a keypair with this format: private.key and cert.pem.

Messages

The program also expects a JSON formatted file with the messages to display, using error ids as keys. A dummy JSON file could be provided and the error ids would be displayed instead.

Current format:

{
    "dice_number": "",
    "faces_number": "",
    "no_drop" : "",
    "notation_max_length": "",
    "repeat_iter_error": "",
    "repeat_nodice_error": "",
    "unknown_action": "",
    "unknown_error": "",
}

Deployment with Dockerfile

Builiding the image

docker build -t <image_name> --build-arg BOT_TOKEN=<bot_token> .

Running the container

docker run -td -p <endpoint_port>:<endpoint_port> -e ENDPOINT=<endpoint_ip> -e PORT=<endpoint_port> <image_name>

Required files

Both keys and the messages file should be available at build time in the following path:

  • deploy/cert.pem
  • deploy/private.key
  • deploy/messages.json

pifiabot's People

Contributors

ncaak avatar

Stargazers

 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.