I
I
Igroman2282021-03-07 08:19:58
Python
Igroman228, 2021-03-07 08:19:58

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

1 answer(s)
S
Sanya Hihi Haha, 2021-03-07
@Igroman228

It was

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question