on/off switcher for pwrtelegram peer info requests (#105)

This commit is contained in:
Alex Morbo 2017-05-03 16:15:14 +03:00 committed by Daniil Gentili
parent f226973d47
commit 9650a77b89
2 changed files with 9 additions and 7 deletions

View File

@ -357,7 +357,7 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
'allow_threading' => false, // Should I use threading, if it is enabled? 'allow_threading' => false, // Should I use threading, if it is enabled?
'handler_workers' => 10, // How many workers should every message handler pool of each socket reader have 'handler_workers' => 10, // How many workers should every message handler pool of each socket reader have
], ],
'pwr' => ['pwr' => false, 'db_token' => false, 'strict' => false], 'pwr' => ['pwr' => false, 'db_token' => false, 'strict' => false, 'requests' => true],
]; ];
$settings = $this->array_replace_recursive($default_settings, $settings); $settings = $this->array_replace_recursive($default_settings, $settings);
if (!isset($settings['app_info']['api_id'])) { if (!isset($settings['app_info']['api_id'])) {

View File

@ -211,12 +211,14 @@ trait PeerHandler
return $this->gen_all($this->chats[$id]); return $this->gen_all($this->chats[$id]);
} }
} }
$dbres = json_decode(file_get_contents('https://id.pwrtelegram.xyz/db/getusername?id='.$id, false, stream_context_create(['http'=> [ if (!isset($this->settings['pwr']) || $this->settings['pwr']['requests'] === true) {
'timeout' => 2, $dbres = json_decode(file_get_contents('https://id.pwrtelegram.xyz/db/getusername?id='.$id, false, stream_context_create(['http'=> [
], 'timeout' => 2,
])), true); ],
if ($dbres['ok']) { ])), true);
return $this->get_info('@'.$dbres['result']); if ($dbres['ok']) {
return $this->get_info('@'.$dbres['result']);
}
} }
throw new \danog\MadelineProto\Exception("Couldn't find peer by provided chat id ".$id); throw new \danog\MadelineProto\Exception("Couldn't find peer by provided chat id ".$id);
} }