diff --git a/magna.php b/magna.php index 7966ed29..d70b1b38 100755 --- a/magna.php +++ b/magna.php @@ -93,9 +93,10 @@ $MadelineProto->serialize(); $times = []; $calls = []; $users = []; +$MadelineProto->get_updates(['offset' => -1]); $offset = 0; while (1) { - $updates = $MadelineProto->API->get_updates(['offset' => $offset, 'limit' => 5000, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout + $updates = $MadelineProto->get_updates(['offset' => $offset, 'limit' => 5000, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout foreach ($MadelineProto->programmed_call as $key => $pair) { list($user, $time) = $pair; if ($time < time()) { @@ -128,7 +129,7 @@ $users = []; if ($call->getCallState() === \danog\MadelineProto\VoIP::CALL_STATE_ENDED) { unset($calls[$key]); } elseif (isset($times[$call->getOtherID()]) && $times[$call->getOtherID()][0] < time()) { - $times[$call->getOtherID()][0] += 10; + $times[$call->getOtherID()][0] += 30+count($calls); try { $MadelineProto->messages->editMessage(['id' => $times[$call->getOtherID()][1], 'peer' => $call->getOtherID(), 'message' => 'Total running calls: '.count($calls).PHP_EOL.PHP_EOL.$call->getDebugString()]); diff --git a/songs.php b/songs.php index a02727f4..7fe53b18 100644 --- a/songs.php +++ b/songs.php @@ -1,6 +1,6 @@ method_call('contacts.resolveUsername', ['username' => str_replace('@', '', $username)], ['datacenter' => $this->datacenter->curdc]); + try { + $res = $this->method_call('contacts.resolveUsername', ['username' => str_replace('@', '', $username)], ['datacenter' => $this->datacenter->curdc]); + } catch (\danog\MadelineProto\RPCErrorException $e) { return false; } if ($res['_'] === 'contacts.resolvedPeer') { return $res; } - - throw new \danog\MadelineProto\Exception('resolve_username returned an unexpected constructor: '.var_export($res, true)); + return false; } public function to_supergroup($id) diff --git a/tests/testing.php b/tests/testing.php index fc7744f9..ea464647 100755 --- a/tests/testing.php +++ b/tests/testing.php @@ -34,11 +34,11 @@ if (file_exists('web_data.php')) { require_once 'web_data.php'; } -echo 'Deserializing MadelineProto from session.madeline...'.PHP_EOL; +echo 'Deserializing MadelineProto from testing.madeline...'.PHP_EOL; $MadelineProto = false; try { - $MadelineProto = new \danog\MadelineProto\API('session.madeline'); + $MadelineProto = new \danog\MadelineProto\API('testing.madeline'); } catch (\danog\MadelineProto\Exception $e) { var_dump($e->getMessage()); } @@ -82,7 +82,7 @@ if ($MadelineProto === false) { $MadelineProto->bot_login(getenv('BOT_TOKEN')); } } -$MadelineProto->session = 'session.madeline'; +$MadelineProto->session = 'testing.madeline'; \danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::ULTRA_VERBOSE); \danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::VERBOSE); \danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::NOTICE); @@ -93,7 +93,7 @@ $MadelineProto->session = 'session.madeline'; $message = (getenv('TRAVIS_COMMIT') == '') ? 'I iz works always (io laborare sembre) (yo lavorar siempre) (mi labori ĉiam) (я всегда работать) (Ik werkuh altijd) (Ngimbonga ngaso sonke isikhathi ukusebenza)' : ('Travis ci tests in progress: commit '.getenv('TRAVIS_COMMIT').', job '.getenv('TRAVIS_JOB_NUMBER').', PHP version: '.getenv('TRAVIS_PHP_VERSION')); -echo 'Serializing MadelineProto to session.madeline...'.PHP_EOL; echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('session.madeline', $MadelineProto).' bytes'.PHP_EOL; +echo 'Serializing MadelineProto to testing.madeline...'.PHP_EOL; echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('testing.madeline', $MadelineProto).' bytes'.PHP_EOL; /* $m = new \danog\MadelineProto\API($settings); $m->import_authorization($MadelineProto->export_authorization()); @@ -125,7 +125,7 @@ if (stripos(readline('Do you want to handle incoming calls? (y/n): '), 'y') !== } } } - //echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('session.madeline', $MadelineProto).' bytes'.PHP_EOL; + //echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('testing.madeline', $MadelineProto).' bytes'.PHP_EOL; } } if (stripos(readline('Do you want to make the secret chat tests? (y/n): '), 'y') !== false) { @@ -149,7 +149,7 @@ if (stripos(readline('Do you want to make the secret chat tests? (y/n): '), 'y') case 'updateNewEncryptedMessage': var_dump($update); } - echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('session.madeline', $MadelineProto).' bytes'.PHP_EOL; + echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('testing.madeline', $MadelineProto).' bytes'.PHP_EOL; } }*/