[store] Basic content store implementation.

- Bump Telegram Bot Framework to 0.6.9-gf1e77653ff
This commit is contained in:
West14
2022-02-16 17:07:30 +02:00
parent 67d0e81953
commit e815deba58
15 changed files with 376 additions and 2 deletions
@@ -0,0 +1,28 @@
using Newtonsoft.Json;
using Telegram.Bot.Types;
using West.TelegramBot.ContentStore.Model;
namespace West.TelegramBot.ContentStore.Service;
public class OBoobsService : IRandomMediaService
{
private readonly HttpClient _httpClient;
public OBoobsService()
{
_httpClient = new HttpClient
{
BaseAddress = new Uri("http://api.oboobs.ru")
};
}
public async Task<RandomMedia> GetRandomMediaAsync()
{
var httpResp = await _httpClient.GetAsync("boobs/1/1/random");
var boobsResponse = JsonConvert.DeserializeObject<List<OBoobsItem>>(await httpResp.Content.ReadAsStringAsync());
var boobsItem = boobsResponse[0];
var boobsId = boobsItem.Id.ToString("D5");
return new RandomMedia($"https://media.oboobs.ru/boobs/{boobsId}.jpg", boobsItem.Model);
}
}