Reputation: 11
How to read particular user latest messages i have userId but i want to read all messages send by that user. I want if there is any bot functions which can be used for this. I also want to know can i read reactions on a particular message of that user
Upvotes: 0
Views: 1352
Reputation: 462
It's pretty easy to filter the messages by sender id. You should:
A bot running in privacy mode will not receive all messages that people send to the group.
When you have an incoming update, check for the update.message.from.id to know if he's the target user.
use copyMessage
or forwardMessage
to send his message to yourself.
Here's a simple example using PHP/TeleBot:
$tg = new TeleBot('your-token');
if ($tg->user->id == 'target-user-id') {
$tg->forwardMessage([
'chat_id' => 'your-user-id',
'from_chat_id' => $tg->chat->id,
'message_id' => $tg->message->message_id,
]);
}
You can also check out this repository to more know and get inspired: https://github.com/mkleymenov/telespy-bot
Upvotes: 0