简体   繁体   中英

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?

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)

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM