A
A
AlexGenesis2021-01-27 00:14:47
Python
AlexGenesis, 2021-01-27 00:14:47

How to send a message to a person using his ID?

(Library: telebot)
The idea of ​​the bot is that after writing the start command in the group, the bot using the user id (Who wrote the start command) will write "Hi" to him in the PM. The problem is that the code works as I want only if I write the start command, but otherwise (If the start command is written by another user), the code just stops without an error.
The code itself:

@Bot.message_handler(commands=["start"])
def show_info(message):
Bot.send_message(message.from_user.id, "Hi")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lesha, 2021-01-27
@AlexGenesis

Bots cannot initiate conversations with users
https://core.telegram.org/bots#4-how-are-bots-diff...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question