Bugfixes to peer management

This commit is contained in:
Daniil Gentili 2018-03-11 17:36:32 +00:00
parent c26a5aaf77
commit d833b0cff8
3 changed files with 12 additions and 8 deletions

View File

@ -18,6 +18,7 @@ class API extends APIFactory
use \danog\Serializable;
public $session;
public $serialized = 0;
public $API;
public function __magic_construct($params = [])
{
@ -25,7 +26,6 @@ class API extends APIFactory
if (is_string($params)) {
$realpaths = Serialization::realpaths($params);
if (file_exists($realpaths['file'])) {
$this->session = $realpaths['file'];
if (!file_exists($realpaths['lockfile'])) {
touch($realpaths['lockfile']);
clearstatcache();
@ -71,6 +71,7 @@ class API extends APIFactory
if (isset($unserialized->API)) {
$this->API = $unserialized->API;
$this->APIFactory();
$this->session = $realpaths['file'];
}
return;
@ -88,7 +89,6 @@ class API extends APIFactory
public function __wakeup()
{
//if (method_exists($this->API, 'wakeup')) $this->API = $this->API->wakeup();
$this->APIFactory();
}

View File

@ -35,7 +35,13 @@ trait PeerHandler
foreach ($users as $key => $user) {
if (!isset($user['access_hash'])) {
if (isset($user['username']) && !isset($this->chats[$user['id']])) {
$this->get_pwr_chat($user['username'], false, true);
try {
$this->get_pwr_chat($user['username'], false, true);
} catch (\danog\MadelineProto\Exception $e) {
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING);
} catch (\danog\MadelineProto\RPCErrorException $e) {
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING);
}
}
continue;
}
@ -115,6 +121,8 @@ trait PeerHandler
{
try {
return isset($this->chats[$this->get_info($id)['bot_api_id']]);
} catch (\danog\MadelineProto\Exception $e) {
return false;
} catch (\danog\MadelineProto\RPCErrorException $e) {
if ($e->rpc === 'CHAT_FORBIDDEN') {
return true;
@ -656,7 +664,7 @@ trait PeerHandler
$this->qres = [];
$this->last_stored = time() + 10;
} catch (\danog\MadelineProto\Exception $e) {
\danog\MadelineProto\Logger::log('======= COULD NOT STORE IN DB DUE TO '.$e->getMessage().' =============', \danog\MadelineProto\Logger::VERBOSE);
\danog\MadelineProto\Logger::log("======= COULD NOT STORE IN DB DUE TO ".$e->getMessage()." =============", \danog\MadelineProto\Logger::VERBOSE);
}
}

View File

@ -326,10 +326,6 @@ trait ResponseHandler
return $only_updates;
}
public function handle_messages_threaded()
{
}
public function handle_rpc_error($server_answer, &$aargs)
{
if (in_array($server_answer['error_message'], ['PERSISTENT_TIMESTAMP_EMPTY', 'PERSISTENT_TIMESTAMP_OUTDATED', 'PERSISTENT_TIMESTAMP_INVALID'])) {