Small bugfixes for magnaluna and resolve_username
This commit is contained in:
parent
a7169969b5
commit
f0939e3725
@ -93,9 +93,10 @@ $MadelineProto->serialize();
|
|||||||
$times = [];
|
$times = [];
|
||||||
$calls = [];
|
$calls = [];
|
||||||
$users = [];
|
$users = [];
|
||||||
|
$MadelineProto->get_updates(['offset' => -1]);
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
while (1) {
|
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) {
|
foreach ($MadelineProto->programmed_call as $key => $pair) {
|
||||||
list($user, $time) = $pair;
|
list($user, $time) = $pair;
|
||||||
if ($time < time()) {
|
if ($time < time()) {
|
||||||
@ -128,7 +129,7 @@ $users = [];
|
|||||||
if ($call->getCallState() === \danog\MadelineProto\VoIP::CALL_STATE_ENDED) {
|
if ($call->getCallState() === \danog\MadelineProto\VoIP::CALL_STATE_ENDED) {
|
||||||
unset($calls[$key]);
|
unset($calls[$key]);
|
||||||
} elseif (isset($times[$call->getOtherID()]) && $times[$call->getOtherID()][0] < time()) {
|
} elseif (isset($times[$call->getOtherID()]) && $times[$call->getOtherID()][0] < time()) {
|
||||||
$times[$call->getOtherID()][0] += 10;
|
$times[$call->getOtherID()][0] += 30+count($calls);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$MadelineProto->messages->editMessage(['id' => $times[$call->getOtherID()][1], 'peer' => $call->getOtherID(), 'message' => 'Total running calls: '.count($calls).PHP_EOL.PHP_EOL.$call->getDebugString()]);
|
$MadelineProto->messages->editMessage(['id' => $times[$call->getOtherID()][1], 'peer' => $call->getOtherID(), 'message' => 'Total running calls: '.count($calls).PHP_EOL.PHP_EOL.$call->getDebugString()]);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$songs = glob('xmas/*raw');
|
$songs = glob('*raw');
|
||||||
for ($x = 0; $x < count($songs); $x++) {
|
for ($x = 0; $x < count($songs); $x++) {
|
||||||
shuffle($songs);
|
shuffle($songs);
|
||||||
}
|
}
|
||||||
|
@ -576,12 +576,13 @@ trait PeerHandler
|
|||||||
|
|
||||||
public function resolve_username($username)
|
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') {
|
if ($res['_'] === 'contacts.resolvedPeer') {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
throw new \danog\MadelineProto\Exception('resolve_username returned an unexpected constructor: '.var_export($res, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function to_supergroup($id)
|
public function to_supergroup($id)
|
||||||
|
@ -34,11 +34,11 @@ if (file_exists('web_data.php')) {
|
|||||||
require_once '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;
|
$MadelineProto = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$MadelineProto = new \danog\MadelineProto\API('session.madeline');
|
$MadelineProto = new \danog\MadelineProto\API('testing.madeline');
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
var_dump($e->getMessage());
|
var_dump($e->getMessage());
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ if ($MadelineProto === false) {
|
|||||||
$MadelineProto->bot_login(getenv('BOT_TOKEN'));
|
$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::ULTRA_VERBOSE);
|
||||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::VERBOSE);
|
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::VERBOSE);
|
||||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::NOTICE);
|
\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'));
|
$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 = new \danog\MadelineProto\API($settings);
|
||||||
$m->import_authorization($MadelineProto->export_authorization());
|
$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) {
|
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':
|
case 'updateNewEncryptedMessage':
|
||||||
var_dump($update);
|
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;
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user