Hide actual cooldown value
This commit is contained in:
parent
d97bdfafce
commit
34ba1d9443
1 changed files with 8 additions and 9 deletions
|
@ -4,19 +4,18 @@ using System.Collections.Generic;
|
||||||
namespace Noikoio.RegexBot.Module.VoteTempChannel
|
namespace Noikoio.RegexBot.Module.VoteTempChannel
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Keeps information on voting sessions and voting cooldowns.
|
/// Keeps information on voting sessions and cooldowns.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class VotingSession
|
class VotingSession
|
||||||
{
|
{
|
||||||
private Configuration _conf;
|
private Configuration _conf;
|
||||||
private DateTimeOffset _initialVoteTime;
|
private DateTimeOffset _initialVoteTime;
|
||||||
private List<ulong> _votes;
|
private List<ulong> _votes;
|
||||||
|
public DateTimeOffset? _cooldownStart;
|
||||||
public DateTimeOffset? CooldownStart { get; private set; }
|
|
||||||
|
|
||||||
public VotingSession()
|
public VotingSession()
|
||||||
{
|
{
|
||||||
CooldownStart = null;
|
_cooldownStart = null;
|
||||||
_votes = new List<ulong>();
|
_votes = new List<ulong>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +34,7 @@ namespace Noikoio.RegexBot.Module.VoteTempChannel
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if the voting session has expired.
|
/// Checks if the voting session has expired.
|
||||||
/// To be called by the background task. This automatically resets state.
|
/// To be called by the background task. This automatically resets and sets cooldown.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsSessionExpired()
|
public bool IsSessionExpired()
|
||||||
{
|
{
|
||||||
|
@ -52,13 +51,13 @@ namespace Noikoio.RegexBot.Module.VoteTempChannel
|
||||||
|
|
||||||
public void StartCooldown()
|
public void StartCooldown()
|
||||||
{
|
{
|
||||||
CooldownStart = DateTimeOffset.UtcNow;
|
_cooldownStart = DateTimeOffset.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsInCooldown()
|
public bool IsInCooldown()
|
||||||
{
|
{
|
||||||
if (!CooldownStart.HasValue) return false;
|
if (!_cooldownStart.HasValue) return false;
|
||||||
return CooldownStart.Value + _conf.VotingCooldown > DateTimeOffset.UtcNow;
|
return _cooldownStart.Value + _conf.VotingCooldown > DateTimeOffset.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -67,7 +66,7 @@ namespace Noikoio.RegexBot.Module.VoteTempChannel
|
||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
_votes.Clear();
|
_votes.Clear();
|
||||||
CooldownStart = null;
|
_cooldownStart = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue