mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-27 03:14:39 +01:00
Reduce latency
This commit is contained in:
parent
ccf83d3aee
commit
2a648fe3bc
@ -126,8 +126,6 @@ class MyEventHandler extends SimpleEventHandler
|
||||
#[Handler]
|
||||
public function handleMessage(Incoming&Message $message): void
|
||||
{
|
||||
$this->logger($message);
|
||||
|
||||
// In this example code, send the "This userbot is powered by MadelineProto!" message only once per chat.
|
||||
// Ignore all further messages coming from this chat.
|
||||
if (!isset($this->notifiedChats[$message->chatId])) {
|
||||
|
@ -78,7 +78,7 @@ abstract class Media extends IpcCapable implements JsonSerializable
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
$v = \get_object_vars($this);
|
||||
unset($v['API'], $v['session']);
|
||||
unset($v['API'], $v['session'], $v['location']);
|
||||
$v['_'] = static::class;
|
||||
return $v;
|
||||
}
|
||||
|
@ -38,4 +38,11 @@ abstract class IpcCapable
|
||||
{
|
||||
$this->API = Client::giveInstanceBySession($this->session);
|
||||
}
|
||||
|
||||
public function __debugInfo()
|
||||
{
|
||||
$vars = \get_object_vars($this);
|
||||
unset($vars['API']);
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ final class Logger
|
||||
if ($param instanceof Throwable) {
|
||||
$param = (string) $param;
|
||||
} elseif (!\is_string($param)) {
|
||||
$param = \json_encode($param, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
$param = \json_encode($param, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR);
|
||||
}
|
||||
if (empty($file)) {
|
||||
$file = \basename(\debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]['file'], '.php');
|
||||
|
@ -829,11 +829,11 @@ trait UpdateHandler
|
||||
private function handleUpdate(array $update): void
|
||||
{
|
||||
/** @var UpdateHandlerType::EVENT_HANDLER|UpdateHandlerType::WEBHOOK|UpdateHandlerType::GET_UPDATES $this->updateHandlerType */
|
||||
EventLoop::queue(match ($this->updateHandlerType) {
|
||||
UpdateHandlerType::EVENT_HANDLER => $this->eventUpdateHandler(...),
|
||||
UpdateHandlerType::WEBHOOK => $this->pwrWebhook(...),
|
||||
UpdateHandlerType::GET_UPDATES => $this->signalUpdate(...),
|
||||
}, $update);
|
||||
match ($this->updateHandlerType) {
|
||||
UpdateHandlerType::EVENT_HANDLER => $this->eventUpdateHandler($update),
|
||||
UpdateHandlerType::WEBHOOK => EventLoop::queue($this->pwrWebhook(...), $update),
|
||||
UpdateHandlerType::GET_UPDATES => EventLoop::queue($this->signalUpdate(...), $update),
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Sends an updateCustomEvent update to the event handler.
|
||||
|
Loading…
Reference in New Issue
Block a user