From 622f37fb2dbead17b35f14ddea3d1c09c625b019 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 27 Mar 2018 15:41:58 +0200 Subject: [PATCH] Bugfixes --- magna.php | 3 + .../MadelineProto/MyTelegramOrgWrapper.php | 4 +- src/danog/MadelineProto/VoIP.php | 93 +++++++++++++++++++ 3 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 src/danog/MadelineProto/VoIP.php diff --git a/magna.php b/magna.php index 7aea208c..537576cb 100755 --- a/magna.php +++ b/magna.php @@ -22,6 +22,7 @@ echo 'Deserializing MadelineProto from session.madeline...'.PHP_EOL; try { $MadelineProto = new \danog\MadelineProto\API('session.madeline'); } catch (\danog\MadelineProto\Exception $e) { + echo $e.PHP_EOL; unlink('session.madeline'); $MadelineProto = new \danog\MadelineProto\API('session.madeline'); } @@ -62,6 +63,8 @@ function configureCall($call) $call->parseConfig(); $call->playOnHold($songs); } +//$c = $MadelineProto->request_call('@danogentili'); +//configureCall($c); $MadelineProto->get_updates(['offset' => -1]); $offset = 0; diff --git a/src/danog/MadelineProto/MyTelegramOrgWrapper.php b/src/danog/MadelineProto/MyTelegramOrgWrapper.php index 2c606a09..97322547 100644 --- a/src/danog/MadelineProto/MyTelegramOrgWrapper.php +++ b/src/danog/MadelineProto/MyTelegramOrgWrapper.php @@ -208,7 +208,7 @@ return false; curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate'); $headers = []; - $headers[] = "Cookie: stel_token=$token"; + $headers[] = "Cookie: stel_token=".$this->token; $headers[] = 'Origin: https://my.telegram.org'; $headers[] = 'Accept-Encoding: gzip, deflate, br'; $headers[] = 'Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4'; @@ -243,7 +243,7 @@ return false; $headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'; $headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'; $headers[] = 'Referer: https://my.telegram.org/'; - $headers[] = "Cookie: stel_token=$token"; + $headers[] = "Cookie: stel_token=".$this->token; $headers[] = 'Connection: keep-alive'; $headers[] = 'Cache-Control: max-age=0'; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); diff --git a/src/danog/MadelineProto/VoIP.php b/src/danog/MadelineProto/VoIP.php new file mode 100644 index 00000000..c5efac6a --- /dev/null +++ b/src/danog/MadelineProto/VoIP.php @@ -0,0 +1,93 @@ +. +*/ +namespace danog\MadelineProto; + +if (!extension_loaded('php-libtgvoip')) { + class VoIP + { + const PHP_LIBTGVOIP_VERSION = '1.1.2'; + const STATE_CREATED = 0; + const STATE_WAIT_INIT = 1; + const STATE_WAIT_INIT_ACK = 2; + const STATE_ESTABLISHED = 3; + const STATE_FAILED = 4; + const STATE_RECONNECTING = 5; + + const TGVOIP_ERROR_UNKNOWN = 0; + const TGVOIP_ERROR_INCOMPATIBLE = 1; + const TGVOIP_ERROR_TIMEOUT = 2; + const TGVOIP_ERROR_AUDIO_IO = 3; + + const NET_TYPE_UNKNOWN = 0; + const NET_TYPE_GPRS = 1; + const NET_TYPE_EDGE = 2; + const NET_TYPE_3G = 3; + const NET_TYPE_HSPA = 4; + const NET_TYPE_LTE = 5; + const NET_TYPE_WIFI = 6; + const NET_TYPE_ETHERNET = 7; + const NET_TYPE_OTHER_HIGH_SPEED = 8; + const NET_TYPE_OTHER_LOW_SPEED = 9; + const NET_TYPE_DIALUP = 10; + const NET_TYPE_OTHER_MOBILE = 11; + + const DATA_SAVING_NEVER = 0; + const DATA_SAVING_MOBILE = 1; + const DATA_SAVING_ALWAYS = 2; + + const PROXY_NONE = 0; + const PROXY_SOCKS5 = 1; + + const AUDIO_STATE_NONE = -1; + const AUDIO_STATE_CREATED = 0; + const AUDIO_STATE_CONFIGURED = 1; + const AUDIO_STATE_RUNNING = 2; + + const CALL_STATE_NONE = -1; + const CALL_STATE_REQUESTED = 0; + const CALL_STATE_INCOMING = 1; + const CALL_STATE_ACCEPTED = 2; + const CALL_STATE_CONFIRMED = 3; + const CALL_STATE_READY = 4; + const CALL_STATE_ENDED = 5; + + private $MadelineProto; + public $configuration = []; + public $storage = []; + private $internalStorage = []; + private $otherID; + private $creator; + private $callState; + private $callID; + private $visualization; + + public function __construct($creator, $otherID, $callID, $MadelineProto, $callState, $protocol) { + $this->creator = $creator; + $this->otherID = $otherID; + $this->callID = $callID; + $this->MadelineProto = $MadelineProto; + $this->callState = $callState; + $this->configuration['protocol'] = $protocol; + } + public function setVisualization($visualization) { + $this->visualization = $visualization; + } + public function parseConfig() { + } + public function startTheMagic() { + var_dump($this->configuration); + } + public function getCallState() { + return $this->callState; + } + } +}