I was trying to add user’s name to a python list from function callback_handler()
when an inline button is pressed. But when i try to get user’s name from call.message.from_user.username
it just gives me bot’s username.
@bot.callback_query_handler(func=lambda call: True)
def callback_handler(call, value=True):
if call.data == 'teachBot':
bot.send_message(call.message.chat.id, "Я внимательно слушаю. Оформите сообщение подобно этому: запрос_ответ1//ответ2//ответ 3 с пробелом")
print(call.message.text)
global teachers
teachers.append(call.message.from_user.username)
elif call.data == 'keep':
for keys in teachers:
if keys == call.message.from_user.username:
teachers.remove(keys)
bot.send_message(call.message.chat.id, 'Ладно брат')
I tried to put user’s name into button’s call.data
but it can’t just read it.