1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 06:59:01 +01:00
This commit is contained in:
Daniil Gentili 2023-01-26 19:30:56 +01:00
parent cf2dd5f3c5
commit 5f08fbd9e0
4 changed files with 640 additions and 446 deletions

View File

@ -5,6 +5,7 @@ $config = new class extends Amp\CodeStyle\Config {
{
return array_merge(parent::getRules(), [
'void_return' => true,
'array_indentation' => true
]);
}
};

View File

@ -83,27 +83,220 @@ class SecretHandler extends EventHandler
$secret_media = [];
// Photo uploaded as document, secret chat
$secret_media['document_photo'] = ['peer' => $update, 'file' => 'tests/faust.jpg', 'message' => ['_' => 'decryptedMessage', 'ttl' => 0, 'message' => '', 'media' => ['_' => 'decryptedMessageMediaDocument', 'thumb' => file_get_contents('tests/faust.preview.jpg'), 'thumb_w' => 90, 'thumb_h' => 90, 'mime_type' => mime_content_type('tests/faust.jpg'), 'caption' => 'This file was uploaded using MadelineProto', 'file_name' => 'faust.jpg', 'size' => filesize('tests/faust.jpg'), 'attributes' => [['_' => 'documentAttributeImageSize', 'w' => 1280, 'h' => 914]]]]];
$secret_media['document_photo'] = [
'peer' => $update,
'file' => 'tests/faust.jpg',
'message' => [
'_' => 'decryptedMessage',
'ttl' => 0,
'message' => '',
'media' => [
'_' => 'decryptedMessageMediaDocument',
'thumb' => file_get_contents('tests/faust.preview.jpg'),
'thumb_w' => 90,
'thumb_h' => 90,
'mime_type' => mime_content_type('tests/faust.jpg'),
'caption' => 'This file was uploaded using MadelineProto',
'file_name' => 'faust.jpg',
'size' => filesize('tests/faust.jpg'),
'attributes' => [
[
'_' => 'documentAttributeImageSize',
'w' => 1280,
'h' => 914
]
]
]
]
];
// Photo, secret chat
$secret_media['photo'] = ['peer' => $update, 'file' => 'tests/faust.jpg', 'message' => ['_' => 'decryptedMessage', 'ttl' => 0, 'message' => '', 'media' => ['_' => 'decryptedMessageMediaPhoto', 'thumb' => file_get_contents('tests/faust.preview.jpg'), 'thumb_w' => 90, 'thumb_h' => 90, 'caption' => 'This file was uploaded using MadelineProto', 'size' => filesize('tests/faust.jpg'), 'w' => 1280, 'h' => 914]]];
$secret_media['photo'] = [
'peer' => $update,
'file' => 'tests/faust.jpg',
'message' => [
'_' => 'decryptedMessage',
'ttl' => 0,
'message' => '',
'media' => [
'_' => 'decryptedMessageMediaPhoto',
'thumb' => file_get_contents('tests/faust.preview.jpg'),
'thumb_w' => 90,
'thumb_h' => 90,
'caption' => 'This file was uploaded using MadelineProto',
'size' => filesize('tests/faust.jpg'),
'w' => 1280,
'h' => 914
]
]
];
// GIF, secret chat
$secret_media['gif'] = ['peer' => $update, 'file' => 'tests/pony.mp4', 'message' => ['_' => 'decryptedMessage', 'ttl' => 0, 'message' => '', 'media' => ['_' => 'decryptedMessageMediaDocument', 'thumb' => file_get_contents('tests/pony.preview.jpg'), 'thumb_w' => 90, 'thumb_h' => 90, 'mime_type' => mime_content_type('tests/pony.mp4'), 'caption' => 'test', 'file_name' => 'pony.mp4', 'size' => filesize('tests/faust.jpg'), 'attributes' => [['_' => 'documentAttributeAnimated']]]]];
$secret_media['gif'] = [
'peer' => $update,
'file' => 'tests/pony.mp4',
'message' => [
'_' => 'decryptedMessage',
'ttl' => 0,
'message' => '',
'media' => [
'_' => 'decryptedMessageMediaDocument',
'thumb' => file_get_contents('tests/pony.preview.jpg'),
'thumb_w' => 90,
'thumb_h' => 90,
'mime_type' => mime_content_type('tests/pony.mp4'),
'caption' => 'test',
'file_name' => 'pony.mp4',
'size' => filesize('tests/faust.jpg'),
'attributes' => [
['_' => 'documentAttributeAnimated']
]
]
]
];
// Sticker, secret chat
$secret_media['sticker'] = ['peer' => $update, 'file' => 'tests/lel.webp', 'message' => ['_' => 'decryptedMessage', 'ttl' => 0, 'message' => '', 'media' => ['_' => 'decryptedMessageMediaDocument', 'thumb' => file_get_contents('tests/lel.preview.jpg'), 'thumb_w' => 90, 'thumb_h' => 90, 'mime_type' => mime_content_type('tests/lel.webp'), 'caption' => 'test', 'file_name' => 'lel.webp', 'size' => filesize('tests/lel.webp'), 'attributes' => [['_' => 'documentAttributeSticker', 'alt' => 'LEL', 'stickerset' => ['_' => 'inputStickerSetEmpty']]]]]];
$secret_media['sticker'] = [
'peer' => $update,
'file' => 'tests/lel.webp',
'message' => [
'_' => 'decryptedMessage',
'ttl' => 0,
'message' => '',
'media' => [
'_' => 'decryptedMessageMediaDocument',
'thumb' => file_get_contents('tests/lel.preview.jpg'),
'thumb_w' => 90,
'thumb_h' => 90,
'mime_type' => mime_content_type('tests/lel.webp'),
'caption' => 'test',
'file_name' => 'lel.webp',
'size' => filesize('tests/lel.webp'),
'attributes' => [
[
'_' => 'documentAttributeSticker',
'alt' => 'LEL',
'stickerset' => ['_' => 'inputStickerSetEmpty']
]
]
]
]
];
// Document, secrey chat
$secret_media['document'] = ['peer' => $update, 'file' => 'tests/60', 'message' => ['_' => 'decryptedMessage', 'ttl' => 0, 'message' => '', 'media' => ['_' => 'decryptedMessageMediaDocument', 'thumb' => file_get_contents('tests/faust.preview.jpg'), 'thumb_w' => 90, 'thumb_h' => 90, 'mime_type' => 'magic/magic', 'caption' => 'test', 'file_name' => 'magic.magic', 'size' => filesize('tests/60'), 'attributes' => [['_' => 'documentAttributeFilename', 'file_name' => 'fairy']]]]];
$secret_media['document'] = [
'peer' => $update,
'file' => 'tests/60',
'message' => [
'_' => 'decryptedMessage',
'ttl' => 0,
'message' => '',
'media' => [
'_' => 'decryptedMessageMediaDocument',
'thumb' => file_get_contents('tests/faust.preview.jpg'),
'thumb_w' => 90,
'thumb_h' => 90,
'mime_type' => 'magic/magic',
'caption' => 'test',
'file_name' => 'magic.magic',
'size' => filesize('tests/60'),
'attributes' => [
[
'_' => 'documentAttributeFilename',
'file_name' => 'fairy'
]
]
]
]
];
// Video, secret chat
$secret_media['video'] = ['peer' => $update, 'file' => 'tests/swing.mp4', 'message' => ['_' => 'decryptedMessage', 'ttl' => 0, 'message' => '', 'media' => ['_' => 'decryptedMessageMediaDocument', 'thumb' => file_get_contents('tests/swing.preview.jpg'), 'thumb_w' => 90, 'thumb_h' => 90, 'mime_type' => mime_content_type('tests/swing.mp4'), 'caption' => 'test', 'file_name' => 'swing.mp4', 'size' => filesize('tests/swing.mp4'), 'attributes' => [['_' => 'documentAttributeVideo', 'duration' => 5, 'w' => 1280, 'h' => 720]]]]];
$secret_media['video'] = [
'peer' => $update,
'file' => 'tests/swing.mp4',
'message' => [
'_' => 'decryptedMessage',
'ttl' => 0,
'message' => '',
'media' => [
'_' => 'decryptedMessageMediaDocument',
'thumb' => file_get_contents('tests/swing.preview.jpg'),
'thumb_w' => 90,
'thumb_h' => 90,
'mime_type' => mime_content_type('tests/swing.mp4'),
'caption' => 'test',
'file_name' => 'swing.mp4',
'size' => filesize('tests/swing.mp4'),
'attributes' => [
[
'_' => 'documentAttributeVideo',
'duration' => 5,
'w' => 1280,
'h' => 720
]
]
]
]
];
// audio, secret chat
$secret_media['audio'] = ['peer' => $update, 'file' => 'tests/mosconi.mp3', 'message' => ['_' => 'decryptedMessage', 'ttl' => 0, 'message' => '', 'media' => ['_' => 'decryptedMessageMediaDocument', 'thumb' => file_get_contents('tests/faust.preview.jpg'), 'thumb_w' => 90, 'thumb_h' => 90, 'mime_type' => mime_content_type('tests/mosconi.mp3'), 'caption' => 'test', 'file_name' => 'mosconi.mp3', 'size' => filesize('tests/mosconi.mp3'), 'attributes' => [['_' => 'documentAttributeAudio', 'voice' => false, 'duration' => 1, 'title' => 'AH NON LO SO IO', 'performer' => 'IL DIO GERMANO MOSCONI']]]]];
$secret_media['audio'] = [
'peer' => $update,
'file' => 'tests/mosconi.mp3',
'message' => [
'_' => 'decryptedMessage',
'ttl' => 0,
'message' => '',
'media' => [
'_' => 'decryptedMessageMediaDocument',
'thumb' => file_get_contents('tests/faust.preview.jpg'),
'thumb_w' => 90,
'thumb_h' => 90,
'mime_type' => mime_content_type('tests/mosconi.mp3'),
'caption' => 'test',
'file_name' => 'mosconi.mp3',
'size' => filesize('tests/mosconi.mp3'),
'attributes' => [
[
'_' => 'documentAttributeAudio',
'voice' => false,
'duration' => 1,
'title' => 'AH NON LO SO IO',
'performer' => 'IL DIO GERMANO MOSCONI'
]
]
]
]
];
$secret_media['voice'] = ['peer' => $update, 'file' => 'tests/mosconi.mp3', 'message' => ['_' => 'decryptedMessage', 'ttl' => 0, 'message' => '', 'media' => ['_' => 'decryptedMessageMediaDocument', 'thumb' => file_get_contents('tests/faust.preview.jpg'), 'thumb_w' => 90, 'thumb_h' => 90, 'mime_type' => mime_content_type('tests/mosconi.mp3'), 'caption' => 'test', 'file_name' => 'mosconi.mp3', 'size' => filesize('tests/mosconi.mp3'), 'attributes' => [['_' => 'documentAttributeAudio', 'voice' => true, 'duration' => 1, 'title' => 'AH NON LO SO IO', 'performer' => 'IL DIO GERMANO MOSCONI']]]]];
$secret_media['voice'] = [
'peer' => $update,
'file' => 'tests/mosconi.mp3',
'message' => [
'_' => 'decryptedMessage',
'ttl' => 0,
'message' => '',
'media' => [
'_' => 'decryptedMessageMediaDocument',
'thumb' => file_get_contents('tests/faust.preview.jpg'),
'thumb_w' => 90,
'thumb_h' => 90,
'mime_type' => mime_content_type('tests/mosconi.mp3'),
'caption' => 'test',
'file_name' => 'mosconi.mp3',
'size' => filesize('tests/mosconi.mp3'),
'attributes' => [
[
'_' => 'documentAttributeAudio',
'voice' => true,
'duration' => 1,
'title' => 'AH NON LO SO IO',
'performer' => 'IL DIO GERMANO MOSCONI'
]
]
]
]
];
$promises = [];
foreach ($secret_media as $type => $smessage) {