In this block of code:
@bot.message_handler(content_types=["document"])
def sending_document(message):
if ".docx" in message.document.file_name:
bot.send_document(message.chat.id, message.document) #<- problem
I don't know where to get the document from the message.
I tried to do a lot of things but it didn't work.
Disclaimer: I'm familiar with the telebot
library, but with the Telegram Bot API itself.
The sendDocument
expects for the parameter document
either a URL, a file id or a multipart-uploaded file. However, message.document
is a Document
object. The file_id of that document should be available via message.document.file_id
, so I'd expect bot.send_document(message.chat.id, message.document.file_id
to work.