Skip to content

Commit

Permalink
Get default bot check back
Browse files Browse the repository at this point in the history
  • Loading branch information
punyflash committed Mar 30, 2021
1 parent b89337b commit 7923ec4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/BotManager.php
Expand Up @@ -128,7 +128,7 @@ class BotManager

/**
* Default bot name.
* @var string
* @var string|null
*/
protected $default;

Expand Down Expand Up @@ -180,7 +180,11 @@ public function __unset(string $key)
*/
public function bot(string $name = null)
{
$bot = $name ?? $this->default ?? $this->bots()[0];
$bot = $name ?? $this->default ?? null;

if (is_null($bot)) {
throw TeleBotObjectException::defaultBotIsNotSet();
}

if (!isset($this->bots[$bot])) {
throw TeleBotObjectException::botNotFound($bot);
Expand Down

0 comments on commit 7923ec4

Please sign in to comment.