Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allowed_updates webhook #1115

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Laravel/Artisan/WebhookCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@
$params['certificate'] = $certificatePath;
}

$allowedUpdates = data_get($this->config, 'allowed_updates');
if ($allowedUpdates) {
$params['allowed_updates'] = $allowedUpdates;

Check warning on line 95 in src/Laravel/Artisan/WebhookCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Laravel/Artisan/WebhookCommand.php#L93-L95

Added lines #L93 - L95 were not covered by tests
}

$response = $this->telegram->setWebhook($params);
if ($response) {
$this->info('Success: Your webhook has been set!');
Expand Down
4 changes: 4 additions & 0 deletions src/Laravel/config/telegram.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
'token' => env('TELEGRAM_BOT_TOKEN', 'YOUR-BOT-TOKEN'),
'certificate_path' => env('TELEGRAM_CERTIFICATE_PATH', 'YOUR-CERTIFICATE-PATH'),
'webhook_url' => env('TELEGRAM_WEBHOOK_URL', 'YOUR-BOT-WEBHOOK-URL'),
/*
* @see https://core.telegram.org/bots/api#update
*/
'allowed_updates' => null,

Check warning on line 41 in src/Laravel/config/telegram.php

View check run for this annotation

Codecov / codecov/patch

src/Laravel/config/telegram.php#L41

Added line #L41 was not covered by tests
'commands' => [
//Acme\Project\Commands\MyTelegramBot\BotCommand::class
],
Expand Down
4 changes: 4 additions & 0 deletions src/Methods/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
{
$this->validateHookUrl($params['url']);

if (isset($params['allowed_updates'])) {
$params['allowed_updates'] = json_encode($params['allowed_updates'], JSON_THROW_ON_ERROR);

Check warning on line 95 in src/Methods/Update.php

View check run for this annotation

Codecov / codecov/patch

src/Methods/Update.php#L95

Added line #L95 was not covered by tests
}

if (isset($params['certificate'])) {
$params['certificate'] = $this->formatCertificate($params['certificate']);

Expand Down
Loading