Français
Ouvrir dans Telegram

Fil de discussion@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 · groupe · Technologie
4 169membres43écrivent en 30 jours
Fil de la communauté Ouvrir dans Telegram

Un fil public ouvert issu de l'index de recherche ChatCrawler — « le Google du Telegram public » ; actualisé à mesure que la communauté est explorée. Les heures sont en UTC.

Contenu public uniquement, API officielle de Telegram. À propos · FAQ · Limites de l'index · Retirer une page · Catalogue · Recherche · Comment nous comptons