Basic Telegram Bot Sending Random Wikimedia Commons Photos
- Download a dataset of photos via the WikiMap API, for instance:
wget --restrict-file-names=windows 'https://wikimap.toolforge.org/api.php?cat=Images_with_annotations&lang=de&year=2010-2015®ion=49|9|46|18'
- Generate a bot API token by sending
/newbot
to BotFather - Install bot via
pip3 install --user --upgrade location-guessing-game-telegram-bot
(or use docker / podman, see below)
- Launch bot:
location-guessing-game-telegram-bot --telegram-token-path file-containing-api-token --wikimap-export-path wikimap-export.json
- Open a chat with the bot in Telegram by searching for the bot's name previously sent to BotFather
- Send message
/photo
, wait, and repeat - Optionally add the bot to a group chat.
Pre-built docker images are available at https://hub.docker.com/r/fphammerle/location-guessing-game-telegram-bot/tags
$ sudo docker run --name location_guessing_game_telegram_bot \
-v /file/containing/api-token:/telegram-token:ro -e TELEGRAM_TOKEN_PATH=/telegram-token \
-v /wikimap/export.json:/wikimap-export.json:ro -e WIKIMAP_EXPORT_PATH=/wikimap-export.json \
--read-only --cap-drop ALL --security-opt no-new-privileges \
--cpus 0.4 --memory 128M \
docker.io/fphammerle/location-guessing-game-telegram-bot:latest
Optionally, replace sudo docker
with podman
.
Annotation of signed git tags docker/*
contains docker image digests: https://github.com/fphammerle/location-guessing-game-telegram-bot/tags
Detached signatures of images are available at https://github.com/fphammerle/container-image-sigstore
(exluding automatically built latest
tag).
- Clone this repository.
- Edit paths in
docker-compose.yml
. sudo docker-compose up --build
See ansible-playbook-example.yml.
Why create a Telegram bot instead of a web app?
I created this mini game for my family including my grandparents, who are comfortable using Telegram.