Torkusz
@Torkusz
Самоучка python

Как воспользоваться методом messages.report из API телеграмм?

не понимаю как воспользоваться методом. Использую библиотеку pyrogram
  • Вопрос задан
  • 197 просмотров
Решения вопроса 1
gnifajio
@gnifajio
Совершенствуюсь каждый день
1, 2, 3

Выжимка:
from pyrogram.raw.functions.account import ReportPeer
from pyrogram.raw.types import *


# Edited. Forgot to replace types2 classes you've putted in your code 
def get_report_reason(text):
    if text == "Report for child abuse.":
        return InputReportReasonChildAbuse()
    elif text == "Report for impersonation.":
        return InputReportReasonFake()
    elif text == "Report for copyrighted content.":
        return InputReportReasonCopyright()
    elif text == "Report an irrelevant geogroup.":
        return InputReportReasonGeoIrrelevant()
    elif text == "Other.":
        return InputReportReasonOther()


peer        = app.resolve_peer("@test")
peer_id     = peer["channel_id"]
access_hash = peer["access_hash"]

# Also you have to determine here what type of peer is that. 
# Lets take channel.
channel = InputPeerChannel(channel_id=peer_id, access_hash=access_hash)
reason  = get_report_reason(report_reason)

report_peer = ReportPeer(
    peer=channel, 
    reason=reason, 
    message="text"
)
report = app.send(report_peer)
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы