Answer the question
In order to leave comments, you need to log in
How to get the ID of the person who clicked on the button in Pytelegrambotapi??
How can I get the ID of the person who clicked the inline button in the chat? I sat all day, as a result, I was able to call the id bot but not the user, here is the code:
@bot.message_handler(commands=['test'])
def send_test(message):
bot.restrict_chat_member(message.chat.id, message.from_user.id)
Knopka = types.InlineKeyboardMarkup()
knop1 = types.InlineKeyboardButton(text = '', callback_data = 'Ok')
knop2 = types.InlineKeyboardButton(text = '', callback_data = 'No')
Knopka.add(knop1, knop2)
name = message.from_user.first_name
bot.send_message(message.chat.id, name + ', добро пожаловать в чат \nчтобы получить доступ к чату нажми на эмодзи \'\' ниже', reply_markup = Knopka)
@bot.callback_query_handler(func = lambda call: True)
def answer(call):
if call.data == "Ok":
bot.send_message(call.message.chat.id, f'Сдесь должен быть айди человека {message.from_user.id}')
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