Updated Bot

This commit is contained in:
netkas 2024-10-06 16:13:03 -04:00
parent 0f7e2641e7
commit bf0b8268de

View file

@ -1,5 +1,12 @@
<?php
/**
* Constructs a new Bot instance.
*
* @param string $token The bot token provided by BotFather.
* @param string $endpoint The API endpoint to use.
*/
namespace TgBotLib;
class Bot
@ -7,27 +14,56 @@ class Bot
private string $token;
private string $endpoint;
/**
* Constructs a new Bot instance
*
* @param string $token The bot token provided by BotFather
* @param string $endpoint The API endpoint to use
*/
public function __construct(string $token, string $endpoint='https://api.telegram.org')
{
$this->token = $token;
$this->endpoint = $endpoint;
}
/**
* Sets the token for the bot.
*
* @param string $token The bot token provided by BotFather
* @return void
*/
public function setToken(string $token): void
{
$this->token = $token;
}
/**
* Retrieves the bot's token
*
* @return string The bot token
*/
public function getToken(): string
{
return $this->token;
}
/**
* Sets the API endpoint.
*
* @param string $endpoint The new API endpoint to be set.
* @return void
*/
public function setEndpoint(string $endpoint): void
{
$this->endpoint = $endpoint;
}
/**
* Retrieves the API endpoint or constructs a specific method endpoint
*
* @param string|null $method Optional method name to append to the endpoint
* @return string The complete API endpoint URL
*/
public function getEndpoint(string $method=null): string
{
if($method)