I
I
Igor29012021-10-27 22:49:51
Python
Igor2901, 2021-10-27 22:49:51

I wanted when you write the word file to the bot, it sends the document. What's my mistake?

@dp.message_handler()
async def echo_all(message: types.Message):
  if 'file' in message.text:
    await bot.send_document(message.chat.id, open(r'Путь_к_документу/Название_документа.txt,' 'rb'))

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor2901, 2021-10-28
@Igor2901

@dp.message_handler()
async def echo_all(message: types.Message):
if 'file' in message.text:
doc = open(("Path_to_document/Name_document" ) + '.txt', 'rb')
await message. reply_document(doc)

Y
Yakovlev Daniil, 2021-10-28
@Kil0Gramm

well, you ask to send a document, he sends) what's the problem then?

I wanted when you write the word file to the bot, it sends a document . What's my mistake?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question