diff --git a/README.md b/README.md index 5d5fb97..2f94eb0 100644 --- a/README.md +++ b/README.md @@ -45,10 +45,8 @@ If your project uses multiple bots, you can easily interact with them, just add ```php addBot(new BotConfig('secondary', 'TELEGRAM_BOT_TOKEN_2')); -$tgWebValid->addBot(new BotConfig('minor', 'TELEGRAM_BOT_TOKEN_3')); +$tgWebValid->addBot('secondary', 'TELEGRAM_BOT_TOKEN_2'); +$tgWebValid->addBot('minor', 'TELEGRAM_BOT_TOKEN_3'); ``` Getting a bot to work is easy. Specify the name of the bot to work with, or leave the argument empty to get the default bot @@ -136,7 +134,6 @@ $loginWidget->authDate; addBot(new BotConfig('secondary', 'TELEGRAM_BOT_TOKEN_2')); - $tgWebValid->addBot(new BotConfig('minor', 'TELEGRAM_BOT_TOKEN_3')); + $tgWebValid->addBot('secondary', 'TELEGRAM_BOT_TOKEN_2'); + $tgWebValid->addBot('minor', 'TELEGRAM_BOT_TOKEN_3'); $initData = $tgWebValid->bot()->validateInitData('query_id=...'); diff --git a/src/TgWebValid.php b/src/TgWebValid.php index 09696a7..9a87439 100644 --- a/src/TgWebValid.php +++ b/src/TgWebValid.php @@ -18,9 +18,9 @@ public function __construct( { } - public function addBot(BotConfig $bot): void + public function addBot(string $name, string $token): void { - $this->bots[$bot->name] = $bot; + $this->bots[$name] = new BotConfig($name, $token); } public function bot(?string $name = null): Bot diff --git a/tests/TgWebValidTest.php b/tests/TgWebValidTest.php index 56c90e3..b10b627 100644 --- a/tests/TgWebValidTest.php +++ b/tests/TgWebValidTest.php @@ -4,7 +4,6 @@ use PHPUnit\Framework\TestCase; use TgWebValid\Bot; -use TgWebValid\BotConfig; use TgWebValid\Exceptions\BotException; use TgWebValid\TgWebValid; @@ -15,8 +14,8 @@ class TgWebValidTest extends TestCase public function setUp(): void { $this->manager = new TgWebValid('DEFAULT_BOT_TOKEN'); - $this->manager->addBot(new BotConfig('next', 'NEXT_BOT_TOKEN')); - $this->manager->addBot(new BotConfig('other', 'OTHER_BOT_TOKEN')); + $this->manager->addBot('next', 'NEXT_BOT_TOKEN'); + $this->manager->addBot('other', 'OTHER_BOT_TOKEN'); } public function testWithoutName(): void