KurimuzonAkuma / pyrogram

Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots
https://pyrogram.org
GNU Lesser General Public License v3.0
268 stars 72 forks source link

SendScreenshotNotification not working #40

Closed SuperZombi closed 3 months ago

SuperZombi commented 3 months ago

Checklist

Description

On the official version of pyrogram (2.0.106), the notification for sending screenshots worked. Doesn't work on your fork (2.1.16)

Steps to reproduce

client.invoke(SendScreenshotNotification(
      peer=client.resolve_peer(message.chat.id),
      reply_to_msg_id=message.id,
      random_id=app.rnd_id()
))
TypeError: SendScreenshotNotification.__init__() got an unexpected keyword argument 'reply_to_msg_id'


I tried changing the attribute name:

client.invoke(SendScreenshotNotification(
      peer=client.resolve_peer(message.chat.id),
      reply_to=message.id,
      random_id=app.rnd_id()
))
File "pyrogram\raw\functions\messages\send_screenshot_notification.py", line 84, in write
  b.write(self.reply_to.write())
          ^^^^^^^^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'write'

But it still doesn't work

Code example

No response

Logs

No response

KurimuzonAkuma commented 3 months ago

Все работает, просто ты не так юзаешь. reply_to принимает тип raw.base.InputReplyTo, а ты пихаешь инт...

SuperZombi commented 3 months ago

Found a solution. Need to use get_reply_to:

from pyrogram.raw.functions.messages import SendScreenshotNotification
from pyrogram.utils import get_reply_to

client.invoke(SendScreenshotNotification(
      peer=client.resolve_peer(message.chat.id),
      reply_to=get_reply_to(reply_to_message_id=message.id),
      random_id=client.rnd_id()
))
SuperZombi commented 3 months ago

Вобще я предлагаю сделать по нормальному функцию, чтобы это выглядело примерно вот так:

SendScreenshotNotification(
    chat_id=message.chat.id
)