LonamiWebs / Telethon

Pure Python 3 MTProto API Telegram client library, for bots too!

Home Page:https://docs.telethon.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing MessagePeerReactions from recent_reactions after running iter_messages().

KMoszczyc opened this issue · comments

Code that causes the issue

 def get_chat_history(self, last_timestamp=None):
        chat_history = []
        count = 0
        print('last_timestamp:', last_timestamp)
        with self.client:
            for msg in self.client.iter_messages(CHAT_ID, offset_date=last_timestamp, reverse=True):
                if msg is None:
                    break

                print(msg.date, msg.id,  ':', msg.sender.first_name, msg.sender.last_name, msg.sender.username, msg.sender_id, ':', msg.text, msg.reactions)
                chat_history.append(msg)
                count += 1

        return chat_history

Expected behavior

This code is pulling the latest chat messages since last_timestamp. And as I've been using recent_reactions and MessagePeerReaction for extracting all of the reactions and the users that gave them. Only to realise that recent_reactions... contain maximum 3 MessagePeerReaction objects and no more! Maybe that was intended, but I really wanted to get all of them, so that I could create a nice reaction matrix (who likes whom).

Actual behavior

results=[ReactionCount(reaction=ReactionEmoji(emoticon='❤'), count=6, chosen_order=0)]
recent_reactions=[MessagePeerReaction(.. ❤), MessagePeerReaction(.. ❤), MessagePeerReaction(.. ❤)]

Traceback

No response

Telethon version

1.35.0

Python version

3.12

Operating system (including distribution name and version)

Windows 11

Other details

Is there a way to get all of the historical reactions and the users that gave them?
Thank you for any help!

Checklist

  • The error is in the library's code, and not in my own.
  • I have searched for this issue before posting it and there isn't an open duplicate.
  • I ran pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zip and triggered the bug in the latest version.

Telethon is directly requesting the messages to Telegram using https://core.telegram.org/method/messages.getHistory. If that doesn't include the information, that's simply how the server behaves, and not something Telethon can "fix".

Huh, well thanks for the info @Lonami! I guess this will have to do.