Skip to content

Commit

Permalink
Texts and small fixes for setcommands command
Browse files Browse the repository at this point in the history
  • Loading branch information
luzrain committed Sep 25, 2023
1 parent 9abb164 commit b1dd9d7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/TelegramBot/Command/ButtonSetCommandsCommand.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
}

if ($commands === []) {
$io->warning('Could not find publish commands');
$io->warning('Could not find any commands to publish');

return Command::SUCCESS;
}
Expand All @@ -67,7 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return Command::FAILURE;
}

$io->success('Bot\'s menu button set');
$io->success('Bot\'s menu button has been set');

return Command::SUCCESS;
}
Expand Down
9 changes: 3 additions & 6 deletions src/TelegramBot/CommandMetadataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@ public function __construct(
}

/**
* @return list<OnCommand>
* @return \Generator<OnCommand>
*/
public function gelMetadataList(): array
public function gelMetadataList(): \Generator
{
$list = [];
foreach ($this->controllersMap as ['controller' => $controller]) {
$command = $this->instantiateAttribute($controller);
if ($command !== null) {
$list[] = $command;
yield $command;
}
}

return $list;
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/TelegramBot/LongPollingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
final class LongPollingService
{
private const LIMIT = 50;

private int $timeout = 15;
private int $offset = 0;

Expand Down
7 changes: 4 additions & 3 deletions tests/CommandMetadataProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ final class CommandMetadataProviderTest extends KernelTestCase
{
public function testCommandsMetadata(): void
{
/** @var CommandMetadataProvider $commandMetadataProvider */
$commandMetadataProvider = self::getContainer()->get('telegram_bot.command_metadata_provider');
$list = $commandMetadataProvider->gelMetadataList();
$list = iterator_to_array($commandMetadataProvider->gelMetadataList());

$this->assertCount(4, $list);
$this->assertObjectInArray(new OnCommand('/start', '', false, 0), $list);
Expand All @@ -37,8 +38,8 @@ public function testCommandsMetadata(): void
$this->assertObjectInArray(new OnCommand('/test3', 'test3 command description', false, 0), $list);
}

private function assertObjectInArray(object $obj, array $arra): void
private function assertObjectInArray(object $obj, array $array): void
{
$this->assertContains(json_encode($obj), array_map(fn ($a) => json_encode($a), $arra));
$this->assertContains(json_encode($obj), array_map(fn ($a) => json_encode($a), $array));
}
}

0 comments on commit b1dd9d7

Please sign in to comment.