A Telegram bot for generating screenshots with highlighted code.
There are two services - bot.py
and screenshot-service.js
.
bot.py
- bot written in AIOgramscreenshot-service.js
- a service for generating screenshots
- Bot requests the screenshot service to generate an image with code.
- Screenshot service in turn does:
- Highlights a code via highlight.js
- Load generated HTML and takes a screenshot via Puppeteer (headless Chrome driver)
- Saves generated screenshot to a directory and returns it's path.
- Bot sends generated image to a user.
- Install dependencies:
# Python dependencies
$ poetry install
# JavaScript dependencies
$ npm i
- Copy
.env.example
to.env
:
$ cp .env.example .env
- Specify a bot token in
.env
. - Execute services:
# execute bot
$ poetry run bot.py
# execute bot (in another terminal)
$ node screenshot-service.js
If you are running a bot locally don't forget to start Telegram Bot API.
For local development use Telegram Bot API.
- Rate limiting
- Use queue to limit the number of pages generated in parallel
- Containerize