feat(store): code cleanup, make some fund with "unlucky" members

This commit is contained in:
Andriy
2023-12-22 21:43:01 +02:00
parent d32b976e1a
commit 7e41fc93fc
10 changed files with 40 additions and 18 deletions
+21 -3
View File
@@ -1,13 +1,31 @@
using Telegram.Bot.Types;
using System.Security.Cryptography;
using Kruzya.TelegramBot.Core.Service;
using Telegram.Bot.Types;
using West.TelegramBot.ContentStore.Model;
namespace West.TelegramBot.ContentStore.Service;
public class CapyApiService : IRandomMediaService
{
private readonly UserService _userService;
private const int BeaverCount = 161;
public StoreItem StoreItem { get; } = new("capybara", "Капибара", 60, 120);
public Task<RandomMedia> GetRandomMediaAsync()
public Task<RandomMedia> GetRandomMediaAsync(Chat chat, User user)
{
return Task.FromResult(new RandomMedia(new InputFileUrl($"https://api.capy.lol/v1/capybara?{new Random().Next(0, 10000)}")));
if (_userService.IsUserUnlucky(user.Id) && RandomNumberGenerator.GetInt32(2) == 1)
{
var beaverId = RandomNumberGenerator.GetInt32(BeaverCount);
return Task.FromResult(RandomMediaFromUrl($"https://westdev.me/_kurwa/{beaverId}.jpg"));
}
return Task.FromResult(RandomMediaFromUrl($"https://api.capy.lol/v1/capybara?{new Random().Next(0, 10000)}"));
}
public RandomMedia RandomMediaFromUrl(string url) => new(new InputFileUrl(url));
public CapyApiService(UserService userService)
{
_userService = userService;
}
}