This bot mirrors the media uploaded in r/soccer to a telegram channel.
Telegram offers unlimted storage to its users and recently, it let anyone on the internet preview content on a public channel without requiring a telegram account. The aim of this bot is to 'exploit' this and serve telegram as a mirror.
This bot crawls through the reddit api for new soccer posts every minute. Once a post with media flare is found, it:
- Tries to process the link in the post and sends the video.
- If it can't process the link in the post, it crawls the mirror links under the automoderator comment and tries to process all links again.
- It tries this process 5 times in 5 minutes in total, if none of the links work.
Processing the video link:
- Uses youtube-dl to get the direct link.
- Checks if the link is greater than 14mb, compresses the video if it is.
- Sends the video to the telegram channel
- Posts a reddit comment under the automoderator with the link to the video
- Clone the repo
git clone https://github.com/RtiM0/telegram-mirror-bot.git
cd telegram-mirror-bot
- Install ffmpeg
- Create virtualenv
python3 -m venv env
source env/bin/activate
- Install requirements
pip install -r requirements.txt
- make
.env
file
TOKEN = "<Telegram Bot Token>"
- make
praw.ini
file
[telegram mirror bot]
client_id=<Reddit Client ID>
client_secret=<Reddit Client Secret>
username=<Reddit Account Username>
password=<Reddit Account Password>
user_agent=tg mirror bot 0.1
- Run the bot
python bot.py
The bot can be optimized further, especially with the video compression. If you have ways to improve upon the current algorithm, Pull requests are welcomed.