|
10 | 10 |
|
11 | 11 | final class TelegramClient
|
12 | 12 | {
|
13 |
| - public const BASE_API_URL = 'https://api.telegram.org'; |
| 13 | + public const BASE_BOT_URL = 'https://api.telegram.org/bot'; |
14 | 14 |
|
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}'; |
18 | 16 |
|
19 | 17 | private HttpClientInterface $httpClientHandler;
|
20 | 18 |
|
21 | 19 | private string $baseBotUrl;
|
22 | 20 |
|
23 |
| - private string $baseFileUrl; |
24 |
| - |
25 | 21 | public function __construct(?HttpClientInterface $httpClientHandler = null, ?string $baseBotUrl = null)
|
26 | 22 | {
|
27 | 23 | $this->httpClientHandler = $httpClientHandler ?? new GuzzleHttpClient();
|
28 | 24 |
|
29 | 25 | $this->baseBotUrl = $baseBotUrl ?? self::BASE_BOT_URL;
|
30 |
| - $this->baseFileUrl = $baseBotUrl ?? self::BASE_API_URL; |
31 | 26 | }
|
32 | 27 |
|
33 | 28 | public function getHttpClientHandler(): HttpClientInterface
|
@@ -66,9 +61,11 @@ public function sendRequest(TelegramRequest $request): TelegramResponse
|
66 | 61 | */
|
67 | 62 | public function getFileUrl(string $path, TelegramRequest $request): string
|
68 | 63 | {
|
| 64 | + $baseFileUrl = str_replace('/bot', '', $this->baseBotUrl); |
| 65 | + |
69 | 66 | 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], |
72 | 69 | $this->fileUrl
|
73 | 70 | );
|
74 | 71 | }
|
|
0 commit comments