1. Telegram API Application#
Open https://my.telegram.org/apps, select Apps after logging in, fill in the relevant information, and automatically generate apiId and apiHash information. If you have applied before, you can see it after entering Apps.
2. Building a Telegram Bot#
- Download the script
- Install rclone. If you only need to download to your local machine, you don't need to install this step.
- Enter the script directory
cd telegram_channel_downloader
- Install dependencies
pip3 install -r requirements.txt
- Modify the relevant information in the telegram_channel_downloader.py file:
api_id, api_hash: Information obtained from the telegram api, fill in the corresponding positions respectively;
bot_token: Contact @BotFather to create a bot, it can also be an existing one. Fill in the obtained token;
admin_id: Contact @get_id_bot to send a random message and obtain it;
If you need to upload to OD: You should modify the following parameters in the script: drive_id="", drive_name='onedrive', onedrive is the name of the cloud drive you filled in when configuring rclone, and replace "fclone" with "rclone" on line 102;
There are corresponding notes for all configurations, modify them as needed.
- Run the script: Can be kept online with SCREEN
Screen related commands:
- Run: Send /start followed by the link to the channel to the bot, and you can start running the script and downloading files.
Link to the channel: Click on your channel name to see the channel link;
0: This is the message ID, you can define it yourself. 0 represents the earliest message. If you want to download from a specific message onwards, right-click on the message and choose "Copy Message Link" to see the message ID number at the end of the link.