Rename the method and use request class from container

parent e3f13a1c
......@@ -83,7 +83,7 @@ class ChatsCommand extends AdminCommand
$chat = new Chat($result);
$whois = $chat->getId();
if ($this->telegram->getCommandObject('whois')) {
if ($this->telegram->createCommandObject('whois')) {
// We can't use '-' in command because part of it will become unclickable
$whois = '/whois' . str_replace('-', 'g', $chat->getId());
}
......
......@@ -10,9 +10,11 @@
namespace Longman\TelegramBot\Commands\AdminCommands;
use Exception;
use Longman\TelegramBot\Commands\AdminCommand;
use Longman\TelegramBot\DB;
use Longman\TelegramBot\Http\Client;
use Longman\TelegramBot\Http\Request;
/**
* Admin "/debug" command
......@@ -94,8 +96,11 @@ class DebugCommand extends AdminCommand
$webhook_info_title = '*Webhook Info:*';
try {
/** @var \Longman\TelegramBot\Http\Request $request */
$request = $this->getTelegram()->getContainer()->make(Request::class);
// Check if we're actually using the Webhook method.
if (Client::getInput() === '') {
if (empty($request->json()->all())) {
$debug_info[] = $webhook_info_title . ' `Using getUpdates method, not Webhook.`';
} else {
$webhook_info_result = json_decode(Client::getWebhookInfo(), true)['result'];
......@@ -111,7 +116,7 @@ class DebugCommand extends AdminCommand
$webhook_info_result_str
);
}
} catch (\Exception $e) {
} catch (Exception $e) {
$debug_info[] = $webhook_info_title . sprintf(' `Failed to get webhook info! (%s)`', $e->getMessage());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment