Skip to content
Advertisement

Send document to telegram bot using python-telegram-bot Package

I am try to build a telegram bot using python with python-telegram-bot Package and its working with text commands now i try to send a document to user

my code like

def start(update, context):

return update.message.download(open('cv.pdf', 'rb'))

but it show a error like return update.message.download(open('cv.pdf', 'rb')) AttributeError: 'Message' object has no attribute 'download'

Then how to send a document file to user any way ?

Advertisement

Answer

telegram.Message

There is no download attribute for the message object, but the bot object has a send_document attribute so to successfully send a document.

doc_file = open('cv.pdf', 'rb')
chat_id=update.effective_chat.id
return context.bot.send_document(chat_id, doc_file)
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement