diff --git a/bots/MadelineProto_bot.php b/bots/MadelineProto_bot.php index 3834ee8fb..c595966e6 100755 --- a/bots/MadelineProto_bot.php +++ b/bots/MadelineProto_bot.php @@ -13,6 +13,7 @@ If not, see . require '../vendor/autoload.php'; $settings = []; +$settings = ["app_info"=>["api_id"=>6,"api_hash"=>"eb06d4abfb49dc3eeb1aeb98ae0f581e"]]; $MadelineProto = false; try { $MadelineProto = \danog\MadelineProto\Serialization::deserialize('MadelineProto_bot.madeline'); @@ -66,11 +67,11 @@ while (true) { continue; } try { - if (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]); } } 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()]); } break; case 'updateNewChannelMessage': @@ -82,9 +83,9 @@ while (true) { $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]); } } 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()]); } 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()]); } break; case 'updateBotInlineQuery': diff --git a/bots/pipesbot.php b/bots/pipesbot.php index 4d7bc4c63..1aa8c78c9 100755 --- a/bots/pipesbot.php +++ b/bots/pipesbot.php @@ -12,13 +12,19 @@ If not, see . */ require '../vendor/autoload.php'; -$settings = []; +$settings = ["app_info"=>["api_id"=>6,"api_hash"=>"eb06d4abfb49dc3eeb1aeb98ae0f581e"]]; $MadelineProto = false; +$uMadelineProto = false; try { $MadelineProto = \danog\MadelineProto\Serialization::deserialize('pipesbot.madeline'); } catch (\danog\MadelineProto\Exception $e) { +var_dump($e->getMessage()); +} +try { + $uMadelineProto = \danog\MadelineProto\Serialization::deserialize('pwr.madeline'); +} catch (\danog\MadelineProto\Exception $e) { +var_dump($e->getMessage()); } -$uMadelineProto = \danog\MadelineProto\Serialization::deserialize('pwr.madeline'); if (file_exists('token.php') && $MadelineProto === false) { include_once 'token.php'; $MadelineProto = new \danog\MadelineProto\API($settings); @@ -27,7 +33,7 @@ if (file_exists('token.php') && $MadelineProto === false) { } if ($uMadelineProto === false) { echo 'Loading MadelineProto...'.PHP_EOL; - $uMadelineProto = new \danog\MadelineProto\API(['updates' => ['handle_updates' => false]]); + $uMadelineProto = new \danog\MadelineProto\API(array_merge($settings, ['updates' => ['handle_updates' => false]])); $sentCode = $uMadelineProto->phone_login(readline()); \danog\MadelineProto\Logger::log([$sentCode], \danog\MadelineProto\Logger::NOTICE); echo 'Enter the code you received: '; @@ -145,7 +151,7 @@ var_dump($update); $query = array_shift($exploded); foreach ($exploded as $current => $botq) { $bot = preg_replace('|:.*|', '', $botq); - if ($bot === '' || $uMadelineProto->get_info($bot)['bot_api_id'] === $MadelineProto->API->datacenter->authorization['user']['id']) { + if ($bot === '' || $uMadelineProto->get_info($bot)['bot_api_id'] === $MadelineProto->API->authorization['user']['id']) { $toset['switch_pm'] = $sswitch; break; } @@ -213,6 +219,6 @@ var_dump($update); } } } - \danog\MadelineProto\Serialization::serialize('bot.madeline', $MadelineProto); + \danog\MadelineProto\Serialization::serialize('pipesbot.madeline', $MadelineProto); \danog\MadelineProto\Serialization::serialize('pwr.madeline', $uMadelineProto); } diff --git a/composer.json b/composer.json index 583da6572..c453bae9a 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "erusev/parsedown": "^1.6", "rollbar/rollbar": "dev-master", "ext-mbstring": "*", - "ext-curl" + "ext-curl": "*" }, "require-dev": { "phpdocumentor/reflection-docblock": "^3.1"