1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-22 16:31:11 +01:00

Improve getReply

This commit is contained in:
Daniil Gentili 2023-07-23 16:47:19 +02:00
parent 69b8c64260
commit a1267b75c6
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 6 additions and 9 deletions

View File

@ -267,16 +267,12 @@ class MyEventHandler extends SimpleEventHandler
#[FilterCommand('dl')]
public function downloadLink(Incoming&Message $message): void
{
if (!$message->replyToMsgId) {
$reply = $message->getReply(Message::class);
if (!$reply?->media) {
$message->reply("This command must reply to a media message!");
return;
}
$message = $message->getReply();
if (!$message instanceof Message || !$message->media) {
$message->reply("This command must reply to a media message!");
return;
}
$message->reply("Download link: ".$message->media->getDownloadLink());
$reply->reply("Download link: ".$reply->media->getDownloadLink());
}
public static function getPluginPaths(): string|array|null

View File

@ -131,13 +131,14 @@ abstract class AbstractMessage extends Update implements SimpleFilters
}
return $this->replyCache;
}
$this->replyCache = $this->API->wrapMessage($this->API->methodCallAsyncRead(
$messages = $this->API->methodCallAsyncRead(
API::isSupergroup($this->chatId) ? 'channels.getMessages' : 'messages.getMessages',
[
'channel' => $this->chatId,
'id' => [['_' => 'inputMessageReplyTo', 'id' => $this->id]]
]
)['messages'][0]);
)['messages'];
$this->replyCache = $messages ? $this->API->wrapMessage($messages[0]) : null;
$this->replyCached = true;
if (!$this->replyCache instanceof $class) {
return null;