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

Question:

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 ?

Asked By: Andrew

||

Answers:

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)
Answered By: darth baba

I have same question i want to send .txt file and im using telegraf.js in nodejs can you guys help me too ?
How to send .txt file from telegram bot using TelegrafJS Framework?

Answered By: YASH PUROHIT