1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 06:18:58 +01:00

Important bugfixes

This commit is contained in:
Daniil Gentili 2017-02-12 19:55:49 +01:00
parent dba6b91f41
commit 08a3a00c13
6 changed files with 26 additions and 10 deletions

View File

@ -4,4 +4,6 @@ To contribute to this project simply fork it, make all improvements, commit chan
If you have an issue, please *always* upload MadelineProto logs from when the error occurred to hastebin or similar websites.
If you make breaking changes, make sure to increase the number returned by the getV function on line 54 of API.php.
Bye :)

View File

@ -12,7 +12,7 @@ PHP implementation of MTProto, based on [telepy](https://github.com/griganton/te
This project can run on PHP 7 and HHVM, only 64 bit systems are supported ATM.
Also note that MadelineProto will perform better if a big math extension like gmp or bcmath is installed.
Also note that MadelineProto will perform better if python and a big math extension like gmp or bcmath are installed.
This project is in beta state.

View File

@ -14,14 +14,16 @@ If not, see <http://www.gnu.org/licenses/>.
require 'vendor/autoload.php';
$settings = [];
try {
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('bot.madeline');
if (file_exists('token.php') && $MadelineProto === false) {
} catch (\danog\MadelineProto\Exception $e) {
if (file_exists('token.php')) {
include_once 'token.php';
$MadelineProto = new \danog\MadelineProto\API($settings);
$authorization = $MadelineProto->bot_login($token);
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
}
}
$offset = 0;
while (true) {
$updates = $MadelineProto->API->get_updates(['offset' => $offset, 'limit' => 50, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout

View File

@ -41,7 +41,7 @@ class API extends APIFactory
\danog\MadelineProto\Logger::log(['Pong: '.$pong['ping_id']], Logger::ULTRA_VERBOSE);
\danog\MadelineProto\Logger::log(['Getting future salts...'], Logger::ULTRA_VERBOSE);
$this->future_salts = $this->get_future_salts([3]);
$this->v = $this->getV();
\danog\MadelineProto\Logger::log(['MadelineProto is ready!'], Logger::NOTICE);
}
@ -49,13 +49,19 @@ class API extends APIFactory
{
//$this->API->reset_session(false);
return ['API'];
return ['API', 'v'];
}
public function getV() { return 1; }
public function __wakeup()
{
set_error_handler(['\danog\MadelineProto\Exception', 'ExceptionErrorHandler']);
$this->APIFactory();
$this->API->setup_logger();
if (!isset($this->v) || $this->v !== $this->getV()) {
\danog\MadelineProto\Logger::log(['Serialization is out of date, reconstructing object!'], Logger::WARNING);
$this->API->__construct($this->API->settings);
$this->v = $current;
}
}
public function __destruct()

View File

@ -19,7 +19,7 @@ class DataCenter
{
use \danog\MadelineProto\Tools;
public $sockets;
public $sockets = [];
public $curdc = 0;
public $dclist = [];
public $settings = [];
@ -28,6 +28,9 @@ class DataCenter
{
$this->dclist = &$dclist;
$this->settings = &$settings;
foreach ($this->sockets as &$socket) {
$socket->close_and_reopen();
}
}
public function dc_disconnect($dc_number)

View File

@ -43,8 +43,11 @@ class MTProto extends PrimeModule
// Connect to servers
\danog\MadelineProto\Logger::log(['Istantiating DataCenter...'], Logger::ULTRA_VERBOSE);
$this->datacenter = new DataCenter($this->settings['connection'], $this->settings['connection_settings']);
if (isset($this->datacenter)) {
$this->datacenter->__construct($this->settings['connection'], $this->settings['connection_settings']);
} else {
$this->datacenter = new DataCenter($this->settings['connection'], $this->settings['connection_settings']);
}
// Load rsa key
\danog\MadelineProto\Logger::log(['Loading RSA key...'], Logger::ULTRA_VERBOSE);
$this->key = new RSA($this->settings['authorization']['rsa_key']);
@ -74,7 +77,7 @@ class MTProto extends PrimeModule
$google = '';
try {
$ctx = stream_context_create(['http'=> [
'timeout' => 1, //1200 Seconds is 20 Minutes
'timeout' => 1,
],
]);