Last active
          July 12, 2020 12:07 
        
      - 
      
- 
        Save HirbodBehnam/08626322ae4ca0ee360fdb62c3a71d35 to your computer and use it in GitHub Desktop. 
    A script to upload file to telegram
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # Use the app like python3 TelegramUploader.py /path/to/file | |
| # At first install Telethon and humanize with pip3 install telethon humanize cryptg | |
| # Note that cryptg is optional and only is used for speeding up the uploads | |
| import sys, humanize | |
| from telethon import TelegramClient, events, sync | |
| def upload_progress_callback(downloaded_bytes, total_bytes): | |
| print("Uploaded: " + humanize.naturalsize(downloaded_bytes) + " / " + humanize.naturalsize(total_bytes), end='\r') | |
| # These example values won't work. You must get your own api_id and | |
| # api_hash from https://my.telegram.org, under API Development. | |
| api_id = 12345 | |
| api_hash = '0123456789abcdef0123456789abcdef' | |
| client = TelegramClient('session_name', api_id, api_hash) | |
| client.start() | |
| client.send_file('me', sys.argv[1], progress_callback=upload_progress_callback) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment