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
JavaScript
x
4
1
def start(update, context):
2
3
return update.message.download(open('cv.pdf', 'rb'))
4
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
There is no download attribute for the message object, but the bot object has a send_document attribute so to successfully send a document.
JavaScript
1
4
1
doc_file = open('cv.pdf', 'rb')
2
chat_id=update.effective_chat.id
3
return context.bot.send_document(chat_id, doc_file)
4