Git Product home page Git Product logo

tdu's Introduction

Telegram File Transfer Bot

This script uses the Telethon library to automate the transfer of files from one Telegram channel to another. It filters specific file types, downloads them, and uploads them to another channel.

Requirements

  • Python 3.x
  • Telethon package

Installation

Install Telethon using pip:

pip install telethon

Usage

  1. Setup API Keys: First, obtain your api_id and api_hash from my.telegram.org.
  2. Configure Script: Open the script and replace api_id and api_hash with your actual API credentials. Set channel_url to the source channel's URL and channel_b_username to the target channel's username.
  3. Run Script: Execute the script. On the first run, you'll need to authenticate with your phone number.

Code Explanation

  • Initialization:

    import os
    from telethon import TelegramClient, events
    
    api_id = 123  # Replace with your API ID
    api_hash = '123'  # Replace with your API Hash
    client = TelegramClient('session_name', api_id, api_hash)
  • Function to Check if a File is Uploaded:

    def is_file_uploaded(file_name):
        ...
  • Main Function:

    • Connect to Telegram.
    • Authenticate if not already authorized.
    • Set up source (channel_url) and target (channel_b_username) channels.
    • Iterate through messages in the source channel, downloading and re-uploading specified file types.
  • File Download and Upload:

    • Check file extensions.
    • Download files to downloads/ folder.
    • Retry mechanism for both downloading and uploading.
    • Delete the file locally after uploading.
  • Running the Client:

    with client.start():
        client.loop.run_until_complete(main())

Note

  • This script requires a persistent internet connection.
  • Ensure sufficient local storage for temporary file downloads.
  • Be aware of Telegram's rate limits to avoid being temporarily banned.

License ๐Ÿ“œ

This project is licensed under the GNU General Public License, version 3 (GPL-3.0). See the LICENSE file for details.

Author โœ๏ธ

This script was developed by SecWithMoh.

tdu's People

Contributors

secwithmoh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.