@bot.callback_query_handler(func=lambda call:True)
def shop(call):
if call.data == 'car_salon':
inline = types.InlineKeyboardMarkup()
markup_inl1 = types.InlineKeyboardButton('Toyota', callback_data='toyota121')
markup_inl2 = types.InlineKeyboardButton('Audi', callback_data='audi121')
markup_inl3 = types.InlineKeyboardButton('Bmw', callback_data='bmw121')
markup_inl4 = types.InlineKeyboardButton('Mersedes', callback_data='mersedes121')
inline.add(markup_inl1, markup_inl2, markup_inl3,markup_inl4)
bot.send_message(call.message.chat.id, 'Виберіть марку авто:', reply_markup=inline)
if call.data == 'bmw121':
bot.send_message(call.message.chat.id, 'Доступні машини:')
for id_user in sql.execute(f"SELECT id FROM users WHERE login = '{user_login}'"):
pass
bot.send_photo(id_user, codecs.open(r"C:\Users\HOME\PycharmProjects\Кеша бот python\Новий бот-Ігра\Фото\Car\bmw_E39.jpg", 'rb'), caption='Bmw e39 - 150.000грн')
bot.send_photo(id_user, codecs.open(r"C:\Users\HOME\PycharmProjects\Кеша бот python\Новий бот-Ігра\Фото\Car\bmw_x3_2011.jpg ", 'rb'), caption='Bmw X3 - 520.000грн')
bot.send_photo(id_user, codecs.open(r"C:\Users\HOME\PycharmProjects\Кеша бот python\Новий бот-Ігра\Фото\Car\bmw_m5f90.jpg", 'rb'), caption='Bmw 5mF90 - 3.000.000грн')
bot.send_message(call.message.chat.id, 'Виберіть авто!' )
Єто не весь код но думаю ошибка здесь
Написал бота и вилизит ошибка:
Traceback (most recent call last):
File "C:/Users/HOME/PycharmProjects/Кеша бот python/Новий бот-Ігра/main.py", line 270, in <module>
bot.polling(none_stop=True, interval=0)
File "C:\Users\HOME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 623, in polling
self.__threaded_polling(non_stop, interval, timeout, long_polling_timeout, allowed_updates)
File "C:\Users\HOME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 682, in __threaded_polling
raise e
File "C:\Users\HOME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 645, in __threaded_polling
self.worker_pool.raise_exceptions()
File "C:\Users\HOME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\util.py", line 130, in raise_exceptions
raise self.exception_info
File "C:\Users\HOME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\util.py", line 82, in run
task(*args, **kwargs)
File "C:/Users/HOME/PycharmProjects/Кеша бот python/Новий бот-Ігра/main.py", line 82, in shop
if call.data == 'car_salon':
AttributeError: 'Message' object has no attribute 'data'