mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
31 lines
1.1 KiB
C#
31 lines
1.1 KiB
C#
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(Chat chat, User user)
|
|
{
|
|
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;
|
|
}
|
|
} |