English
Open in Telegram

Thread@bot.message_handler(commands=['download_track'])

4 messages · –
С
@bot.message_handler(commands=['download_track']) def download_track(msg): bot.send_message(chat_id=msg.chat.id, text='*Send me a link to the track!*') bot.register_next_step_handler(msg, two_step_of_download_track) def two_step_of_download_track(msg): url = msg.text name = download_track(url) f = open(file=name, mode='rb') bot.send_document(chat_id=msg.chat.id, document=f) f.close() os.remove(name) AttributeError: 'str' object has no attribute 'chat'
  1. ⁣
    Ты в download_track прокидываешь строку (во втором методе). Вот и нет атрибута. А почему такие проблемы? А потому что нет тайпхинтов и потому что не надо дергать хендлеры из другого хендлера
  2. ⁣
    name = download_track(url) Перечитай эту строчку 5 раз в контексте твоей программки, и если ты не поймешь в чем ошибка, тебе рано в ботов. А ошибок, кстати, больше чем одна
ССообщество Python ПрограммистовСообщество Python Программистов@python_scripts · group · Tech
4 169members43writing in 30 days
Venue feed Open in Telegram

An open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · Index limits · Remove a page · Catalog · Search · How we count