Code Monkey home page Code Monkey logo

telegram-bot-server's Introduction

telegram-bot-server

Setup

Docker should be installed.

  1. Get api_id and api_hash from telegram.
  2. Get the bot_token from BotFather Telegram Bot.
  3. Get the webhook_url from the Setup of your Bot Webhook Listener
  4. Get the bot_server_base_url either using noip or ngrok.
  5. Clone this repo
git clone https://github.com/chitranjan-gupta/telegram-bot-server

Build

  1. Go to directory telegram-bot-server
cd telegram-bot-server
  1. Build the docker image
docker build -t telegram .

Execute

  1. Make GET request to https://api.telegram.org/bot[BOT_TOKEN]/logOut replace with bot_token to logout Telegram Cloud API Server.
  2. Run the docker image
docker run -p 80:80 telegram --api-id [API_ID] --api-hash [API_HASH] --http-port 80
  1. Make GET request to https://[BOT_SERVER_BASE_URL]/bot[BOT_TOKEN]/setWebhook?url=[WEBHOOK_URL]/&drop_pending_updates=true replace with bot_server_base_url, bot_token and webhook_url to set webhook url to get updates from the bot.

Migrate

If you want to migrate to different server you have to all the steps from above but before that you have do this

  1. Make GET request to https://[BOT_SERVER_BASE_URL]/bot[BOT_TOKEN]/getWebhookInfo replace with bot_server_base_url and bot_token to check about your webhook url.
  2. Make GET request to https://[BOT_SERVER_BASE_URL]/bot[BOT_TOKEN]/deleteWebhook?drop_pending_updates=true replace with bot_server_base_url and bot_token to remove your webhook url set previously.
  3. Make GET request to https://[BOT_SERVER_BASE_URL]/bot[BOT_TOKEN]/close replace with bot_server_base_url and bot_token to stop the bot instance.
  4. Make GET request to https://[BOT_SERVER_BASE_URL]/bot[BOT_TOKEN]/logOut replace with bot_server_base_url and bot_token to logout from Local API Server.

Sources:

  1. https://core.telegram.org/bots/api
  2. https://github.com/tdlib/telegram-bot-api
  3. https://api.telegram.org/bot[BOT_TOKEN]/getWebhookInfo
  4. https://api.telegram.org/bot[BOT_TOKEN]/setWebhook?url=[WEBHOOK_URL]&drop_pending_updates=true
  5. https://api.telegram.org/bot[BOT_TOKEN]/deleteWebhook?drop_pending_updates=true
  6. https://api.telegram.org/bot[BOT_TOKEN]/close

telegram-bot-server's People

Contributors

chitranjan-gupta 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.