Code Monkey home page Code Monkey logo

pytelegrambotapi-redisqueue_poc's Introduction

pytelegrambotapi + redis queue POC

This is a Proof Of Concept of a Telegram Bot working with Redis queues, where one service receives client updates from Telegram Bot API and pushes them into a Redis queue. Then, one or more backend services subscribe to the queue and process the incoming updates.

Services intended to be deployed

  • 1/n Redis server (cluster?)
  • 1 Telegram updates entrypoint service (telegrambot_entrypoint): receives Telegram bot client updates through polling/webhook and insert them into a Redis queue (it would be interesting to have more of these workers for redundancy, but only one should run at the same time)
  • n Telegram bot backend services/workers (telegrambot_backend): subscribe to the queue and get the requests processed through aiogram

Getting started

# 1) Create conda env (optional)
make create-conda-env
conda activate pytelegrambotapi+redis

# 2) Start a Redis server (requires Docker)
make run-redis

# 3) Setup .env file
cp sample.env .env
# Edit the .env file to change the TOKEN to the token of a bot of your own

# 4) Run bot polling
make run-polling

# 5) Run a bot updates worker (new terminal - you can run as many as you want!)
conda activate pytelegrambotapi+redis
make run-worker

# After playing with it... Teardown of Redis server (stop & remove container)
make teardown-redis

TODO

  • Replace aioredis with sync redis (as pytelegrambot does not run async) & set all functions sync
  • Improve logging
  • Improve multithreading for each bot worker + add commands that sleep for a few seconds

pytelegrambotapi-redisqueue_poc's People

Contributors

david-lor avatar

Watchers

 avatar  avatar

Forkers

excelenz

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.