Skip to content

Commit 31a71ae

Browse files
committed
Revise Base File URL
1 parent 73ec22c commit 31a71ae

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/TelegramClient.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,19 @@
1010

1111
final class TelegramClient
1212
{
13-
public const BASE_API_URL = 'https://api.telegram.org';
13+
public const BASE_BOT_URL = 'https://api.telegram.org/bot';
1414

15-
public const BASE_BOT_URL = self::BASE_API_URL.'/bot';
16-
17-
private string $fileUrl = '{BASE_FILE_URL}/file/bot{TOKEN}/{FILE_PATH}';
15+
private string $fileUrl = '{BASE_BOT_URL}/file/bot{TOKEN}/{FILE_PATH}';
1816

1917
private HttpClientInterface $httpClientHandler;
2018

2119
private string $baseBotUrl;
2220

23-
private string $baseFileUrl;
24-
2521
public function __construct(?HttpClientInterface $httpClientHandler = null, ?string $baseBotUrl = null)
2622
{
2723
$this->httpClientHandler = $httpClientHandler ?? new GuzzleHttpClient();
2824

2925
$this->baseBotUrl = $baseBotUrl ?? self::BASE_BOT_URL;
30-
$this->baseFileUrl = $baseBotUrl ?? self::BASE_API_URL;
3126
}
3227

3328
public function getHttpClientHandler(): HttpClientInterface
@@ -66,9 +61,11 @@ public function sendRequest(TelegramRequest $request): TelegramResponse
6661
*/
6762
public function getFileUrl(string $path, TelegramRequest $request): string
6863
{
64+
$baseFileUrl = str_replace('/bot', '', $this->baseBotUrl);
65+
6966
return str_replace(
70-
['{BASE_FILE_URL}', '{TOKEN}', '{FILE_PATH}'],
71-
[$this->baseFileUrl, $request->getAccessToken(), $path],
67+
['{BASE_BOT_URL}', '{TOKEN}', '{FILE_PATH}'],
68+
[$baseFileUrl, $request->getAccessToken(), $path],
7269
$this->fileUrl
7370
);
7471
}

0 commit comments

Comments
 (0)