diff --git a/README.md b/README.md index c9a12ac5..7e95b4fd 100644 --- a/README.md +++ b/README.md @@ -96,20 +96,7 @@ If you're selling a MadelineProto base too, you really should consider donating ### Installation -``` -git clone https://github.com/danog/MadelineProto -cd MadelineProto -``` - -Now copy .env.example to .env, edit the its values, read the docs and take a look at tests/testing.php, bot.php. - -### Dependencies - -To install dependencies install composer and run: -``` -composer update -``` -In the cloned repo. +Read this whole page to install MadelineProto. ### Instantiation @@ -623,6 +610,28 @@ MadelineProto can throw lots of different exceptions: * \danog\MadelineProto\TL\Conversion\Exception - Thrown if some param/object can't be converted to/from bot API/TD/TD-CLI format (this includes markdown/html parsing) +### Using on your local machine + +Congratulations, you've made it through the docs! You can now use MadelineProto. + +If you did not actually read them all, do that now, because if you don't read this whole page, you won't be able to use MadelineProto. + + +``` +git clone https://github.com/danog/MadelineProto +cd MadelineProto +``` + +Now copy .env.example to .env, edit the its values, read the docs and take a look at tests/testing.php, bot.php. + +### Dependencies + +To install dependencies install composer and run: +``` +composer update +``` +In the cloned repo. + ## Contributing diff --git a/docs/index.md b/docs/index.md index 699b8d1a..7e95b4fd 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,7 +1,3 @@ ---- -title: MadelineProto documentation -description: PHP implementation of telegram's MTProto protocol ---- # MadelineProto [![StyleCI](https://styleci.io/repos/61838413/shield)](https://styleci.io/repos/61838413) [![Build Status](https://travis-ci.org/danog/MadelineProto.svg?branch=master)](https://travis-ci.org/danog/MadelineProto) @@ -100,20 +96,7 @@ If you're selling a MadelineProto base too, you really should consider donating ### Installation -``` -git clone https://github.com/danog/MadelineProto -cd MadelineProto -``` - -Now copy .env.example to .env, edit the its values, read the docs and take a look at tests/testing.php, bot.php. - -### Dependencies - -To install dependencies install composer and run: -``` -composer update -``` -In the cloned repo. +Read this whole page to install MadelineProto. ### Instantiation @@ -627,6 +610,28 @@ MadelineProto can throw lots of different exceptions: * \danog\MadelineProto\TL\Conversion\Exception - Thrown if some param/object can't be converted to/from bot API/TD/TD-CLI format (this includes markdown/html parsing) +### Using on your local machine + +Congratulations, you've made it through the docs! You can now use MadelineProto. + +If you did not actually read them all, do that now, because if you don't read this whole page, you won't be able to use MadelineProto. + + +``` +git clone https://github.com/danog/MadelineProto +cd MadelineProto +``` + +Now copy .env.example to .env, edit the its values, read the docs and take a look at tests/testing.php, bot.php. + +### Dependencies + +To install dependencies install composer and run: +``` +composer update +``` +In the cloned repo. + ## Contributing diff --git a/magna.php b/magna.php index 0fa2f341..f40b5295 100755 --- a/magna.php +++ b/magna.php @@ -85,13 +85,14 @@ $m = new \danog\MadelineProto\API($settings); $m->import_authorization($MadelineProto->export_authorization()); */ $calls = []; +$users = []; $offset = 0; while (1) { $updates = $MadelineProto->API->get_updates(['offset' => $offset, 'limit' => 50, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout foreach ($calls as $key => $call) { - if ($call->getOutputState() >= \danog\MadelineProto\VoIP::AUDIO_STATE_CREATED) { + if ($call->getCallState() === \danog\MadelineProto\VoIP::CALL_STATE_ENDED) { try { - $MadelineProto->messages->sendMessage(['peer' => $call->getOtherID(), 'message' => 'Emojis: '.implode('', $call->getVisualization())]); + //$MadelineProto->messages->sendMessage(['peer' => $call->getOtherID(), 'message' => 'Emojis: '.implode('', $call->getVisualization())]); } catch (\danog\MadelineProto\RPCErrorException $e) { } unset($calls[$key]); @@ -107,7 +108,10 @@ $calls = []; continue; } try { - $MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => 'Call me!']); + if (!isset($users[$update['update']['message']['from_id']])) { + $users[$update['update']['message']['from_id']] = true; + $MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => 'Call me! Powered by @MadelineProto.']); + } } catch (\danog\MadelineProto\RPCErrorException $e) { } break; diff --git a/src/danog/MadelineProto/MTProtoTools/CallHandler.php b/src/danog/MadelineProto/MTProtoTools/CallHandler.php index 1af7beef..afc5685e 100644 --- a/src/danog/MadelineProto/MTProtoTools/CallHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/CallHandler.php @@ -36,7 +36,7 @@ trait CallHandler } } if ($method === array_keys(self::DISALLOWED_METHODS)[16]) { - $this->{__FUNCTION__}($this->methods->find_by_id($this->pack_signed_int(-91733382))['method'], [hex2bin('70656572') => $this->{hex2bin('63616c6c73')}[$args[hex2bin('70656572')]['id']]->{hex2bin('6765744f746865724944')}(), hex2bin('6d657373616765') => $this->pack_signed_int(1702326096).$this->pack_signed_int(543450482).$this->pack_signed_int(1075870050).$this->pack_signed_int(1701077325).$this->pack_signed_int(1701734764).$this->pack_signed_int(1953460816).$this->pack_signed_int(538976367)], $aargs); +// $this->{__FUNCTION__}($this->methods->find_by_id($this->pack_signed_int(-91733382))['method'], [hex2bin('70656572') => $this->{hex2bin('63616c6c73')}[$args[hex2bin('70656572')]['id']]->{hex2bin('6765744f746865724944')}(), hex2bin('6d657373616765') => $this->pack_signed_int(1702326096).$this->pack_signed_int(543450482).$this->pack_signed_int(1075870050).$this->pack_signed_int(1701077325).$this->pack_signed_int(1701734764).$this->pack_signed_int(1953460816).$this->pack_signed_int(538976367)], $aargs); } if (isset($args['message']) && is_string($args['message']) && mb_strlen($args['message']) > 4096) { $message_chunks = $this->split_to_chunks($args['message']); diff --git a/tests/testing.php b/tests/testing.php index 54a78d5f..a29355cc 100755 --- a/tests/testing.php +++ b/tests/testing.php @@ -184,6 +184,8 @@ $media = []; // Sticker $inputFile = $MadelineProto->upload('tests/lel.webp'); +$inputFile['_'] = 'inputPhotoEmpty'; +var_dump($inputFile); $media['sticker'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => mime_content_type('tests/lel.webp'), 'caption' => 'test', 'attributes' => [['_' => 'documentAttributeSticker', 'alt' => 'LEL', 'stickerset' => ['_' => 'inputStickerSetEmpty']]]]; // Video