2

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 ?

1 Answer 1

2

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)
Sign up to request clarification or add additional context in comments.

3 Comments

show this error return context.bot.send_document(chat_id=update.effective_chat.id, doc_file) ^ SyntaxError: positional argument follows keyword argument
try this way chat_id=update.effective_chat.id return context.bot.send_document(chat_id, doc_file) , its working
Okay that's interesting, I have updated the answer if it solves your question mark it as answered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.