Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from telegram import *
- from telegram.ext import *
- import os
- def download(update, context):
- files = update.message.text.split()[1:]
- for file in files:
- if not os.path.isfile(file):
- continue
- try:
- context.bot.send_document(chat_id=update.message.chat_id, document=open(file, 'rb'))
- except TelegramError as error:
- update.message.reply_text(str(error))
- def main():
- updater = Updater('token_here', use_context=True)
- dp = updater.dispatcher
- dp.add_handler(CommandHandler('download', download))
- updater.start_polling()
- updater.idle()
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement