skip to Main Content

The "telethon" library has a "get messages" method, with which you can get a message and information about it, including comments.

But can you get reactions?
https://core.telegram.org/method/messages.getMessageReactionsList

3

Answers


  1. I couldn’t find a way to do this via telethon.
    However, you can get a list of reactions to messages using pyrogram: GetMessageReactionsList

    Something like that:

    from pyrogram import Client
    from pyrogram.raw.functions.messages import GetMessageReactionsList
    
    
    app = Client(
        "my_account",
        api_id=12345678,
        api_hash='XXX'
    )
    
    chat_id = -123456789
    
    with app:
        peer = app.resolve_peer(chat_id)
    
        for message in app.iter_history(chat_id=chat_id):
            reactions = app.send(
                GetMessageReactionsList(
                    peer=peer,
                    id=message.message_id,
                    limit=100
                )
            )
    

    UPD
    Found an easier way:

    with app:
        peer = app.resolve_peer(chat_id)
    
        for message in app.iter_history(chat_id=chat_id):
            print(message.reactions)
    
    Login or Signup to reply.
  2. I recently was looking for reactions as well and discovered the GetMessagesReactionsRequest() function from the Telegram API methods list:

    with TelegramClient(session, api_id, api_hash) as client:
         reaction = client(GetMessagesReactionsRequest(chat_test, id=[4775]))
    

    Where ID is the message ID. There might be a more efficient solution, as soon as I found it I’ll let you know.

    Login or Signup to reply.
  3. In telethon 1.25.4 you can get it easily:

    with TelegramClient(session, api_id, api_hash) as client:
        for message in client.get_messages('@'+channelusername):
            print(message.reactions)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search