mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 08:18:59 +01:00
Fixes
This commit is contained in:
parent
2acd733355
commit
8dffdd0ff4
@ -79,7 +79,7 @@ class SecretHandler extends SimpleEventHandler
|
||||
if ($update->media) {
|
||||
$this->logger($update->media->downloadToDir('/tmp'));
|
||||
}
|
||||
if (isset($this->sent[$update->chatId])) {
|
||||
/*if (isset($this->sent[$update->chatId])) {
|
||||
return;
|
||||
}
|
||||
$secret_media = [];
|
||||
@ -312,7 +312,7 @@ class SecretHandler extends SimpleEventHandler
|
||||
// You can also use the sendEncrypted parameter for more options in secret chats
|
||||
$this->sendMessage(peer: $update->chatId, message: (string) ($i++));
|
||||
}
|
||||
$this->sent[$update->chatId] = true;
|
||||
$this->sent[$update->chatId] = true;*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ 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;
|
||||
|
||||
/**
|
||||
@ -62,10 +63,10 @@ abstract class Media extends IpcCapable implements JsonSerializable
|
||||
/** @internal Media location */
|
||||
public readonly array $location;
|
||||
|
||||
/** Encryption key for secret chat files */
|
||||
private readonly ?string $key;
|
||||
/** Encryption key for secret chat files */
|
||||
private readonly ?string $iv;
|
||||
/** @internal Encryption key for secret chat files */
|
||||
public readonly ?Bytes $key;
|
||||
/** @internal Encryption key for secret chat files */
|
||||
public readonly ?Bytes $iv;
|
||||
|
||||
/** @internal */
|
||||
public function __construct(
|
||||
@ -143,7 +144,7 @@ abstract class Media extends IpcCapable implements JsonSerializable
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
$v = \get_object_vars($this);
|
||||
unset($v['API'], $v['session'], $v['location']);
|
||||
unset($v['API'], $v['session'], $v['location'], $v['key'], $v['iv']);
|
||||
return $v;
|
||||
}
|
||||
}
|
||||
|
@ -77,15 +77,18 @@ trait Files
|
||||
*/
|
||||
public function wrapMedia(array $media, bool $protected = false): ?Media
|
||||
{
|
||||
if ($media['_'] === 'photo' || $media['_'] === 'decryptedMessageMediaPhoto') {
|
||||
if ($media['_'] === 'photo') {
|
||||
$media = [ '_' => 'messageMediaPhoto', 'photo' => $media ];
|
||||
}
|
||||
if ($media['_'] === 'document' || $media['_'] === 'decryptedMessageMediaDocument' || $media['_'] === 'decryptedMessageMediaExternalDocument') {
|
||||
if ($media['_'] === 'document') {
|
||||
$media = [ '_' => 'messageMediaDocument', 'document' => $media];
|
||||
}
|
||||
if ($media['_'] === 'decryptedMessageMediaAudio') {
|
||||
return new Audio($this, $media, $media, $protected);
|
||||
}
|
||||
if ($media['_'] === 'decryptedMessageMediaPhoto') {
|
||||
return new Photo($this, $media, $protected);
|
||||
}
|
||||
if ($media['_'] === 'decryptedMessageMediaVideo') {
|
||||
return new Video($this, $media, $media, $protected);
|
||||
}
|
||||
@ -95,7 +98,10 @@ trait Files
|
||||
}
|
||||
return new Photo($this, $media, $protected);
|
||||
}
|
||||
if ($media['_'] !== 'messageMediaDocument') {
|
||||
if ($media['_'] !== 'messageMediaDocument'
|
||||
&& $media['_'] === 'decryptedMessageMediaDocument'
|
||||
&& $media['_'] === 'decryptedMessageMediaExternalDocument'
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
if (!isset($media['document'])) {
|
||||
|
@ -404,6 +404,7 @@ final class SecretChatController implements Stringable
|
||||
if (isset($response['file']) && $response['file']['_'] !== 'encryptedFileEmpty') {
|
||||
$msg['message']['file'] = $response['file'];
|
||||
$msg['message']['decrypted_message']['media']['file'] = $response['file'];
|
||||
$msg['message']['decrypted_message']['media']['date'] = $response['date'];
|
||||
}
|
||||
$msg['message']['decrypted_message']['out'] = true;
|
||||
$msg['message']['decrypted_message']['date'] = $msg['message']['date'];
|
||||
@ -426,6 +427,7 @@ final class SecretChatController implements Stringable
|
||||
if ($decryptedMessage['_'] === 'decryptedMessage') {
|
||||
if (isset($update['message']['file']) && $update['message']['file']['_'] !== 'encryptedFileEmpty') {
|
||||
$update['message']['decrypted_message']['media']['file'] = $update['message']['file'];
|
||||
$update['message']['decrypted_message']['media']['date'] = $update['message']['date'];
|
||||
}
|
||||
$this->API->saveUpdate($update);
|
||||
return;
|
||||
|
@ -388,6 +388,12 @@ trait BotAPI
|
||||
$res['file_id'] = (string) $fileId;
|
||||
$res['file_unique_id'] = $fileId->getUniqueBotAPI();
|
||||
return [$type_name => $res, 'caption' => $data['caption'] ?? ''];
|
||||
case 'decryptedMessageMediaAudio':
|
||||
case 'decryptedMessageMediaPhoto':
|
||||
case 'decryptedMessageMediaVideo':
|
||||
case 'decryptedMessageMediaDocument':
|
||||
case 'decryptedMessageMediaDocument':
|
||||
$data = $data['file'];
|
||||
case 'encryptedFile':
|
||||
$fileId = new FileId;
|
||||
$fileId->setId($data['id']);
|
||||
@ -402,7 +408,7 @@ trait BotAPI
|
||||
'file_size' => $data['size'],
|
||||
'mime_type' => 'application/octet-stream'
|
||||
];
|
||||
return ['encrypted' => $res, 'caption' => $data['caption'] ?? ''];
|
||||
return ['encrypted' => $res];
|
||||
default:
|
||||
throw new Exception(\sprintf(Lang::$current_lang['botapi_conversion_error'], $data['_']));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user