对消息的反应 Telegram/Telethon

fer*_*r0m 4 telethon

“telethon”库有一个“获取消息”方法,您可以使用该方法获取消息和相关信息,包括评论。

但你能得到反应吗? https://core.telegram.org/method/messages.getMessageReactionsList

Msh*_*sha 5

我找不到通过电视马拉松来做到这一点的方法。但是,您可以使用pyrogram获取对消息的反应列表:GetMessageReactionsList

像这样的东西:

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
            )
        )
Run Code Online (Sandbox Code Playgroud)

UPD 找到了一个更简单的方法:

with app:
    peer = app.resolve_peer(chat_id)

    for message in app.iter_history(chat_id=chat_id):
        print(message.reactions)
Run Code Online (Sandbox Code Playgroud)