74 lines
2.5 KiB
Python
74 lines
2.5 KiB
Python
"""
|
|
Contains the election cycle class
|
|
"""
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
from nextcord.ext import commands
|
|
|
|
|
|
class ElectionCycle:
|
|
"""
|
|
This class represents all the dates required for an election cycle along with all the functions needed to operate
|
|
the cycle.
|
|
"""
|
|
|
|
def __init__(self, election_start: datetime, term_start: datetime, term_end: datetime, bot) -> None:
|
|
"""
|
|
Generates all dates relevant to the election cycle from input election start, term start and end dates.
|
|
|
|
Args:
|
|
election_start (datetime): Date the election cycle starts.
|
|
term_start (datetime): Date the term being elected starts.
|
|
term_end (datetime): Date the term being elected ends.
|
|
bot: the discord bot instance
|
|
"""
|
|
self._election_start: datetime = election_start
|
|
self._term_start: datetime = term_start
|
|
self._term_end: datetime = term_end # might not be needed
|
|
self._voting_start: datetime = self._election_start + timedelta(days=7)
|
|
self._voting_end: datetime = self._voting_start + timedelta(days=7)
|
|
self._highcouncil_election: datetime = self._voting_end + timedelta(days=1)
|
|
self._bot: commands.Bot = bot
|
|
|
|
def check_date(self) -> None:
|
|
"""
|
|
Function checks current date to see if something needs to be run.
|
|
"""
|
|
today = datetime.today()
|
|
|
|
# check all dates if action is needed
|
|
match today.date():
|
|
case self._election_start.date():
|
|
self.election_start_action()
|
|
case self._voting_start.date():
|
|
self.voting_end_action()
|
|
case self._voting_end.date():
|
|
self.voting_end_action()
|
|
case self._highcouncil_election.date():
|
|
self.highcouncil_election_action()
|
|
|
|
def election_start_action(self) -> None:
|
|
"""
|
|
Performs required actions for when the election cycle starts.
|
|
"""
|
|
print("election cycle has started")
|
|
|
|
def voting_start_action(self) -> None:
|
|
"""
|
|
Performs required actions for when voting for candidates starts.
|
|
"""
|
|
print("Voting has started")
|
|
|
|
def voting_end_action(self) -> None:
|
|
"""
|
|
Performs required actions for when voting time has ended.
|
|
"""
|
|
print("voting has ended")
|
|
|
|
def highcouncil_election_action(self) -> None:
|
|
"""
|
|
Performs required actions for when the highcouncil is elected.
|
|
"""
|
|
print("Highcouncil election has started.")
|