Skip to content

Commit 0163bab

Browse files
committed
Fix forgotten webhook parameters.
1 parent 6538ddd commit 0163bab

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/BotManager.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public function validateSecret(bool $force = false): self
187187
public function validateAndSetWebhook(): self
188188
{
189189
$webhook = $this->params->getBotParam('webhook');
190-
if (empty($webhook) && $this->action->isAction(['set', 'reset'])) {
190+
if (empty($webhook['url'] ?? null) && $this->action->isAction(['set', 'reset'])) {
191191
throw new InvalidWebhookException('Invalid webhook');
192192
}
193193

@@ -199,14 +199,14 @@ public function validateAndSetWebhook(): self
199199

200200
if ($this->action->isAction(['set', 'reset'])) {
201201
$webhook_params = array_filter([
202-
'certificate' => $this->params->getBotParam('certificate'),
203-
'max_connections' => $this->params->getBotParam('max_connections'),
204-
'allowed_updates' => $this->params->getBotParam('allowed_updates'),
202+
'certificate' => $webhook['certificate'] ?? null,
203+
'max_connections' => $webhook['max_connections'] ?? null,
204+
'allowed_updates' => $webhook['allowed_updates'] ?? null,
205205
]);
206206

207207
$this->handleOutput(
208208
$this->telegram->setWebhook(
209-
$webhook . '?a=handle&s=' . $this->params->getBotParam('secret'),
209+
$webhook['url'] . '?a=handle&s=' . $this->params->getBotParam('secret'),
210210
$webhook_params
211211
)->getDescription() . PHP_EOL
212212
);
@@ -324,7 +324,7 @@ protected function setBotExtrasRequest(): self
324324
*/
325325
public function handleRequest(): self
326326
{
327-
if (empty($this->params->getBotParam('webhook'))) {
327+
if (empty($this->params->getBotParam('webhook.url'))) {
328328
if ($loop_time = $this->getLoopTime()) {
329329
$this->handleGetUpdatesLoop($loop_time, $this->getLoopInterval());
330330
} else {

tests/TelegramBotManager/Tests/BotManagerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function testValidateSecretSuccess()
153153
public function testValidateAndSetWebhookSuccess()
154154
{
155155
$botManager = new BotManager(array_merge(ParamsTest::$demo_vital_params, [
156-
'webhook' => 'https://web/hook.php',
156+
'webhook' => ['url' => 'https://web/hook.php'],
157157
]));
158158

159159
TestHelpers::setObjectProperty(
@@ -211,7 +211,7 @@ public function testValidateAndSetWebhookSuccess()
211211
public function testValidateAndSetWebhookSuccessLiveBot()
212212
{
213213
$botManager = new BotManager(array_merge(self::$live_params, [
214-
'webhook' => 'https://example.com/hook.php',
214+
'webhook' => ['url' => 'https://example.com/hook.php'],
215215
]));
216216

217217
// Make sure the webhook isn't set to start with.
@@ -244,7 +244,7 @@ public function testDeleteWebhookViaRunLiveBot()
244244
{
245245
$_GET = ['a' => 'unset'];
246246
$botManager = new BotManager(array_merge(self::$live_params, [
247-
'webhook' => 'https://example.com/hook.php',
247+
'webhook' => ['url' => 'https://example.com/hook.php'],
248248
]));
249249
$output = $botManager->run()->getOutput();
250250

0 commit comments

Comments
 (0)