mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
[store] Basic content store implementation.
- Bump Telegram Bot Framework to 0.6.9-gf1e77653ff
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using Newtonsoft.Json;
|
||||
using West.TelegramBot.ContentStore.Model;
|
||||
|
||||
namespace West.TelegramBot.ContentStore.Service;
|
||||
|
||||
public abstract class AnimalAsAService : IRandomMediaService
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
|
||||
protected AnimalAsAService(Uri baseAddress)
|
||||
{
|
||||
_httpClient = new HttpClient
|
||||
{
|
||||
BaseAddress = baseAddress
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<RandomMedia> GetRandomMediaAsync()
|
||||
{
|
||||
var resp = await _httpClient.GetAsync("images/search");
|
||||
var catImage = JsonConvert.DeserializeObject<List<AnimalImage>>(await resp.Content.ReadAsStringAsync())[0];
|
||||
return new RandomMedia(catImage.Url);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user