1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 06:18:58 +01:00
This commit is contained in:
Daniil Gentili 2023-07-21 17:49:55 +02:00
parent 9c3c52ce23
commit 296d9500ac
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
9 changed files with 24 additions and 17 deletions

View File

@ -5,9 +5,9 @@ Features:
Fixes:
- Fixed simple filters with service messages.
- Fixed IDE typehinting for `getEventHandler`
- Fixed IDE typehinting for `getEventHandler`.
- Fixed startAndLoopMulti
- Tweaked the default drop timeout on media DCs to avoid timeout errors on slow networks
- Tweaked the default drop timeout on media DCs to avoid timeout errors on slow networks.
- Now the admin list only contains user report peers.
---

2
docs

@ -1 +1 @@
Subproject commit 36fed16a6e3260dc30b0c116d56fe392de71f84b
Subproject commit beaafe9ef45ee1cc080a48fa565c4b63c7c64aa6

View File

@ -28,7 +28,6 @@ use danog\MadelineProto\EventHandler\Filter\FilterCommand;
use danog\MadelineProto\EventHandler\Filter\FilterRegex;
use danog\MadelineProto\EventHandler\Filter\FilterText;
use danog\MadelineProto\EventHandler\Message;
use danog\MadelineProto\EventHandler\Message\Service\DialogMessagePinned;
use danog\MadelineProto\EventHandler\Message\Service\DialogPhotoChanged;
use danog\MadelineProto\EventHandler\SimpleFilter\FromAdmin;
use danog\MadelineProto\EventHandler\SimpleFilter\Incoming;
@ -182,7 +181,6 @@ class MyEventHandler extends SimpleEventHandler
$message->reply('hello');
}
/**
* Called when the dialog photo of a chat or channel changes.
*/
@ -190,10 +188,9 @@ class MyEventHandler extends SimpleEventHandler
public function logPhotoChanged(Incoming&DialogPhotoChanged $message): void
{
if ($message->photo) {
$message->reply("Nice :D");
} else {
$message->reply("Aww, why did you delete the group photo? :(");
$message->reply("Nice! Here's a download link for the photo: ".$message->photo->getDownloadLink());
}
// The group photo was deleted
}
/**

View File

@ -20,7 +20,6 @@
use danog\MadelineProto\API;
use danog\MadelineProto\EventHandler;
use danog\MadelineProto\Logger;
/*
* Various ways to load MadelineProto

View File

@ -91,12 +91,13 @@ abstract class Filter
HasSticker::class => new FilterSticker,
HasVideo::class => new FilterVideo,
HasVoice::class => new FilterVoice,
default => is_subclass_of($type->getName(), Update::class)
default => \is_subclass_of($type->getName(), Update::class)
? new class($type->getName()) extends Filter {
public function __construct(private readonly string $class)
{
}
public function apply(Update $update): bool {
public function apply(Update $update): bool
{
return $update instanceof $this->class;
}
}

View File

@ -652,7 +652,7 @@ abstract class InternalDoc
return \danog\MadelineProto\Tools::genVectorHash($ints);
}
/**
* Get admin IDs (equal to the report peers).
* Get admin IDs (equal to all user report peers).
*/
public function getAdminIds(): array
{
@ -785,7 +785,11 @@ abstract class InternalDoc
/**
* Get event handler (or plugin instance).
*
* @param ?class-string<PluginEventHandler> $class
* @template T as EventHandler
*
* @param class-string<T>|null $class
*
* @return T|EventHandlerProxy|__PHP_Incomplete_Class|null
*/
public function getEventHandler(?string $class = null): \danog\MadelineProto\EventHandler|\danog\MadelineProto\Ipc\EventHandlerProxy|\__PHP_Incomplete_Class|null
{
@ -1089,6 +1093,13 @@ abstract class InternalDoc
{
return $this->wrapper->getAPI()->getWebMessage($message);
}
/**
* Check if has admins.
*/
public function hasAdmins(): bool
{
return $this->wrapper->getAPI()->hasAdmins();
}
/**
* Check if an event handler instance is present.
*/
@ -1985,7 +1996,7 @@ abstract class InternalDoc
/**
* Wrap a Message constructor into an abstract Message object.
*/
public function wrapMessage(array $message): ?\danog\MadelineProto\EventHandler\Message
public function wrapMessage(array $message): ?\danog\MadelineProto\EventHandler\AbstractMessage
{
return $this->wrapper->getAPI()->wrapMessage($message);
}

View File

@ -1682,7 +1682,7 @@ final class MTProto implements TLCallback, LoggerGetter
public function setReportPeers(int|string|array $userOrId): void
{
$this->reportDest = $this->sanitizeReportPeers($userOrId);
$this->admins = array_values(array_filter($this->reportDest, fn (int $v) => $v > 0));
$this->admins = \array_values(\array_filter($this->reportDest, fn (int $v) => $v > 0));
}
private ?LocalMutex $reportMutex = null;
/**

View File

@ -336,7 +336,7 @@ trait AuthKeyHandler
* Generate auth_key
*/
$this->logger->logger(
extension_loaded('gmp') ? 'Generating authorization key...' : 'Generating authorization key (install gmp to speed up this process)...',
\extension_loaded('gmp') ? 'Generating authorization key...' : 'Generating authorization key (install gmp to speed up this process)...',
Logger::VERBOSE
);
$auth_key = $g_a->powMod($b, $dh_prime);

View File

@ -24,7 +24,6 @@ use Amp\DeferredFuture;
use danog\MadelineProto\MTProto\Container;
use danog\MadelineProto\MTProto\MTProtoOutgoingMessage;
use danog\MadelineProto\TL\Exception;
use danog\MadelineProto\Tools;
use danog\MadelineProto\WrappedFuture;
use Revolt\EventLoop;