mirror of
https://github.com/danog/MadelineProto.git
synced 2025-01-22 16:31:11 +01:00
Improve getReply
This commit is contained in:
parent
69b8c64260
commit
a1267b75c6
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user