Answer the question
In order to leave comments, you need to log in
What should I do if I get the error AttributeError: 'CallbackQuery' object has no attribute 'chat' when starting the program?
I run the program:
import telebot
print('******1')
from config import token
print('****2')
from telebot import types
bot = telebot.TeleBot(token)
@bot.message_handler(commands = ['start'])
def welcome(message):
bot.send_message(message.chat.id, 'Привет, {0.first_name}!\nЧтобы поискать статьи в техноблоге по моделям нажмите /tech'.format(message.from_user, bot.get_me()), parse_mode='html')
@bot.message_handler(commands = ['tech'])
def tech(gg):
kb = types.InlineKeyboardMarkup()
brand1 = types.InlineKeyboardButton(text='Kingsong', callback_data = 'kingsong')
brand2 = types.InlineKeyboardButton(text='Inmotion', callback_data = 'inmotion')
kb.add(brand1, brand2)
bot.send_message(gg.chat.id, "Choose a brand", reply_markup=kb)
@bot.callback_query_handler(func = tech)
def tech_ob(callback):
if call.data == 'kingsong':
bot.send_message('KS')
elif call.data == 'inmotion':
bot.send_message('Im')
bot.polling(none_stop=True)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question