3
3
3f4g2022-02-05 15:05:02
Python
3f4g, 2022-02-05 15:05:02

How to get chat_id telegram?

how to get your chat_id for bot? I am writing a bot that will send me data in private messages. telebot library.
is it possible to copy a unique identifier from the user's client and paste it into the bot code so that he writes messages to me?
I will be very grateful for your help

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Krostelev, 2022-02-05
@twistfire92

in the message handler, just add a line
print(message.chat.id)
and see what it displays in the console.
Or send the same message from the bot

T
This_is_MonoliT, 2022-02-05
@This_is_MonoliT

id = message.chat.id
Where id is exactly the ID of the user the bot is writing to.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question