-3

I can’t figure out how to make two people communicate through the bot? That is, user1 >message> bot>message>user2 It turns out that the bot acts as an intermediary, passing messages from one user to another

I was thinking of making a database with a user ID, and if a person clicks on the "find a friend" button, the status of his ID = True And if 2 people with the True status, then they can communicate with each other, but there are no further thoughts at all .... Please help((

Cisco
  • 1

1 Answers1

1

Remember, the Telegram bot will never be able to write to the user, if he himself did not activate this bot before.

So. Your idea can be implemented as follows. The user enters the bot and is offered a choice (two buttons). The first button is "connect with a random user", and the second is "connect by id". The first option: you accept a message from that user and duplicate it to another (and vice versa). The second option: if the user enters the correct id of another user, he receives a notification about a successful connection, and then everything is the same as in the first option. If the id is incorrect - an error message.

For navigation I would use InlineKeyboard (or alternatively ReplyKeyboard). It turns out that the bot will be an intermediary between users.

Disadvantages for users: you (an outsider) will be able to save all correspondence and view them. View complete information about the user's account. Benefits for users: They will be completely anonymous to each other.

I could say more about this, but I don't quite understand the point of creating a bot for such things

ogelcast
  • 41
  • 1
  • You explained everything correctly, but I myself know this theory, at the moment when I wanted to do this, I did not know how to apply the plan into action, or rather into the code. Your answer didn't help at all, thanks. – Cisco Jan 17 '23 at 16:45