mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
28 lines
789 B
C#
28 lines
789 B
C#
|
|
using System.Text;
|
||
|
|
using West.TelegramBot.ContentStore.Model;
|
||
|
|
|
||
|
|
namespace West.TelegramBot.ContentStore.API;
|
||
|
|
|
||
|
|
public class KittiesApi : IKittiesApi
|
||
|
|
{
|
||
|
|
private readonly HttpClient _client;
|
||
|
|
|
||
|
|
public KittiesApi(HttpClient client)
|
||
|
|
{
|
||
|
|
_client = client;
|
||
|
|
}
|
||
|
|
|
||
|
|
public async Task<KittiesResponse> GetKittiesImageAsync(string type)
|
||
|
|
{
|
||
|
|
var httpResponse = await _client.GetAsync($"v1/{type}");
|
||
|
|
var headers = httpResponse.Headers;
|
||
|
|
var titleBytes =
|
||
|
|
Convert.FromBase64String(headers.GetValues("X-Video-Title").First());
|
||
|
|
|
||
|
|
return new KittiesResponse(
|
||
|
|
await httpResponse.Content.ReadAsStreamAsync(),
|
||
|
|
headers.GetValues("X-Video-Source").First(),
|
||
|
|
Encoding.UTF8.GetString(titleBytes)
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|