A small demo telegram bot that creates polls from a predefined list.
88
An example for a telegram bot written in python and running in a container.
For a small project, we needed a bot as member in our telegram group that should create always the same polls if it was asked to. So a bot account was created using the telegram botfather, and some bot code written in python, using the python-telegram-bot library.
Important: you'll need the code from our Github repository to run the bot because the image is designed to mount the local directory with code and configuration and run the bot from there.
Get the code from https://github.com/SydalsITC/telegram-tools:
git clone https://github.com/SydalsITC/telegram-tools
Change to the demo-bot subfolder:
cd demo-bot
Make sure that the env variable BOTSTELEGRAMTOKEN contains your telegram access token and pass it when starting the bot:
docker run --rm -it -v .:/app:Z --env=BOTSTELEGRAMTOKEN=$BOTSTELEGRAMTOKEN sydalsitc/telegram-poll-bot:0.9.0-amd64
Add the flag "-d" for creating a background process if you like.
The demo-bot directory gets mounted inside the container at /app, making code and config available. Docker then
The bot need a telegram token for authentication. The python code awaits this in an environment variable called BOTSTELEGRAMTOKEN which is passed through from the outside by the docker-compose.yml file.
This way works fine for a small testing setup but is not recommended for production environments. Make sure to use secrets with docker swarm and kubernetes while adapting the code respectively.
Content type
Image
Digest
sha256:dc5135f7b…
Size
215.6 MB
Last updated
about 1 year ago
docker pull sydalsitc/telegram-poll-bot:0.9.0-amd64