1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-22 16:51:16 +01:00
This commit is contained in:
Daniil Gentili 2023-09-28 21:03:56 +02:00
parent ef259dce4f
commit eec2605a9f
11 changed files with 13 additions and 14 deletions

View File

@ -60,7 +60,6 @@ final class BotApp implements JsonSerializable
/** The bot is asking permission to send messages to the user: if the user agrees, set the write_allowed flag when invoking [messages.requestAppWebView](https://docs.madelineproto.xyz/API_docs/methods/messages.requestAppWebView.html). */
public readonly ?bool $requestWriteAccess = null,
public readonly ?bool $hasSettings = null,
) {
$this->id = $rawBotApp['id'];

View File

@ -19,7 +19,6 @@ namespace danog\MadelineProto\EventHandler;
use Amp\ByteStream\ReadableStream;
use danog\MadelineProto\Ipc\IpcCapable;
use danog\MadelineProto\MTProto;
use danog\MadelineProto\TL\Types\Bytes;
use JsonSerializable;
/**
@ -100,8 +99,8 @@ abstract class Media extends IpcCapable implements JsonSerializable
$this->ttl = $rawMedia['ttl_seconds'] ?? null;
$this->spoiler = $rawMedia['spoiler'] ?? false;
$this->keyFingerprint = $rawMedia['file']['key_fingerprint'] ?? null;
$this->key = isset($rawMedia['key']) ? (string)$rawMedia['key'] : null;
$this->iv = isset($rawMedia['iv']) ? (string)$rawMedia['iv'] : null;
$this->key = isset($rawMedia['key']) ? (string) $rawMedia['key'] : null;
$this->iv = isset($rawMedia['iv']) ? (string) $rawMedia['iv'] : null;
}
/**

View File

@ -40,7 +40,7 @@ final class Document extends Media
bool $protected
) {
parent::__construct($API, $rawMedia, $protected);
$this->thumb = isset($rawMedia['thumb']) ? new Bytes($rawMedia['thumb']) : null;
$this->thumb = $rawMedia['thumb'] ?? null;
$this->thumbHeight = $rawMedia['thumb_h'] ?? null;
$this->thumbWidth = $rawMedia['thumb_w'] ?? null;
}

View File

@ -49,7 +49,7 @@ final class Video extends AbstractVideo
}
}
$this->hasStickers = $hasStickers;
$this->thumb = isset($rawMedia['thumb']) ? new Bytes($rawMedia['thumb']) : null;
$this->thumb = $rawMedia['thumb'] ?? null;
$this->thumbHeight = $rawMedia['thumb_h'] ?? null;
$this->thumbWidth = $rawMedia['thumb_w'] ?? null;
}

View File

@ -711,7 +711,7 @@ abstract class InternalDoc
*
* @param array $config Current config
*/
public function getConfig(array $config = [
public function getConfig(array $config = [
]): array
{
return $this->wrapper->getAPI()->getConfig($config);
@ -1102,7 +1102,7 @@ abstract class InternalDoc
* @param array{offset?: int, limit?: int, timeout?: float} $params Params
* @return list<array{update_id: mixed, update: mixed}>
*/
public function getUpdates(array $params = [
public function getUpdates(array $params = [
]): array
{
return $this->wrapper->getAPI()->getUpdates($params);

View File

@ -98,7 +98,7 @@ trait Files
}
return new Photo($this, $media, $protected);
}
if ($media['_'] === 'decryptedMessageMediaDocument'
if ($media['_'] === 'decryptedMessageMediaDocument'
|| $media['_'] === 'decryptedMessageMediaExternalDocument'
) {
// TODO caption?

View File

@ -65,7 +65,6 @@ use danog\MadelineProto\EventHandler\Message\Service\DialogTitleChanged;
use danog\MadelineProto\EventHandler\Message\Service\DialogTopicCreated;
use danog\MadelineProto\EventHandler\Message\Service\DialogTopicEdited;
use danog\MadelineProto\EventHandler\Message\Service\DialogWebView;
use danog\MadelineProto\EventHandler\Typing\SecretUserTyping;
use danog\MadelineProto\EventHandler\Privacy;
use danog\MadelineProto\EventHandler\Query\ChatButtonQuery;
use danog\MadelineProto\EventHandler\Query\ChatGameQuery;
@ -75,6 +74,7 @@ use danog\MadelineProto\EventHandler\Story\Story;
use danog\MadelineProto\EventHandler\Story\StoryDeleted;
use danog\MadelineProto\EventHandler\Story\StoryReaction;
use danog\MadelineProto\EventHandler\Typing\ChatUserTyping;
use danog\MadelineProto\EventHandler\Typing\SecretUserTyping;
use danog\MadelineProto\EventHandler\Typing\SupergroupUserTyping;
use danog\MadelineProto\EventHandler\Typing\UserTyping;
use danog\MadelineProto\EventHandler\Update;

View File

@ -4,7 +4,7 @@ namespace danog\MadelineProto\Namespace;
final class Blacklist
{
public const BLACKLIST = [
public const BLACKLIST = [
'account.updatePasswordSettings' => 'You cannot use this method directly; use $MadelineProto->update2fa($params), instead (see https://docs.madelineproto.xyz for more info)',
'account.getPasswordSettings' => 'You cannot use this method directly; use $MadelineProto->update2fa($params), instead (see https://docs.madelineproto.xyz for more info)',
'messages.receivedQueue' => 'You cannot use this method directly',

View File

@ -49,7 +49,7 @@ final class SecretChat extends IpcCapable
*
* @param integer $randomId Secret chat message ID.
*/
public function getMessage(int $randomId): array
public function getMessage(int $randomId): \danog\MadelineProto\EventHandler\Message\SecretMessage
{
return $this->getClient()->getSecretMessage($this->chatId, $randomId);
}

View File

@ -401,7 +401,7 @@ final class SecretChatController implements Stringable
$msg['message']['date'] = $response['date'];
$msg['message']['decrypted_message'] = $msg['message']['message'];
unset($msg['message']['message']);
if (isset($msg['message']['decrypted_message']['media'])
if (isset($msg['message']['decrypted_message']['media'])
&& $msg['message']['decrypted_message']['media']['_'] !== 'decryptedMessageMediaEmpty'
) {
$msg['message']['file'] = $response['file'];
@ -428,7 +428,7 @@ final class SecretChatController implements Stringable
$decryptedMessage = $update['message']['decrypted_message'];
if ($decryptedMessage['_'] === 'decryptedMessage') {
if (isset($update['message']['decrypted_message']['media'])
if (isset($update['message']['decrypted_message']['media'])
&& $update['message']['decrypted_message']['media']['_'] !== 'decryptedMessageMediaEmpty'
) {
$update['message']['decrypted_message']['media']['file'] = $update['message']['file'];

View File

@ -394,6 +394,7 @@ trait BotAPI
case 'decryptedMessageMediaDocument':
case 'decryptedMessageMediaDocument':
$data = $data['file'];
// no break
case 'encryptedFile':
$fileId = new FileId;
$fileId->setId($data['id']);