A script for a Telegram bot that deletes non-photo material from a group chat topic.
To run this script with the right Python version and all the dependencies, please use uv:
Installation commands for uv
Install uv on Windows 11+ with PowerShell:
irm https://astral.sh/uv/install.ps1 | iex; $env:Path = "$env:USERPROFILE\.local\bin;$env:Path"
On macOS or Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh && source $HOME/.local/bin/env
Or, if you only have access to Python (as is the case for PythonAnywhere's free tier):
pip install --upgrade uv
Then, run the script:
curl -L https://github.com/vovavili/media_only_tg_bot/archive/refs/heads/master.zip | tar -xz
cd media_only_tg_bot-master
# Make sure to create a .env or .env.prod file at this step
uv run -m media_only_topic
Prior to running the script, please make sure your .env
or .env.prod
file contains the following variables. To find out
how to get them, please refer to the
following guide:
- BOT_TOKEN - an API token for your bot.
- TOPIC_ID - an ID for your group chat topic.
- GROUP_CHAT_ID - an ID for your group chat.
- ENVIRONMENT - if you intend on running this script on a VPS, this improves logging information in your production system. Has to be either "development" or "production."
Required only in production, to send an email message on failure:
- SMTP_HOST - SMTP server address (e.g., smtp.gmail.com).
- SMTP_USER - Email username/address for SMTP authentication.
- SMTP_PASSWORD - Email password or app-specific password (in case of something like Gmail).
Based on my experience, this script runs on Oracle's free VM.Standard.E2.1.Micro shape just fine, though for particularly active group chats it might be too limited.