M
M
MarkSmersh2021-05-25 00:38:51
Python
MarkSmersh, 2021-05-25 00:38:51

How to find out the new chat_id of a private chat?

Is it possible to get the chat_id of every user that starts a chat with the bot without having to enter the chat_id manually?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ananchenko, 2021-05-25
@MarkSmersh

It is possible, when starting the bot with the "/start" command, to add the user's chat_id to the database
. For example, in the "telebot" module, this can be implemented like this

@bot.message_handler(regexp='/start')
def start(message):
    print(message.chat.id)
    #Ну сюда фигаришь дальше код, куда сохранять эти chat_id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question