Skip to content

Commit

Permalink
V3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
luzrain committed Feb 27, 2024
1 parent 0d450c1 commit 7a3e9ea
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 29 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"require": {
"php": ">=8.2",
"luzrain/telegram-bot-api": "^2.1.1",
"luzrain/telegram-bot-api": "^2.3.1|^3.0",
"symfony/config": "^6.3|^7.0",
"symfony/console": "^6.3|^7.0",
"symfony/dependency-injection": "^6.3|^7.0",
Expand Down
29 changes: 3 additions & 26 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public function getConfigTreeBuilder(): TreeBuilder
->always(fn ($values) => array_map(strval(...), $values))
->end()
->validate()
->ifTrue(fn ($configArray) => array_diff($configArray, $this->getAllowedUpdates()) !== [])
->ifTrue(fn ($configArray) => array_diff($configArray, Update::getUpdateTypes()) !== [])
->then(function ($configArray) {
if (array_diff($configArray, $this->getAllowedUpdates()) !== []) {
$allowedKeys = implode(', ', $this->getAllowedUpdates());
if (array_diff($configArray, Update::getUpdateTypes()) !== []) {
$allowedKeys = implode(', ', Update::getUpdateTypes());
throw new \InvalidArgumentException(sprintf('Invalid updates list. Allowed updates: %s', $allowedKeys));
}
return $configArray;
Expand All @@ -57,27 +57,4 @@ public function getConfigTreeBuilder(): TreeBuilder

return $treeBuilder;
}

/**
* @return list<string>
*/
private function getAllowedUpdates(): array
{
return [
Update::MESSAGE_TYPE,
Update::EDITED_MESSAGE_TYPE,
Update::CHANNEL_POST_TYPE,
Update::EDITED_CHANNEL_POST_TYPE,
Update::INLINE_QUERY_TYPE,
Update::CHOSEN_INLINE_RESULT_TYPE,
Update::CALLBACK_QUERY_TYPE,
Update::SHIPPING_QUERY_TYPE,
Update::PRE_CHECKOUT_QUERY_TYPE,
Update::POLL_TYPE,
Update::POLL_ANSWER_TYPE,
Update::MY_CHAT_MEMBER_TYPE,
Update::CHAT_MEMBER_TYPE,
Update::CHAT_JOIN_REQUEST_TYPE,
];
}
}
2 changes: 1 addition & 1 deletion src/TelegramBot/Command/WebhookInfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$allowedUpdates = $webhookInfo->allowedUpdates === null
? 'All update types except chat_member'
? 'All update types'
: '[' . implode(',', $webhookInfo->allowedUpdates) . ']'
;

Expand Down
2 changes: 1 addition & 1 deletion src/TelegramBot/TelegramCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function getUser(): Type\User
protected function reply(
string $text,
string|null $parseMode = null,
/** @deprecated */
bool|null $disableWebPagePreview = null,
bool|null $disableNotification = null,
bool|null $protectContent = null,
Expand All @@ -34,7 +35,6 @@ protected function reply(
chatId: $this->getUser()->id,
text: $text,
parseMode: $parseMode,
disableWebPagePreview: $disableWebPagePreview,
disableNotification: $disableNotification,
protectContent: $protectContent,
replyMarkup: $replyMarkup,
Expand Down

0 comments on commit 7a3e9ea

Please sign in to comment.