mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
[entertainment] use thread safe random, update /roll number range
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using BotFramework;
|
||||
using Castle.Core.Internal;
|
||||
using Kruzya.TelegramBot.Core;
|
||||
using Kruzya.TelegramBot.Core.Data;
|
||||
using Kruzya.TelegramBot.Core.Extensions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -18,8 +19,9 @@ namespace West.Entertainment.Handler.Fun
|
||||
private readonly CoreContext _db;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly ThreadSafeRandom _rng;
|
||||
|
||||
protected virtual TimeSpan Cooldown => TimeSpan.FromMinutes(new Random().Next(10, 1337));
|
||||
protected virtual TimeSpan Cooldown => TimeSpan.FromMinutes(_rng.Next(10, 1337));
|
||||
|
||||
protected Message? Message => RawUpdate.Message;
|
||||
|
||||
@@ -30,10 +32,11 @@ namespace West.Entertainment.Handler.Fun
|
||||
get;
|
||||
}
|
||||
|
||||
protected AbstractAnimationReply(CoreContext db, ILogger logger)
|
||||
protected AbstractAnimationReply(CoreContext db, ILogger logger, ThreadSafeRandom rng)
|
||||
{
|
||||
_db = db;
|
||||
_logger = logger;
|
||||
_rng = rng;
|
||||
}
|
||||
|
||||
protected abstract string GetAnimationName();
|
||||
|
||||
Reference in New Issue
Block a user