├── revisto_files_bot ├── requirements.txt ├── .env.example ├── setting.py └── bot.py ├── .gitignore └── Dockerfile /revisto_files_bot/requirements.txt: -------------------------------------------------------------------------------- 1 | python-dotenv 2 | python-telegram-bot -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | .vscode/settings.json 3 | mc_bot/__pycache__ 4 | revisto_files_bot/__pycache__/ 5 | -------------------------------------------------------------------------------- /revisto_files_bot/.env.example: -------------------------------------------------------------------------------- 1 | telegram_robot_access_token = 1234567891:ABCD_123456ABCD123456abcd1234567891 -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.8 2 | 3 | COPY revisto_files_bot /app 4 | WORKDIR /app 5 | 6 | RUN pip3 install -U setuptools 7 | RUN apt-get install -y libssl-dev libffi-dev 8 | RUN apt-get install -y libxml2-dev libxslt1-dev zlib1g-dev 9 | RUN pip3 install -r requirements.txt 10 | 11 | CMD ["python3","bot.py"] 12 | -------------------------------------------------------------------------------- /revisto_files_bot/setting.py: -------------------------------------------------------------------------------- 1 | import dotenv 2 | from os import getenv 3 | 4 | dotenv.load_dotenv() 5 | 6 | base_save_location = "/root/shared_data/telegram/" 7 | music_save_location = f"{base_save_location}musics/" 8 | video_save_location = f"{base_save_location}videos/" 9 | picture_save_location = f"{base_save_location}pictures/" 10 | telegram_access_token = getenv("telegram_robot_access_token") -------------------------------------------------------------------------------- /revisto_files_bot/bot.py: -------------------------------------------------------------------------------- 1 | from telegram.ext import Updater, CommandHandler, MessageHandler, Filters 2 | import setting 3 | 4 | def video_downloader(update, context): 5 | file_name = update.message.video.file_name 6 | file = context.bot.getFile(update.message.video.file_id) 7 | file.download(setting.save_location + file_name) 8 | update.message.reply_text("Done, bro") 9 | 10 | def main(): 11 | updater = Updater(setting.telegram_access_token, use_context=True) 12 | dp = updater.dispatcher 13 | dp.add_handler(MessageHandler(Filters.video, video_downloader)) 14 | 15 | 16 | updater.start_polling() 17 | updater.idle() 18 | 19 | 20 | if __name__ == '__main__': 21 | main() 22 | --------------------------------------------------------------------------------