Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. from telegram import  *
  2. from telegram.ext import *
  3. import os
  4.  
  5.  
  6. def download(update, context):
  7.     files = update.message.text.split()[1:]
  8.    
  9.     for file in files:
  10.         if not os.path.isfile(file):
  11.             continue
  12.         try:
  13.             context.bot.send_document(chat_id=update.message.chat_id, document=open(file, 'rb'))
  14.            
  15.         except TelegramError as error:
  16.             update.message.reply_text(str(error))
  17.                        
  18.  
  19. def main():
  20.     updater = Updater('token_here', use_context=True)
  21.     dp = updater.dispatcher
  22.    
  23.     dp.add_handler(CommandHandler('download', download))
  24.    
  25.    
  26.     updater.start_polling()
  27.     updater.idle()
  28.    
  29. if __name__ == '__main__':
  30.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement