1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 09:38:57 +01:00

Improve performance a bit

This commit is contained in:
Daniil Gentili 2023-07-13 16:54:57 +02:00
parent 48e17f6ff2
commit ccf83d3aee
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
4 changed files with 12 additions and 11 deletions

View File

@ -44,9 +44,9 @@ abstract class AbstractMessage extends Update implements SimpleFilters
public function __construct(
MTProto $API,
array $rawMessage,
array $info
) {
parent::__construct($API);
$info = $this->API->getInfo($rawMessage);
$this->out = $rawMessage['out'];
$this->id = $rawMessage['id'];

View File

@ -76,9 +76,9 @@ abstract class Message extends AbstractMessage
public function __construct(
MTProto $API,
array $rawMessage,
array $info,
) {
parent::__construct($API, $rawMessage);
$info = $this->API->getInfo($rawMessage);
parent::__construct($API, $rawMessage, $info);
$this->entities = $rawMessage['entities'] ?? null;
$this->message = $rawMessage['message'];

View File

@ -18,9 +18,10 @@ final class ChannelMessage extends Message
/** @internal */
public function __construct(
MTProto $API,
array $rawMessage
array $rawMessage,
array $info
) {
parent::__construct($API, $rawMessage);
parent::__construct($API, $rawMessage, $info);
$this->views = $rawMessage['views'];
$this->signature = $rawMessage['post_author'] ?? null;

View File

@ -381,14 +381,14 @@ trait UpdateHandler
default => null
};
}
$id = $this->getIdInternal($message);
if (($this->chats[$id]['username'] ?? '') === 'replies') {
$info = $this->getInfo($message);
if (($this->chats[$info['bot_api_id']]['username'] ?? '') === 'replies') {
return null;
}
return match ($this->getType($id)) {
API::PEER_TYPE_BOT, API::PEER_TYPE_USER => new PrivateMessage($this, $message),
API::PEER_TYPE_GROUP, API::PEER_TYPE_SUPERGROUP => new GroupMessage($this, $message),
API::PEER_TYPE_CHANNEL => new ChannelMessage($this, $message),
return match ($info['type']) {
API::PEER_TYPE_BOT, API::PEER_TYPE_USER => new PrivateMessage($this, $message, $info),
API::PEER_TYPE_GROUP, API::PEER_TYPE_SUPERGROUP => new GroupMessage($this, $message, $info),
API::PEER_TYPE_CHANNEL => new ChannelMessage($this, $message, $info),
};
}
/**