1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-22 09:51:15 +01:00

Small bugfixes for magnaluna and resolve_username

This commit is contained in:
Daniil Gentili 2018-02-18 17:26:14 +00:00
parent a7169969b5
commit f0939e3725
4 changed files with 14 additions and 12 deletions

View File

@ -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()]);

View File

@ -1,6 +1,6 @@
<?php
$songs = glob('xmas/*raw');
$songs = glob('*raw');
for ($x = 0; $x < count($songs); $x++) {
shuffle($songs);
}

View File

@ -576,12 +576,13 @@ trait PeerHandler
public function resolve_username($username)
{
$res = $this->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)

View File

@ -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;
}
}*/