mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
feat(store): code cleanup, make some fund with "unlucky" members
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user