Giter VIP home page Giter VIP logo

botserver's Introduction

BOTServer

Telegram Bot API Webhooks Framework, for Rubyists.
BOTServer configures, tests and deploys bots, running a fast rack server for webhooks routing.

Details about Telegram Bot API long polling vs webhooks: Telegram Bot Platform

Webhooks ?

There are at least three Telegram Bot Ruby clients (as far as I know), here listed Telegram BOT Ruby clients:

NOTE: All of them implement Telegram Bot API long polling way, with getUpdates endpoint. No one of these gems implement the webhooks mode.

  • Webhooks vs long polling

    BOTServer first goal is to set-up a Ruby way to manage Telegram Bot API webhooks Updates, a performance improvement in comparison with HTTPS long polling mode.

    This project is related to telegram-bot-ruby gem, Alexander Tipugin's excellent Telegram Bot client APIs wrapper; to thank him for his work, I tried to solve issue #19: setting up webhooks with telegram-bot-ruby ?. BOTServer closed the issue :)

  • Multiple bots webhooks updates routing

Receiving HTTPS webhooks callbacks is probably more efficient than getting updates on a long polling connection, but the real need of webhooks is when you have dozen, hundreds of bots to manage at once with your server. In this scenario, it could pretty impossible to manage in a single host, using long polling connections, because the need to maintain open too many Ruby processes/ HTTPS (persistent) connections.

** BOTServer is a toolkit to test and deploy Bot tokens to receive webhooks with a very simple dynamic routing server: a rack server that dispatch dinamically incoming token webhooks, calling update method of an instance of a class generated with a template sckeleton, that define the bot. Details: Telegram Bot Architecture(s)**

  TELEGRAM Bot API Server                         
 --------------------------------------------------------------------
   v v v                                                       ^ ^ ^
   | | |                                                       | | |
   | | |    SSL/HTTPS                                          | | | 
   | | |    front-end       BOTServer                          | | |
   | | |    +-------+       Rack router                        | | |
   | | |    |       |       +------+                           | | |
   | | |    |       |       |      |     +-------+ HTTPS send  | | |
   | | |    |       |       |      |---->| App 1 |-------------+ | |
   | | |    |       | HTTP  |      |     +-------+               | |
   | | |    |       | POST  |      |                             | |
   | | +--->|       |------>|      |     +-------+ HTTPS send    | |
   | +----->|       |------>|      |---->| App 2 |---------------+ |
   +------->|       |------>|      |     +-------+                 |
   webhooks |       |       |      |                               |
 HTTPS POST |       |       |      |     +-------+  HTTPS send     |
            |       |       |      |---->| App   |-----------------+
            |       |       | Thin |     +-------+
            | NGINX |       +------+
            +-------+       

BOTServer is a devops utility to:

  • set-up and test tokens/webhooks
  • generate a template app for each bot
  • run a webhooks router/server.

Here assembly instruction steps:

  1. Installation (web/proxy server, Ruby project code)
  2. Get Telegram Bot token(s)
  3. Update configuration files
  4. Create (self-signed) Certificate
  5. Configure "Webhooks mode" for each token
  6. Generate template for each bot
  7. Deploy and run _BOTServer

Keep calm and follow step by step instrctions: Assembly instructions in 7 steps

After installation of the project, just run rake from your project home:

$ rake
rake app:new[token]        # Create bot app template for given token
rake certificate:new       # Create SSL certificate
rake certificate:show      # Show public certificate
rake proxy:config:new      # Generate nginx proxy SSL configuration from server.yml data
rake proxy:restart         # Restart proxy server
rake proxy:start           # Start proxy server
rake proxy:stop            # Stop proxy server
rake server:config:show    # Show server configuration: /home/solyaris/BOTServer/config/server.yml
rake server:config:test    # Check server configuration: /home/solyaris/BOTServer/config/server.yml
rake server:log            # Tail -f rack sever logfile: /home/solyaris/BOTServer/log/thin.log
rake server:pid            # Show rack server pid
rake server:restart        # Restart rack server
rake server:start          # Start rack server
rake server:stop           # Stop rack server
rake tokens:show           # Show tokens configuration file: /home/solyaris/BOTServer/config/tokens.yml
rake tokens:test           # Verify if tokens are valid, online querying Telegram Server
rake webhook:reset[token]  # Reset webhook for a given token
rake webhook:set[token]    # Set webhook for a given token

Documentation / wiki

botserver's People

Contributors

l-eugene avatar romansavrulin avatar solyarisoftware 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.