Apply fixes from StyleCI
This commit is contained in:
parent
913fc912ee
commit
f16aa7c63a
2
bot.php
2
bot.php
@ -47,11 +47,13 @@ while (true) {
|
|||||||
if ($res == '') {
|
if ($res == '') {
|
||||||
$res = var_export($update, true);
|
$res = var_export($update, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// $MadelineProto->messages->sendMessage(['peer' => $update['update']['_'] === 'updateNewMessage' ? $update['update']['message']['from_id'] : $update['update']['message']['to_id'], 'message' => $res, 'reply_to_msg_id' => $update['update']['message']['id'], 'entities' => [['_' => 'messageEntityPre', 'offset' => 0, 'length' => strlen($res), 'language' => 'json']]]);
|
// $MadelineProto->messages->sendMessage(['peer' => $update['update']['_'] === 'updateNewMessage' ? $update['update']['message']['from_id'] : $update['update']['message']['to_id'], 'message' => $res, 'reply_to_msg_id' => $update['update']['message']['id'], 'entities' => [['_' => 'messageEntityPre', 'offset' => 0, 'length' => strlen($res), 'language' => 'json']]]);
|
||||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]);
|
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isset($update['update']['message']['media']) && ($update['update']['message']['media']['_'] == 'messageMediaPhoto' || $update['update']['message']['media']['_'] == 'messageMediaDocument')) {
|
if (isset($update['update']['message']['media']) && ($update['update']['message']['media']['_'] == 'messageMediaPhoto' || $update['update']['message']['media']['_'] == 'messageMediaDocument')) {
|
||||||
$time = time();
|
$time = time();
|
||||||
|
@ -15,6 +15,7 @@ require '../vendor/autoload.php';
|
|||||||
$settings = [];
|
$settings = [];
|
||||||
$settings = ['app_info'=>['api_id'=>6, 'api_hash'=>'eb06d4abfb49dc3eeb1aeb98ae0f581e']];
|
$settings = ['app_info'=>['api_id'=>6, 'api_hash'=>'eb06d4abfb49dc3eeb1aeb98ae0f581e']];
|
||||||
$MadelineProto = false;
|
$MadelineProto = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('MadelineProto_bot.madeline');
|
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('MadelineProto_bot.madeline');
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
@ -66,6 +67,7 @@ while (true) {
|
|||||||
if (isset($update['update']['message']['out']) && $update['update']['message']['out']) {
|
if (isset($update['update']['message']['out']) && $update['update']['message']['out']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isset($update['update']['message']['message']) && preg_match('|/start|', $update['update']['message']['message'])) {
|
if (isset($update['update']['message']['message']) && preg_match('|/start|', $update['update']['message']['message'])) {
|
||||||
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => $start, 'reply_to_msg_id' => $update['update']['message']['id'], 'parse_mode' => 'markdown', 'reply_markup' => $reply_markup]);
|
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => $start, 'reply_to_msg_id' => $update['update']['message']['id'], 'parse_mode' => 'markdown', 'reply_markup' => $reply_markup]);
|
||||||
@ -78,6 +80,7 @@ while (true) {
|
|||||||
if (isset($update['update']['message']['out']) && $update['update']['message']['out']) {
|
if (isset($update['update']['message']['out']) && $update['update']['message']['out']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (preg_match('|/start|', $update['update']['message']['message'])) {
|
if (preg_match('|/start|', $update['update']['message']['message'])) {
|
||||||
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['to_id'], 'message' => $start, 'reply_to_msg_id' => $update['update']['message']['id'], 'parse_mode' => 'markdown', 'reply_markup' => $reply_markup]);
|
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['to_id'], 'message' => $start, 'reply_to_msg_id' => $update['update']['message']['id'], 'parse_mode' => 'markdown', 'reply_markup' => $reply_markup]);
|
||||||
@ -112,11 +115,13 @@ while (true) {
|
|||||||
}
|
}
|
||||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]);
|
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$MadelineProto->messages->sendMessage(['peer' => $update['update']['user_id'], 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]);
|
$MadelineProto->messages->sendMessage(['peer' => $update['update']['user_id'], 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]);
|
||||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$toset['switch_pm'] = $sswitch;
|
$toset['switch_pm'] = $sswitch;
|
||||||
$MadelineProto->messages->setInlineBotResults($toset);
|
$MadelineProto->messages->setInlineBotResults($toset);
|
||||||
@ -130,6 +135,7 @@ while (true) {
|
|||||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$toset['switch_pm'] = $sswitch;
|
$toset['switch_pm'] = $sswitch;
|
||||||
$MadelineProto->messages->setInlineBotResults($toset);
|
$MadelineProto->messages->setInlineBotResults($toset);
|
||||||
|
@ -15,11 +15,13 @@ require '../vendor/autoload.php';
|
|||||||
$settings = ['app_info'=>['api_id'=>6, 'api_hash'=>'eb06d4abfb49dc3eeb1aeb98ae0f581e']];
|
$settings = ['app_info'=>['api_id'=>6, 'api_hash'=>'eb06d4abfb49dc3eeb1aeb98ae0f581e']];
|
||||||
$MadelineProto = false;
|
$MadelineProto = false;
|
||||||
$uMadelineProto = false;
|
$uMadelineProto = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('pipesbot.madeline');
|
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('pipesbot.madeline');
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
var_dump($e->getMessage());
|
var_dump($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$uMadelineProto = \danog\MadelineProto\Serialization::deserialize('pwr.madeline');
|
$uMadelineProto = \danog\MadelineProto\Serialization::deserialize('pwr.madeline');
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
@ -114,6 +116,7 @@ while (true) {
|
|||||||
if (isset($update['update']['message']['out']) && $update['update']['message']['out']) {
|
if (isset($update['update']['message']['out']) && $update['update']['message']['out']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (preg_match('|/start|', $update['update']['message']['message'])) {
|
if (preg_match('|/start|', $update['update']['message']['message'])) {
|
||||||
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => $start, 'reply_to_msg_id' => $update['update']['message']['id']]);
|
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => $start, 'reply_to_msg_id' => $update['update']['message']['id']]);
|
||||||
@ -126,6 +129,7 @@ while (true) {
|
|||||||
if (isset($update['update']['message']['out']) && $update['update']['message']['out']) {
|
if (isset($update['update']['message']['out']) && $update['update']['message']['out']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (preg_match('|/start|', $update['update']['message']['message'])) {
|
if (preg_match('|/start|', $update['update']['message']['message'])) {
|
||||||
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['to_id'], 'message' => $start, 'reply_to_msg_id' => $update['update']['message']['id']]);
|
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['to_id'], 'message' => $start, 'reply_to_msg_id' => $update['update']['message']['id']]);
|
||||||
@ -199,6 +203,7 @@ while (true) {
|
|||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
var_dump($e->getMessage());
|
var_dump($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$toset['switch_pm'] = $sswitch;
|
$toset['switch_pm'] = $sswitch;
|
||||||
$MadelineProto->messages->setInlineBotResults($toset);
|
$MadelineProto->messages->setInlineBotResults($toset);
|
||||||
@ -216,6 +221,7 @@ while (true) {
|
|||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
var_dump($e->getMessage());
|
var_dump($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$toset['switch_pm'] = $sswitch;
|
$toset['switch_pm'] = $sswitch;
|
||||||
$MadelineProto->messages->setInlineBotResults($toset);
|
$MadelineProto->messages->setInlineBotResults($toset);
|
||||||
|
@ -13,6 +13,7 @@ If not, see <http://www.gnu.org/licenses/>.
|
|||||||
require '../vendor/autoload.php';
|
require '../vendor/autoload.php';
|
||||||
$settings = ['app_info'=>['api_id'=>6, 'api_hash'=>'eb06d4abfb49dc3eeb1aeb98ae0f581e']];
|
$settings = ['app_info'=>['api_id'=>6, 'api_hash'=>'eb06d4abfb49dc3eeb1aeb98ae0f581e']];
|
||||||
include_once 'token.php';
|
include_once 'token.php';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('b.madeline');
|
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('b.madeline');
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
@ -184,10 +185,11 @@ while (true) {
|
|||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]);
|
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isset($update['update']['message']['media']) && $update['update']['message']['media'] == 'messageMediaPhoto' && $update['update']['message']['media'] == 'messageMediaDocument') {
|
if (isset($update['update']['message']['media']) && $update['update']['message']['media'] == 'messageMediaPhoto' && $update['update']['message']['media'] == 'messageMediaDocument') {
|
||||||
$time = time();
|
$time = time();
|
||||||
// $file = $MadelineProto->download_to_dir($update['update']['message']['media'], '/tmp');
|
// $file = $MadelineProto->download_to_dir($update['update']['message']['media'], '/tmp');
|
||||||
// $MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => 'Downloaded to '.$file.' in '.(time() - $time).' seconds', 'reply_to_msg_id' => $update['update']['message']['id'], 'entities' => [['_' => 'messageEntityPre', 'offset' => 0, 'length' => strlen($res), 'language' => 'json']]]);
|
// $MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => 'Downloaded to '.$file.' in '.(time() - $time).' seconds', 'reply_to_msg_id' => $update['update']['message']['id'], 'entities' => [['_' => 'messageEntityPre', 'offset' => 0, 'length' => strlen($res), 'language' => 'json']]]);
|
||||||
}
|
}
|
||||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
|
@ -29,6 +29,7 @@ while (true) {
|
|||||||
if (isset($update['update']['message']['out']) && $update['update']['message']['out']) {
|
if (isset($update['update']['message']['out']) && $update['update']['message']['out']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($update['update']['message']['message'] === 'callstorm') {
|
if ($update['update']['message']['message'] === 'callstorm') {
|
||||||
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => 'callstorming you', 'reply_to_msg_id' => $update['update']['message']['id']]);
|
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => 'callstorming you', 'reply_to_msg_id' => $update['update']['message']['id']]);
|
||||||
|
@ -17,6 +17,7 @@ if (file_exists('web_data.php')) {
|
|||||||
|
|
||||||
echo 'Deserializing MadelineProto from calls.madeline...'.PHP_EOL;
|
echo 'Deserializing MadelineProto from calls.madeline...'.PHP_EOL;
|
||||||
$MadelineProto = false;
|
$MadelineProto = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('calls.madeline');
|
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('calls.madeline');
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
|
@ -14,6 +14,7 @@ If not, see <http://www.gnu.org/licenses/>.
|
|||||||
require '../vendor/autoload.php';
|
require '../vendor/autoload.php';
|
||||||
$settings = [];
|
$settings = [];
|
||||||
$Lua = false;
|
$Lua = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$Lua = \danog\MadelineProto\Serialization::deserialize('bot.madeline');
|
$Lua = \danog\MadelineProto\Serialization::deserialize('bot.madeline');
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
|
@ -13,6 +13,7 @@ If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
require '../vendor/autoload.php';
|
require '../vendor/autoload.php';
|
||||||
$settings = [];
|
$settings = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$Lua = \danog\MadelineProto\Serialization::deserialize('td.madeline');
|
$Lua = \danog\MadelineProto\Serialization::deserialize('td.madeline');
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
|
@ -17,6 +17,7 @@ if (file_exists('web_data.php')) {
|
|||||||
|
|
||||||
echo 'Deserializing MadelineProto from session.madeline...'.PHP_EOL;
|
echo 'Deserializing MadelineProto from session.madeline...'.PHP_EOL;
|
||||||
$MadelineProto = false;
|
$MadelineProto = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('session.madeline');
|
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('session.madeline');
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
@ -107,6 +108,7 @@ $users = [];
|
|||||||
if ($update['update']['message']['out'] || $update['update']['message']['to_id']['_'] !== 'peerUser' || !isset($update['update']['message']['from_id'])) {
|
if ($update['update']['message']['out'] || $update['update']['message']['to_id']['_'] !== 'peerUser' || !isset($update['update']['message']['from_id'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!isset($users[$update['update']['message']['from_id']])) {
|
if (!isset($users[$update['update']['message']['from_id']])) {
|
||||||
$users[$update['update']['message']['from_id']] = true;
|
$users[$update['update']['message']['from_id']] = true;
|
||||||
|
@ -17,6 +17,7 @@ if (file_exists('web_data.php')) {
|
|||||||
|
|
||||||
echo 'Deserializing MadelineProto from s.madeline...'.PHP_EOL;
|
echo 'Deserializing MadelineProto from s.madeline...'.PHP_EOL;
|
||||||
$MadelineProto = false;
|
$MadelineProto = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('s.madeline');
|
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('s.madeline');
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
|
@ -134,6 +134,7 @@ class APIFactory
|
|||||||
if ($this->lua === false) {
|
if ($this->lua === false) {
|
||||||
return method_exists($this->API, $this->namespace.$name) ? $this->API->{$this->namespace.$name}(...$arguments) : $this->API->method_call($this->namespace.$name, (isset($arguments[0]) && $this->is_array($arguments[0])) ? $arguments[0] : [], $aargs);
|
return method_exists($this->API, $this->namespace.$name) ? $this->API->{$this->namespace.$name}(...$arguments) : $this->API->method_call($this->namespace.$name, (isset($arguments[0]) && $this->is_array($arguments[0])) ? $arguments[0] : [], $aargs);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$deserialized = method_exists($this->API, $this->namespace.$name) ? $this->API->{$this->namespace.$name}(...$arguments) : $this->API->method_call($this->namespace.$name, (isset($arguments[0]) && $this->is_array($arguments[0])) ? $arguments[0] : [], $aargs);
|
$deserialized = method_exists($this->API, $this->namespace.$name) ? $this->API->{$this->namespace.$name}(...$arguments) : $this->API->method_call($this->namespace.$name, (isset($arguments[0]) && $this->is_array($arguments[0])) ? $arguments[0] : [], $aargs);
|
||||||
Lua::convert_objects($deserialized);
|
Lua::convert_objects($deserialized);
|
||||||
|
@ -46,13 +46,13 @@ class Connection extends \Volatile
|
|||||||
public $call_queue = [];
|
public $call_queue = [];
|
||||||
|
|
||||||
public $i = [];
|
public $i = [];
|
||||||
/* public function __get($name) {
|
/* public function __get($name) {
|
||||||
echo "GETTING $name\n";
|
echo "GETTING $name\n";
|
||||||
if (isset($this->i[$name]) && $this->{$name} === null) var_dump($this->i[$name]);
|
if (isset($this->i[$name]) && $this->{$name} === null) var_dump($this->i[$name]);
|
||||||
if ($this->{$name} instanceof \Volatile) $this->i[$name] = debug_backtrace(0);
|
if ($this->{$name} instanceof \Volatile) $this->i[$name] = debug_backtrace(0);
|
||||||
var_dump(is_null($this->{$name}));
|
var_dump(is_null($this->{$name}));
|
||||||
return $this->{$name};
|
return $this->{$name};
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
public function ___construct($proxy, $extra, $ip, $port, $protocol, $timeout, $ipv6)
|
public function ___construct($proxy, $extra, $ip, $port, $protocol, $timeout, $ipv6)
|
||||||
{
|
{
|
||||||
@ -290,6 +290,7 @@ var_dump(is_null($this->{$name}));
|
|||||||
}
|
}
|
||||||
if (strlen($packet) !== $length) {
|
if (strlen($packet) !== $length) {
|
||||||
$this->close_and_reopen();
|
$this->close_and_reopen();
|
||||||
|
|
||||||
throw new Exception("WARNING: Wrong length was read (should've read ".($length).', read '.strlen($packet).')!');
|
throw new Exception("WARNING: Wrong length was read (should've read ".($length).', read '.strlen($packet).')!');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,6 +310,7 @@ var_dump(is_null($this->{$name}));
|
|||||||
}
|
}
|
||||||
if (strlen($packet) !== $length) {
|
if (strlen($packet) !== $length) {
|
||||||
$this->close_and_reopen();
|
$this->close_and_reopen();
|
||||||
|
|
||||||
throw new Exception("WARNING: Wrong length was read (should've read ".($length).', read '.strlen($packet).')!');
|
throw new Exception("WARNING: Wrong length was read (should've read ".($length).', read '.strlen($packet).')!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,16 +25,16 @@ class DataCenter extends \Volatile
|
|||||||
public $dclist = [];
|
public $dclist = [];
|
||||||
public $settings = [];
|
public $settings = [];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public $i = [];
|
public $i = [];
|
||||||
public function __get($name) {
|
public function __get($name) {
|
||||||
echo "GETTING $name\n";
|
echo "GETTING $name\n";
|
||||||
if (isset($this->i[$name]) && $this->{$name} === null) var_dump($this->i[$name]);
|
if (isset($this->i[$name]) && $this->{$name} === null) var_dump($this->i[$name]);
|
||||||
if ($this->{$name} instanceof \Volatile) $this->i[$name] = debug_backtrace(0);
|
if ($this->{$name} instanceof \Volatile) $this->i[$name] = debug_backtrace(0);
|
||||||
var_dump(is_null($this->{$name}));
|
var_dump(is_null($this->{$name}));
|
||||||
return $this->{$name};
|
return $this->{$name};
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
public function __sleep()
|
public function __sleep()
|
||||||
{
|
{
|
||||||
return ['sockets', 'curdc', 'dclist', 'settings'];
|
return ['sockets', 'curdc', 'dclist', 'settings'];
|
||||||
|
@ -59,6 +59,7 @@ class Exception extends \Exception
|
|||||||
if (error_reporting() === 0) {
|
if (error_reporting() === 0) {
|
||||||
return true; // return true to continue through the others error handlers
|
return true; // return true to continue through the others error handlers
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new self($errstr, $errno, null, $errfile, $errline);
|
throw new self($errstr, $errno, null, $errfile, $errline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,6 +114,7 @@ class Logger
|
|||||||
if (!defined('\danog\MadelineProto\VoIP::PHP_LIBTGVOIP_VERSION') || \danog\MadelineProto\VoIP::PHP_LIBTGVOIP_VERSION !== '1.1.2') {
|
if (!defined('\danog\MadelineProto\VoIP::PHP_LIBTGVOIP_VERSION') || \danog\MadelineProto\VoIP::PHP_LIBTGVOIP_VERSION !== '1.1.2') {
|
||||||
throw new \danog\MadelineProto\Exception(hex2bin('506c6561736520757064617465207068702d6c69627467766f6970'), 0, null, 'MadelineProto', 1);
|
throw new \danog\MadelineProto\Exception(hex2bin('506c6561736520757064617465207068702d6c69627467766f6970'), 0, null, 'MadelineProto', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
\Threaded::extend('\danog\MadelineProto\VoIP');
|
\Threaded::extend('\danog\MadelineProto\VoIP');
|
||||||
} catch (\RuntimeException $e) {
|
} catch (\RuntimeException $e) {
|
||||||
@ -125,6 +126,7 @@ class Logger
|
|||||||
self::$colors[self::WARNING] = implode(';', [self::foreground['white'], self::set['dim'], self::background['red']]);
|
self::$colors[self::WARNING] = implode(';', [self::foreground['white'], self::set['dim'], self::background['red']]);
|
||||||
self::$colors[self::ERROR] = implode(';', [self::foreground['white'], self::set['bold'], self::background['red']]);
|
self::$colors[self::ERROR] = implode(';', [self::foreground['white'], self::set['bold'], self::background['red']]);
|
||||||
self::$colors[self::FATAL_ERROR] = implode(';', [self::foreground['red'], self::set['bold'], self::background['light_gray']]);
|
self::$colors[self::FATAL_ERROR] = implode(';', [self::foreground['red'], self::set['bold'], self::background['light_gray']]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
self::$isatty = defined('STDOUT') && function_exists('posix_isatty') && posix_isatty(STDOUT);
|
self::$isatty = defined('STDOUT') && function_exists('posix_isatty') && posix_isatty(STDOUT);
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
|
@ -127,6 +127,7 @@ class Lua
|
|||||||
public function __call($name, $params)
|
public function __call($name, $params)
|
||||||
{
|
{
|
||||||
self::convert_objects($params);
|
self::convert_objects($params);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return $this->Lua->{$name}(...$params);
|
return $this->Lua->{$name}(...$params);
|
||||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
|
@ -20,7 +20,7 @@ trait AckHandler
|
|||||||
public function ack_outgoing_message_id($message_id, $datacenter)
|
public function ack_outgoing_message_id($message_id, $datacenter)
|
||||||
{
|
{
|
||||||
// The server acknowledges that it received my message
|
// The server acknowledges that it received my message
|
||||||
//var_dump($this->datacenter->sockets[$datacenter]->outgoing_messages[$message_id]);
|
//var_dump($this->datacenter->sockets[$datacenter]->outgoing_messages[$message_id]);
|
||||||
if (!isset($this->datacenter->sockets[$datacenter]->outgoing_messages[$message_id])) {
|
if (!isset($this->datacenter->sockets[$datacenter]->outgoing_messages[$message_id])) {
|
||||||
\danog\MadelineProto\Logger::log(["WARNING: Couldn't find message id ".$message_id.' in the array of outgoing messages. Maybe try to increase its size?'], \danog\MadelineProto\Logger::WARNING);
|
\danog\MadelineProto\Logger::log(["WARNING: Couldn't find message id ".$message_id.' in the array of outgoing messages. Maybe try to increase its size?'], \danog\MadelineProto\Logger::WARNING);
|
||||||
|
|
||||||
|
@ -456,25 +456,25 @@ trait AuthKeyHandler
|
|||||||
throw new \danog\MadelineProto\SecurityException("p isn't a safe 2048-bit prime (p isn't a prime).");
|
throw new \danog\MadelineProto\SecurityException("p isn't a safe 2048-bit prime (p isn't a prime).");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ***********************************************************************
|
* ***********************************************************************
|
||||||
* Check validity of p
|
* Check validity of p
|
||||||
* Is (p - 1) / 2 a prime?
|
* Is (p - 1) / 2 a prime?
|
||||||
*
|
*
|
||||||
* Almost always fails
|
* Almost always fails
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
\danog\MadelineProto\Logger::log(['Executing p/g checks (2/3)...'], \danog\MadelineProto\Logger::VERBOSE);
|
\danog\MadelineProto\Logger::log(['Executing p/g checks (2/3)...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||||
if (!$p->subtract($this->one)->divide($this->two)[0]->isPrime()) {
|
if (!$p->subtract($this->one)->divide($this->two)[0]->isPrime()) {
|
||||||
throw new \danog\MadelineProto\SecurityException("p isn't a safe 2048-bit prime ((p - 1) / 2 isn't a prime).");
|
throw new \danog\MadelineProto\SecurityException("p isn't a safe 2048-bit prime ((p - 1) / 2 isn't a prime).");
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ***********************************************************************
|
* ***********************************************************************
|
||||||
* Check validity of p
|
* Check validity of p
|
||||||
* 2^2047 < p < 2^2048
|
* 2^2047 < p < 2^2048
|
||||||
*/
|
*/
|
||||||
\danog\MadelineProto\Logger::log(['Executing p/g checks (2/2)...'], \danog\MadelineProto\Logger::VERBOSE);
|
\danog\MadelineProto\Logger::log(['Executing p/g checks (2/2)...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||||
if ($p->compare($this->twoe2047) <= 0 // 2^2047 < p or p > 2^2047 or ! p <= 2^2047
|
if ($p->compare($this->twoe2047) <= 0 // 2^2047 < p or p > 2^2047 or ! p <= 2^2047
|
||||||
|| $p->compare($this->twoe2048) >= 0 // p < 2^2048 or ! p >= 2^2048
|
|| $p->compare($this->twoe2048) >= 0 // p < 2^2048 or ! p >= 2^2048
|
||||||
@ -482,11 +482,11 @@ trait AuthKeyHandler
|
|||||||
throw new \danog\MadelineProto\SecurityException("g isn't a safe 2048-bit prime (2^2047 < p < 2^2048 is false).");
|
throw new \danog\MadelineProto\SecurityException("g isn't a safe 2048-bit prime (2^2047 < p < 2^2048 is false).");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ***********************************************************************
|
* ***********************************************************************
|
||||||
* Check validity of g
|
* Check validity of g
|
||||||
* 1 < g < p - 1
|
* 1 < g < p - 1
|
||||||
*/
|
*/
|
||||||
\danog\MadelineProto\Logger::log(['Executing g check...'], \danog\MadelineProto\Logger::VERBOSE);
|
\danog\MadelineProto\Logger::log(['Executing g check...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||||
|
|
||||||
if ($g->compare($this->one) <= 0 // 1 < g or g > 1 or ! g <= 1
|
if ($g->compare($this->one) <= 0 // 1 < g or g > 1 or ! g <= 1
|
||||||
@ -559,6 +559,7 @@ trait AuthKeyHandler
|
|||||||
$this->datacenter->sockets[$datacenter]->new_incoming = [];
|
$this->datacenter->sockets[$datacenter]->new_incoming = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \danog\MadelineProto\SecurityException('An error occurred while binding temporary and permanent authorization keys.');
|
throw new \danog\MadelineProto\SecurityException('An error occurred while binding temporary and permanent authorization keys.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,9 +134,11 @@ trait CallHandler
|
|||||||
\danog\MadelineProto\Logger::log(['WARNING: Resetting auth key...'], \danog\MadelineProto\Logger::WARNING);
|
\danog\MadelineProto\Logger::log(['WARNING: Resetting auth key...'], \danog\MadelineProto\Logger::WARNING);
|
||||||
$this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key = null;
|
$this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key = null;
|
||||||
$this->init_authorization();
|
$this->init_authorization();
|
||||||
|
|
||||||
throw new \danog\MadelineProto\Exception('I had to recreate the temporary authorization key');
|
throw new \danog\MadelineProto\Exception('I had to recreate the temporary authorization key');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \danog\MadelineProto\RPCErrorException($error, $error);
|
throw new \danog\MadelineProto\RPCErrorException($error, $error);
|
||||||
}
|
}
|
||||||
$only_updates = $this->handle_messages($aargs['datacenter']); // This method receives data from the socket, and parses stuff
|
$only_updates = $this->handle_messages($aargs['datacenter']); // This method receives data from the socket, and parses stuff
|
||||||
@ -187,6 +189,7 @@ trait CallHandler
|
|||||||
$this->init_authorization();
|
$this->init_authorization();
|
||||||
continue 3;
|
continue 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \danog\MadelineProto\RPCErrorException('Received bad_msg_notification: '.self::BAD_MSG_ERROR_CODES[$server_answer['error_code']], $server_answer['error_code']);
|
throw new \danog\MadelineProto\RPCErrorException('Received bad_msg_notification: '.self::BAD_MSG_ERROR_CODES[$server_answer['error_code']], $server_answer['error_code']);
|
||||||
break;
|
break;
|
||||||
case 'boolTrue':
|
case 'boolTrue':
|
||||||
@ -241,6 +244,7 @@ trait CallHandler
|
|||||||
|
|
||||||
return $this->method_call($method, $args, $aargs);
|
return $this->method_call($method, $args, $aargs);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \danog\MadelineProto\Exception('An error occurred while calling method '.$method.' ('.$last_error.').');
|
throw new \danog\MadelineProto\Exception('An error occurred while calling method '.$method.' ('.$last_error.').');
|
||||||
}
|
}
|
||||||
\danog\MadelineProto\Logger::log(['Got response for method '.$method.' @ try '.$count.' (response try '.$res_count.')'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
\danog\MadelineProto\Logger::log(['Got response for method '.$method.' @ try '.$count.' (response try '.$res_count.')'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||||
@ -258,6 +262,7 @@ trait CallHandler
|
|||||||
if ($method === 'req_pq') {
|
if ($method === 'req_pq') {
|
||||||
throw new \danog\MadelineProto\RPCErrorException('RPC_CALL_FAIL');
|
throw new \danog\MadelineProto\RPCErrorException('RPC_CALL_FAIL');
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \danog\MadelineProto\Exception('An error occurred while calling method '.$method.' ('.$last_error.').');
|
throw new \danog\MadelineProto\Exception('An error occurred while calling method '.$method.' ('.$last_error.').');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,6 +291,7 @@ trait CallHandler
|
|||||||
|
|
||||||
return $message_id;
|
return $message_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \danog\MadelineProto\Exception('An error occurred while sending object '.$object.'.');
|
throw new \danog\MadelineProto\Exception('An error occurred while sending object '.$object.'.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ trait Files
|
|||||||
$constructor['key_fingerprint'] = $fingerprint;
|
$constructor['key_fingerprint'] = $fingerprint;
|
||||||
$constructor['key'] = $key;
|
$constructor['key'] = $key;
|
||||||
$constructor['iv'] = $iv;
|
$constructor['iv'] = $iv;
|
||||||
// $constructor['md5_checksum'] = '';
|
// $constructor['md5_checksum'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $constructor;
|
return $constructor;
|
||||||
@ -316,6 +316,7 @@ trait Files
|
|||||||
if ($res['_'] === 'upload.cdnFileReuploadNeeded') {
|
if ($res['_'] === 'upload.cdnFileReuploadNeeded') {
|
||||||
\danog\MadelineProto\Logger::log(['File is not stored on CDN, requesting reupload!'], \danog\MadelineProto\Logger::NOTICE);
|
\danog\MadelineProto\Logger::log(['File is not stored on CDN, requesting reupload!'], \danog\MadelineProto\Logger::NOTICE);
|
||||||
$this->get_config([], ['datacenter' => $this->datacenter->curdc]);
|
$this->get_config([], ['datacenter' => $this->datacenter->curdc]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->add_cdn_hashes($message_media['file_token'], $this->method_call('upload.reuploadCdnFile', ['file_token' => $message_media['file_token'], 'request_token' => $res['request_token']], ['heavy' => true, 'datacenter' => $old_dc]));
|
$this->add_cdn_hashes($message_media['file_token'], $this->method_call('upload.reuploadCdnFile', ['file_token' => $message_media['file_token'], 'request_token' => $res['request_token']], ['heavy' => true, 'datacenter' => $old_dc]));
|
||||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
|
@ -30,6 +30,7 @@ trait PeerHandler
|
|||||||
var_dump(ord($char));
|
var_dump(ord($char));
|
||||||
}*/
|
}*/
|
||||||
$this->chats[$user['id']] = $user;
|
$this->chats[$user['id']] = $user;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->get_pwr_chat($user['id'], false, true);
|
$this->get_pwr_chat($user['id'], false, true);
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
@ -56,6 +57,7 @@ trait PeerHandler
|
|||||||
case 'chatForbidden':
|
case 'chatForbidden':
|
||||||
if (!isset($this->chats[-$chat['id']]) || $this->chats[-$chat['id']] !== $chat) {
|
if (!isset($this->chats[-$chat['id']]) || $this->chats[-$chat['id']] !== $chat) {
|
||||||
$this->chats[-$chat['id']] = $chat;
|
$this->chats[-$chat['id']] = $chat;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->get_pwr_chat(-$chat['id'], true, true);
|
$this->get_pwr_chat(-$chat['id'], true, true);
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
@ -75,6 +77,7 @@ trait PeerHandler
|
|||||||
$bot_api_id = $this->to_supergroup($chat['id']);
|
$bot_api_id = $this->to_supergroup($chat['id']);
|
||||||
if (!isset($this->chats[$bot_api_id]) || $this->chats[$bot_api_id] !== $chat) {
|
if (!isset($this->chats[$bot_api_id]) || $this->chats[$bot_api_id] !== $chat) {
|
||||||
$this->chats[$bot_api_id] = $chat;
|
$this->chats[$bot_api_id] = $chat;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!isset($this->full_chats[$bot_api_id]) || $this->full_chats[$bot_api_id]['full']['participants_count'] !== $this->get_full_info($bot_api_id)['full']['participants_count']) {
|
if (!isset($this->full_chats[$bot_api_id]) || $this->full_chats[$bot_api_id]['full']['participants_count'] !== $this->get_full_info($bot_api_id)['full']['participants_count']) {
|
||||||
$this->get_pwr_chat($this->to_supergroup($chat['id']), true, true);
|
$this->get_pwr_chat($this->to_supergroup($chat['id']), true, true);
|
||||||
@ -219,6 +222,7 @@ trait PeerHandler
|
|||||||
return $this->get_info('@'.$dbres['result']);
|
return $this->get_info('@'.$dbres['result']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database');
|
throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database');
|
||||||
}
|
}
|
||||||
$id = str_replace('@', '', $id);
|
$id = str_replace('@', '', $id);
|
||||||
@ -232,6 +236,7 @@ trait PeerHandler
|
|||||||
|
|
||||||
return $this->get_info($id, false);
|
return $this->get_info($id, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database');
|
throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,6 +460,7 @@ trait PeerHandler
|
|||||||
$filters = ['channelParticipantsRecent', 'channelParticipantsAdmins', 'channelParticipantsKicked', 'channelParticipantsBots', 'channelParticipantsBanned'];
|
$filters = ['channelParticipantsRecent', 'channelParticipantsAdmins', 'channelParticipantsKicked', 'channelParticipantsBots', 'channelParticipantsBanned'];
|
||||||
foreach ($filters as $filter) {
|
foreach ($filters as $filter) {
|
||||||
$offset = -$limit;
|
$offset = -$limit;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$gres = $this->method_call('channels.getParticipants', ['channel' => $full['InputChannel'], 'filter' => ['_' => $filter, 'q' => ''], 'offset' => $offset += $limit, 'limit' => $limit], ['datacenter' => $this->datacenter->curdc]);
|
$gres = $this->method_call('channels.getParticipants', ['channel' => $full['InputChannel'], 'filter' => ['_' => $filter, 'q' => ''], 'offset' => $offset += $limit, 'limit' => $limit], ['datacenter' => $this->datacenter->curdc]);
|
||||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
@ -553,6 +559,7 @@ trait PeerHandler
|
|||||||
if (empty($this->qres)) {
|
if (empty($this->qres)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$payload = json_encode($this->qres);
|
$payload = json_encode($this->qres);
|
||||||
$path = '/tmp/ids'.hash('sha256', $payload);
|
$path = '/tmp/ids'.hash('sha256', $payload);
|
||||||
@ -574,6 +581,7 @@ trait PeerHandler
|
|||||||
if ($res['_'] === 'contacts.resolvedPeer') {
|
if ($res['_'] === 'contacts.resolvedPeer') {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \danog\MadelineProto\Exception('resolve_username returned an unexpected constructor: '.var_export($res, true));
|
throw new \danog\MadelineProto\Exception('resolve_username returned an unexpected constructor: '.var_export($res, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,6 +272,7 @@ trait ResponseHandler
|
|||||||
}
|
}
|
||||||
\danog\MadelineProto\Logger::log(['No'], \danog\MadelineProto\Logger::VERBOSE);
|
\danog\MadelineProto\Logger::log(['No'], \danog\MadelineProto\Logger::VERBOSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \danog\MadelineProto\ResponseException('Dunno how to handle '.PHP_EOL.var_export($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content'], true));
|
throw new \danog\MadelineProto\ResponseException('Dunno how to handle '.PHP_EOL.var_export($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content'], true));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -318,6 +319,7 @@ trait ResponseHandler
|
|||||||
switch ($server_answer['error_code']) {
|
switch ($server_answer['error_code']) {
|
||||||
case 303:
|
case 303:
|
||||||
$this->datacenter->curdc = $aargs['datacenter'] = (int) preg_replace('/[^0-9]+/', '', $server_answer['error_message']);
|
$this->datacenter->curdc = $aargs['datacenter'] = (int) preg_replace('/[^0-9]+/', '', $server_answer['error_message']);
|
||||||
|
|
||||||
throw new \danog\MadelineProto\Exception('Received request to switch to DC '.$this->datacenter->curdc);
|
throw new \danog\MadelineProto\Exception('Received request to switch to DC '.$this->datacenter->curdc);
|
||||||
case 401:
|
case 401:
|
||||||
switch ($server_answer['error_message']) {
|
switch ($server_answer['error_message']) {
|
||||||
@ -342,6 +344,7 @@ trait ResponseHandler
|
|||||||
if (is_numeric($seconds) && $seconds < $limit) {
|
if (is_numeric($seconds) && $seconds < $limit) {
|
||||||
\danog\MadelineProto\Logger::log(['Flood, waiting '.$seconds.' seconds...'], \danog\MadelineProto\Logger::NOTICE);
|
\danog\MadelineProto\Logger::log(['Flood, waiting '.$seconds.' seconds...'], \danog\MadelineProto\Logger::NOTICE);
|
||||||
sleep($seconds);
|
sleep($seconds);
|
||||||
|
|
||||||
throw new \danog\MadelineProto\Exception('Re-executing query...');
|
throw new \danog\MadelineProto\Exception('Re-executing query...');
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -152,6 +152,7 @@ trait UpdateHandler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->load_channel_state($channel)['sync_loading'] = true;
|
$this->load_channel_state($channel)['sync_loading'] = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$input = $this->get_info('channel#'.$channel);
|
$input = $this->get_info('channel#'.$channel);
|
||||||
if (!isset($input['InputChannel'])) {
|
if (!isset($input['InputChannel'])) {
|
||||||
@ -176,6 +177,7 @@ trait UpdateHandler
|
|||||||
if ($e->getMessage() === "You haven't joined this channel/supergroup") {
|
if ($e->getMessage() === "You haven't joined this channel/supergroup") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
unset($input);
|
unset($input);
|
||||||
@ -394,10 +396,10 @@ trait UpdateHandler
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// if ($cur_state['pts'] < $update['pts']) {
|
// if ($cur_state['pts'] < $update['pts']) {
|
||||||
\danog\MadelineProto\Logger::log(['Applying pts. current pts: '.$cur_state['pts'].', new pts: '.$update['pts'].', channel id: '.$channel_id], \danog\MadelineProto\Logger::VERBOSE);
|
\danog\MadelineProto\Logger::log(['Applying pts. current pts: '.$cur_state['pts'].', new pts: '.$update['pts'].', channel id: '.$channel_id], \danog\MadelineProto\Logger::VERBOSE);
|
||||||
$cur_state['pts'] = $update['pts'];
|
$cur_state['pts'] = $update['pts'];
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if ($channel_id === false && isset($options['date']) && $cur_state['date'] < $options['date']) {
|
if ($channel_id === false && isset($options['date']) && $cur_state['date'] < $options['date']) {
|
||||||
$cur_state['date'] = $options['date'];
|
$cur_state['date'] = $options['date'];
|
||||||
|
@ -91,6 +91,7 @@ trait AuthKeyHandler
|
|||||||
//var_dump($key);
|
//var_dump($key);
|
||||||
if ($key['fingerprint'] !== $params['key_fingerprint']) {
|
if ($key['fingerprint'] !== $params['key_fingerprint']) {
|
||||||
$this->discard_secret_chat($params['id']);
|
$this->discard_secret_chat($params['id']);
|
||||||
|
|
||||||
throw new \danog\MadelineProto\SecurityException('Invalid key fingerprint!');
|
throw new \danog\MadelineProto\SecurityException('Invalid key fingerprint!');
|
||||||
}
|
}
|
||||||
$key['visualization_orig'] = substr(sha1($key['auth_key'], true), 16);
|
$key['visualization_orig'] = substr(sha1($key['auth_key'], true), 16);
|
||||||
@ -180,6 +181,7 @@ trait AuthKeyHandler
|
|||||||
$key['visualization_46'] = substr(hash('sha256', $key['auth_key'], true), 20);
|
$key['visualization_46'] = substr(hash('sha256', $key['auth_key'], true), 20);
|
||||||
if ($key['fingerprint'] !== $params['key_fingerprint']) {
|
if ($key['fingerprint'] !== $params['key_fingerprint']) {
|
||||||
$this->method_call('messages.sendEncryptedService', ['peer' => $chat, 'message' => ['_' => 'decryptedMessageService', 'action' => ['_' => 'decryptedMessageActionAbortKey', 'exchange_id' => $params['exchange_id']]]], ['datacenter' => $this->datacenter->curdc]);
|
$this->method_call('messages.sendEncryptedService', ['peer' => $chat, 'message' => ['_' => 'decryptedMessageService', 'action' => ['_' => 'decryptedMessageActionAbortKey', 'exchange_id' => $params['exchange_id']]]], ['datacenter' => $this->datacenter->curdc]);
|
||||||
|
|
||||||
throw new \danog\MadelineProto\SecurityException('Invalid key fingerprint!');
|
throw new \danog\MadelineProto\SecurityException('Invalid key fingerprint!');
|
||||||
}
|
}
|
||||||
$this->method_call('messages.sendEncryptedService', ['peer' => $chat, 'message' => ['_' => 'decryptedMessageService', 'action' => ['_' => 'decryptedMessageActionCommitKey', 'exchange_id' => $params['exchange_id'], 'key_fingerprint' => $key['fingerprint']]]], ['datacenter' => $this->datacenter->curdc]);
|
$this->method_call('messages.sendEncryptedService', ['peer' => $chat, 'message' => ['_' => 'decryptedMessageService', 'action' => ['_' => 'decryptedMessageActionCommitKey', 'exchange_id' => $params['exchange_id'], 'key_fingerprint' => $key['fingerprint']]]], ['datacenter' => $this->datacenter->curdc]);
|
||||||
@ -201,6 +203,7 @@ trait AuthKeyHandler
|
|||||||
}
|
}
|
||||||
if ($this->temp_rekeyed_secret_chats['fingerprint'] !== $params['key_fingerprint']) {
|
if ($this->temp_rekeyed_secret_chats['fingerprint'] !== $params['key_fingerprint']) {
|
||||||
$this->method_call('messages.sendEncryptedService', ['peer' => $chat, 'message' => ['_' => 'decryptedMessageService', 'action' => ['_' => 'decryptedMessageActionAbortKey', 'exchange_id' => $params['exchange_id']]]], ['datacenter' => $this->datacenter->curdc]);
|
$this->method_call('messages.sendEncryptedService', ['peer' => $chat, 'message' => ['_' => 'decryptedMessageService', 'action' => ['_' => 'decryptedMessageActionAbortKey', 'exchange_id' => $params['exchange_id']]]], ['datacenter' => $this->datacenter->curdc]);
|
||||||
|
|
||||||
throw new \danog\MadelineProto\SecurityException('Invalid key fingerprint!');
|
throw new \danog\MadelineProto\SecurityException('Invalid key fingerprint!');
|
||||||
}
|
}
|
||||||
\danog\MadelineProto\Logger::log(['Completing rekeying of secret chat '.$chat.'...'], \danog\MadelineProto\Logger::VERBOSE);
|
\danog\MadelineProto\Logger::log(['Completing rekeying of secret chat '.$chat.'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||||
@ -246,6 +249,7 @@ trait AuthKeyHandler
|
|||||||
if (isset($this->temp_rekeyed_secret_chats[$chat])) {
|
if (isset($this->temp_rekeyed_secret_chats[$chat])) {
|
||||||
unset($this->temp_rekeyed_secret_chats[$chat]);
|
unset($this->temp_rekeyed_secret_chats[$chat]);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->method_call('messages.discardEncryption', ['chat_id' => $chat], ['datacenter' => $this->datacenter->curdc]);
|
$this->method_call('messages.discardEncryption', ['chat_id' => $chat], ['datacenter' => $this->datacenter->curdc]);
|
||||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
|
@ -61,11 +61,13 @@ trait MessageHandler
|
|||||||
if (isset($this->secret_chats[$message['message']['chat_id']]['old_key']['fingerprint'])) {
|
if (isset($this->secret_chats[$message['message']['chat_id']]['old_key']['fingerprint'])) {
|
||||||
if ($auth_key_id !== $this->secret_chats[$message['message']['chat_id']]['old_key']['fingerprint']) {
|
if ($auth_key_id !== $this->secret_chats[$message['message']['chat_id']]['old_key']['fingerprint']) {
|
||||||
$this->discard_secret_chat($message['message']['chat_id']);
|
$this->discard_secret_chat($message['message']['chat_id']);
|
||||||
|
|
||||||
throw new \danog\MadelineProto\SecurityException('Key fingerprint mismatch');
|
throw new \danog\MadelineProto\SecurityException('Key fingerprint mismatch');
|
||||||
}
|
}
|
||||||
$old = true;
|
$old = true;
|
||||||
} else {
|
} else {
|
||||||
$this->discard_secret_chat($message['message']['chat_id']);
|
$this->discard_secret_chat($message['message']['chat_id']);
|
||||||
|
|
||||||
throw new \danog\MadelineProto\SecurityException('Key fingerprint mismatch');
|
throw new \danog\MadelineProto\SecurityException('Key fingerprint mismatch');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ trait ResponseHandler
|
|||||||
$seq--;
|
$seq--;
|
||||||
if ($seq >= $update['message']['decrypted_message']['action']['start_seq_no'] && $seq <= $update['message']['decrypted_message']['action']['end_seq_no']) {
|
if ($seq >= $update['message']['decrypted_message']['action']['start_seq_no'] && $seq <= $update['message']['decrypted_message']['action']['end_seq_no']) {
|
||||||
throw new \danog\MadelineProto\ResponseException('Resending of messages is not yet supported');
|
throw new \danog\MadelineProto\ResponseException('Resending of messages is not yet supported');
|
||||||
// $this->send_encrypted_message($update['message']['chat_id'], $update['message']['decrypted_message']);
|
// $this->send_encrypted_message($update['message']['chat_id'], $update['message']['decrypted_message']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ trait SeqNoHandler
|
|||||||
if (isset($message['decrypted_message']['in_seq_no'])) {
|
if (isset($message['decrypted_message']['in_seq_no'])) {
|
||||||
if (($message['decrypted_message']['in_seq_no'] - $this->secret_chats[$chat_id]['out_seq_no_x']) / 2 < $last) {
|
if (($message['decrypted_message']['in_seq_no'] - $this->secret_chats[$chat_id]['out_seq_no_x']) / 2 < $last) {
|
||||||
$this->discard_secret_chat($chat_id);
|
$this->discard_secret_chat($chat_id);
|
||||||
|
|
||||||
throw new \danog\MadelineProto\SecurityException('in_seq_no is not increasing');
|
throw new \danog\MadelineProto\SecurityException('in_seq_no is not increasing');
|
||||||
}
|
}
|
||||||
$last = ($message['decrypted_message']['in_seq_no'] - $this->secret_chats[$chat_id]['out_seq_no_x']) / 2;
|
$last = ($message['decrypted_message']['in_seq_no'] - $this->secret_chats[$chat_id]['out_seq_no_x']) / 2;
|
||||||
@ -32,6 +33,7 @@ trait SeqNoHandler
|
|||||||
}
|
}
|
||||||
if ($seqno > $this->secret_chats[$chat_id]['out_seq_no'] + 1) {
|
if ($seqno > $this->secret_chats[$chat_id]['out_seq_no'] + 1) {
|
||||||
$this->discard_secret_chat($chat_id);
|
$this->discard_secret_chat($chat_id);
|
||||||
|
|
||||||
throw new \danog\MadelineProto\SecurityException('in_seq_no is too big');
|
throw new \danog\MadelineProto\SecurityException('in_seq_no is too big');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +48,7 @@ trait SeqNoHandler
|
|||||||
if (isset($message['decrypted_message']['out_seq_no']) && $C < $this->secret_chats[$chat_id]['in_seq_no']) {
|
if (isset($message['decrypted_message']['out_seq_no']) && $C < $this->secret_chats[$chat_id]['in_seq_no']) {
|
||||||
if (($message['decrypted_message']['out_seq_no'] - $this->secret_chats[$chat_id]['in_seq_no_x']) / 2 !== $C) {
|
if (($message['decrypted_message']['out_seq_no'] - $this->secret_chats[$chat_id]['in_seq_no_x']) / 2 !== $C) {
|
||||||
$this->discard_secret_chat($chat_id);
|
$this->discard_secret_chat($chat_id);
|
||||||
|
|
||||||
throw new \danog\MadelineProto\SecurityException('out_seq_no hole: should be '.$C.', is '.(($message['decrypted_message']['out_seq_no'] - $this->secret_chats[$chat_id]['in_seq_no_x']) / 2));
|
throw new \danog\MadelineProto\SecurityException('out_seq_no hole: should be '.$C.', is '.(($message['decrypted_message']['out_seq_no'] - $this->secret_chats[$chat_id]['in_seq_no_x']) / 2));
|
||||||
} else {
|
} else {
|
||||||
$C++;
|
$C++;
|
||||||
@ -60,6 +63,7 @@ trait SeqNoHandler
|
|||||||
}
|
}
|
||||||
if ($seqno > $C) { // > C+1
|
if ($seqno > $C) { // > C+1
|
||||||
$this->discard_secret_chat($chat_id);
|
$this->discard_secret_chat($chat_id);
|
||||||
|
|
||||||
throw new \danog\MadelineProto\SecurityException('WARNING: out_seq_no gap detected ('.$seqno.' > '.$C.')!');
|
throw new \danog\MadelineProto\SecurityException('WARNING: out_seq_no gap detected ('.$seqno.' > '.$C.')!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -70,13 +70,14 @@ class Serialization
|
|||||||
}
|
}
|
||||||
class_exists('\Volatile');
|
class_exists('\Volatile');
|
||||||
\danog\MadelineProto\Logger::class_exists();
|
\danog\MadelineProto\Logger::class_exists();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$unserialized = \danog\Serialization::unserialize($unserialized);
|
$unserialized = \danog\Serialization::unserialize($unserialized);
|
||||||
} catch (Bug74586Exception $e) {
|
} catch (Bug74586Exception $e) {
|
||||||
$unserialized = \danog\Serialization::unserialize($unserialized);
|
$unserialized = \danog\Serialization::unserialize($unserialized);
|
||||||
/*} catch (Exception $e) {
|
/*} catch (Exception $e) {
|
||||||
$unserialized = \danog\Serialization::unserialize($unserialized);
|
$unserialized = \danog\Serialization::unserialize($unserialized);
|
||||||
*/
|
*/
|
||||||
} catch (\Error $e) {
|
} catch (\Error $e) {
|
||||||
$unserialized = \danog\Serialization::unserialize($unserialized);
|
$unserialized = \danog\Serialization::unserialize($unserialized);
|
||||||
}
|
}
|
||||||
|
@ -445,6 +445,7 @@ trait BotAPI
|
|||||||
}
|
}
|
||||||
if (preg_match('/html/i', $arguments['parse_mode'])) {
|
if (preg_match('/html/i', $arguments['parse_mode'])) {
|
||||||
$nmessage = '';
|
$nmessage = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$arguments['message'] = $this->html_fixtags($arguments['message']);
|
$arguments['message'] = $this->html_fixtags($arguments['message']);
|
||||||
$dom = new \DOMDocument();
|
$dom = new \DOMDocument();
|
||||||
|
@ -359,6 +359,7 @@ trait TL
|
|||||||
$constructorData = $this->constructors->find_by_predicate($predicate, $layer);
|
$constructorData = $this->constructors->find_by_predicate($predicate, $layer);
|
||||||
if ($constructorData === false) {
|
if ($constructorData === false) {
|
||||||
\danog\MadelineProto\Logger::log([$object], \danog\MadelineProto\Logger::FATAL_ERROR);
|
\danog\MadelineProto\Logger::log([$object], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||||
|
|
||||||
throw new Exception('Could not extract type "'.$predicate.'"');
|
throw new Exception('Could not extract type "'.$predicate.'"');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,6 +450,7 @@ trait TL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception('Missing required parameter', $current_argument['name']);
|
throw new Exception('Missing required parameter', $current_argument['name']);
|
||||||
}
|
}
|
||||||
if (!$this->is_array($arguments[$current_argument['name']]) && $current_argument['type'] === 'InputEncryptedChat') {
|
if (!$this->is_array($arguments[$current_argument['name']]) && $current_argument['type'] === 'InputEncryptedChat') {
|
||||||
|
@ -36,9 +36,11 @@ class SocketHandler extends \Threaded implements \Collectable
|
|||||||
\danog\MadelineProto\Logger::log(['WARNING: Resetting auth key...'], \danog\MadelineProto\Logger::WARNING);
|
\danog\MadelineProto\Logger::log(['WARNING: Resetting auth key...'], \danog\MadelineProto\Logger::WARNING);
|
||||||
$this->API->datacenter->sockets[$this->current]->temp_auth_key = null;
|
$this->API->datacenter->sockets[$this->current]->temp_auth_key = null;
|
||||||
$this->API->init_authorization();
|
$this->API->init_authorization();
|
||||||
|
|
||||||
throw new \danog\MadelineProto\Exception('I had to recreate the temporary authorization key');
|
throw new \danog\MadelineProto\Exception('I had to recreate the temporary authorization key');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \danog\MadelineProto\RPCErrorException($this->error, $this->error);
|
throw new \danog\MadelineProto\RPCErrorException($this->error, $this->error);
|
||||||
}
|
}
|
||||||
$this->API->handle_messages($this->current);
|
$this->API->handle_messages($this->current);
|
||||||
|
@ -78,6 +78,7 @@ trait AuthKeyHandler
|
|||||||
$b = \phpseclib\Math\BigInteger::randomRange($this->two, $dh_config['p']->subtract($this->two));
|
$b = \phpseclib\Math\BigInteger::randomRange($this->two, $dh_config['p']->subtract($this->two));
|
||||||
$g_b = $dh_config['g']->powMod($b, $dh_config['p']);
|
$g_b = $dh_config['g']->powMod($b, $dh_config['p']);
|
||||||
$this->check_G($g_b, $dh_config['p']);
|
$this->check_G($g_b, $dh_config['p']);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$res = $this->method_call('phone.acceptCall', ['peer' => $call, 'g_b' => $g_b->toBytes(), 'protocol' => ['_' => 'phoneCallProtocol', 'udp_reflector' => true, 'udp_p2p' => true, 'min_layer' => 65, 'max_layer' => 65]], ['datacenter' => $this->datacenter->curdc]);
|
$res = $this->method_call('phone.acceptCall', ['peer' => $call, 'g_b' => $g_b->toBytes(), 'protocol' => ['_' => 'phoneCallProtocol', 'udp_reflector' => true, 'udp_p2p' => true, 'min_layer' => 65, 'max_layer' => 65]], ['datacenter' => $this->datacenter->curdc]);
|
||||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
@ -92,6 +93,7 @@ trait AuthKeyHandler
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
$this->calls[$res['phone_call']['id']]->storage['b'] = $b;
|
$this->calls[$res['phone_call']['id']]->storage['b'] = $b;
|
||||||
@ -257,6 +259,7 @@ trait AuthKeyHandler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
\danog\MadelineProto\Logger::log(['Discarding call '.$call['id'].'...'], \danog\MadelineProto\Logger::VERBOSE);
|
\danog\MadelineProto\Logger::log(['Discarding call '.$call['id'].'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$res = $this->method_call('phone.discardCall', ['peer' => $call, 'duration' => time() - $this->calls[$call['id']]->whenCreated(), 'connection_id' => $this->calls[$call['id']]->getPreferredRelayID(), 'reason' => $reason], ['datacenter' => $this->datacenter->curdc]);
|
$res = $this->method_call('phone.discardCall', ['peer' => $call, 'duration' => time() - $this->calls[$call['id']]->whenCreated(), 'connection_id' => $this->calls[$call['id']]->getPreferredRelayID(), 'reason' => $reason], ['datacenter' => $this->datacenter->curdc]);
|
||||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
|
@ -97,6 +97,7 @@ trait Login
|
|||||||
}
|
}
|
||||||
$this->authorized = self::NOT_LOGGED_IN;
|
$this->authorized = self::NOT_LOGGED_IN;
|
||||||
\danog\MadelineProto\Logger::log(['Logging in as a normal user...'], \danog\MadelineProto\Logger::NOTICE);
|
\danog\MadelineProto\Logger::log(['Logging in as a normal user...'], \danog\MadelineProto\Logger::NOTICE);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$authorization = $this->method_call(
|
$authorization = $this->method_call(
|
||||||
'auth.signIn',
|
'auth.signIn',
|
||||||
@ -122,6 +123,7 @@ trait Login
|
|||||||
|
|
||||||
return ['_' => 'account.needSignup'];
|
return ['_' => 'account.needSignup'];
|
||||||
}
|
}
|
||||||
|
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
$this->authorized = self::LOGGED_IN;
|
$this->authorized = self::LOGGED_IN;
|
||||||
|
@ -18,6 +18,7 @@ if (file_exists('web_data.php')) {
|
|||||||
|
|
||||||
echo 'Deserializing MadelineProto from session.madeline...'.PHP_EOL;
|
echo 'Deserializing MadelineProto from session.madeline...'.PHP_EOL;
|
||||||
$MadelineProto = false;
|
$MadelineProto = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('session.madeline');
|
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('session.madeline');
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user