danog / MadelineProto

Async PHP client API for the telegram MTProto protocol
https://docs.madelineproto.xyz
GNU Affero General Public License v3.0
2.74k stars 617 forks source link

messages.gethistory and messages.search return no messages #1498

Closed iamcrang closed 2 months ago

iamcrang commented 3 months ago

Hello, thank you for the great library.

I'm trying to fetch messages from a public channel starting from certain message.id Used 2 methods, getHistory and search, both returns the same result:

$messages_Messages = $MadelineProto->messages->getHistory(peer: $channel, offset_id: $offset_id, limit: $limit, min_id: $offset_id);
$messages_Messages = $MadelineProto->messages->search(filter: ['_' => 'inputMessagesFilterEmpty'], peer: $channel, offset_id: $offset_id, limit: $limit, min_id: $offset_id);

$offset_id is the latest message id from my database, it is less than the latest message id in the channel $limit = 100;

{
    "_": "messages.channelMessages",
    "inexact": false,
    "pts": 62852,
    "count": 18231,
    "offset_id_offset": 19,
    "messages": [],
    "topics": [],
    "chats": [],
    "users": []
}

Tell me please, how can I get latest messages (with id greater than provided id in $offset_id) and why I getting no messages?

Thank you in advance.

danog commented 2 months ago

Please only use the event handler to fetch new messages.