diff --git a/bots/pipesbot.php b/bots/pipesbot.php index fa278c80..d795d5a2 100755 --- a/bots/pipesbot.php +++ b/bots/pipesbot.php @@ -195,26 +195,34 @@ while (true) { $MadelineProto->messages->sendMessage(['peer' => '@danogentili', '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) { + var_dump($e->getMessage()); } catch (\danog\MadelineProto\Exception $e) { + var_dump($e->getMessage()); } try { $toset['switch_pm'] = $sswitch; $MadelineProto->messages->setInlineBotResults($toset); } catch (\danog\MadelineProto\RPCErrorException $e) { + var_dump($e->getMessage()); } catch (\danog\MadelineProto\Exception $e) { + var_dump($e->getMessage()); } } catch (\danog\MadelineProto\Exception $e) { try { $MadelineProto->messages->sendMessage(['peer' => '@danogentili', '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) { + var_dump($e->getMessage()); } catch (\danog\MadelineProto\Exception $e) { + var_dump($e->getMessage()); } try { $toset['switch_pm'] = $sswitch; $MadelineProto->messages->setInlineBotResults($toset); } catch (\danog\MadelineProto\RPCErrorException $e) { + var_dump($e->getMessage()); } catch (\danog\MadelineProto\Exception $e) { + var_dump($e->getMessage()); } } } diff --git a/bots/pwrtelegram_debug_bot.php b/bots/pwrtelegram_debug_bot.php index f41d7a75..9cc556a4 100755 --- a/bots/pwrtelegram_debug_bot.php +++ b/bots/pwrtelegram_debug_bot.php @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with Mad If not, see . */ require '../vendor/autoload.php'; -$settings = []; +$settings = ['app_info'=>['api_id'=>6, 'api_hash'=>'eb06d4abfb49dc3eeb1aeb98ae0f581e']]; include_once 'token.php'; try { $MadelineProto = \danog\MadelineProto\Serialization::deserialize('b.madeline'); @@ -93,7 +93,15 @@ function getfiles($token, &$params) } } } - +function recurse($array, $prefix = '') { + $res = []; + foreach ($array as $k => $v) { + if (is_array($v)) { + $res = array_merge(recurse($v, $prefix.$k.'->'), $res); + } else if (is_integer($v)) $res[$prefix.$k] = $v; + } + return $res; +} $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 @@ -111,6 +119,10 @@ while (true) { $bot_api_id = $message = $res['files'][$update['update']['message']['id']]; $bot_api_id_b256 = base64url_decode($bot_api_id); $bot_api_id_rledecoded = rle_decode($bot_api_id_b256); + $message .= PHP_EOL.PHP_EOL; + for ($x = 0; $x < strlen($bot_api_id_rledecoded)-3; $x++) { + $message .= 'Bytes '.$x.'-'.($x+4).': '.\danog\PHP\Struct::unpack('param (value): start-end (length)
'.PHP_EOL; + PHP_EOL.'param (value): start-end (length)'.PHP_EOL.PHP_EOL; $bot_api = foreach_offset_length($bot_api_id_rledecoded); - $mtproto = $MadelineProto->get_download_info($update['update']['message']['media'])['InputFileLocation']; + //$mtproto = $MadelineProto->get_download_info($update['update']['message']['media'])['InputFileLocation']; + //unset($mtproto['_']); $m = []; - unset($mtproto['_']); + $mtproto = recurse($update['update']['message']); + /* if (isset($mtproto['version'])) { unset($mtproto['version']); } if (isset($update['update']['message']['media']['photo'])) { $mtproto['id'] = $update['update']['message']['media']['photo']['id']; } + $mtproto['sender_id'] = $update['update']['message']['from_id']; if (isset($update['update']['message']['media']['photo'])) { $mtproto['access_hash'] = $update['update']['message']['media']['photo']['access_hash']; } @@ -138,11 +153,11 @@ while (true) { } if (isset($update['update']['message']['media']['document'])) { $mtproto['access_hash'] = $update['update']['message']['media']['document']['access_hash']; - } + }*/ foreach ($mtproto as $key => $n) { foreach ($bot_api as $bn) { if ($bn['number'] === $n) { - $m[$bn['offset'] + $bn['length']] = $key.' ('.$n.'): '.$bn['offset'].'-'.($bn['offset'] + $bn['length']).' ('.$bn['length'].')'.PHP_EOL; + $m[$bn['offset'] + $bn['length']] = $key.' ('.$n.'): '.$bn['offset'].'-'.($bn['offset'] + $bn['length']).' ('.$bn['length'].') FOUND'.PHP_EOL; unset($mtproto[$key]); } } @@ -154,6 +169,8 @@ while (true) { foreach ($mtproto as $key => $n) { $message .= $key.' ('.$n.'): not found'.PHP_EOL; } + $message .= PHP_EOL.PHP_EOL.'File number: '.\danog\PHP\Struct::unpack('messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => $message, 'reply_to_msg_id' => $update['update']['message']['id'], 'parse_mode' => 'markdown']); } } catch (\danog\MadelineProto\RPCErrorException $e) { diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index 6cab81fc..72f88157 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -289,8 +289,8 @@ class MTProto extends \Volatile $this->authorized = self::LOGGED_IN; } $this->updates_state['sync_loading'] = false; - foreach ($this->channels_state as &$state) { - $state['sync_loading'] = false; + foreach ($this->channels_state as $key => $state) { + $this->channels_state[$key]['sync_loading'] = false; } foreach (debug_backtrace(0) as $trace) { if (isset($trace['function']) && isset($trace['class']) && $trace['function'] === 'deserialize' && $trace['class'] === 'danog\MadelineProto\Serialization') {