""" Contains the MessageBuilder class. """ from datetime import datetime from config import DakinyConfig class MessageBuilder: """ Contains all the announcements that the bot will send regarding elections. """ def __init__(self, config: DakinyConfig, cycle: int) -> None: self.config = config self.cycle = cycle def get_vote_start(self) -> str: """ Builds the voting start message out of template and configurations. Returns: str: Message to send """ vote_end = self.get_datetime(self.config.election_cycles[self.cycle].voting_end) message = "====================\n" message += f"<@&{self.config.params.clan_member_role_id}>, it's time to vote for clan council.\n\n" message += f"React with <:{self.config.params.voting_emote_id}> to vote. " message += f"Voting ends next Wednesday , {vote_end.date()}." message += f"Announcement of the results to whole clan will happen {vote_end.date()}.\n\n" message += "After a candidate receives 3 votes, their spot is secured in the new council, " message += "but you can still vote for them to show your support.\n\n" message += "**Just a reminder:** only the people listed below are eligible to vote, and each " message += "clan member may **only vote for one person**. Votes from guests, diplomats, or allies " message += "will be annulled.\nVotes for multiple candidates from the same person will not be counted. \n\n" message += "RS3 Clan Members\n" message += "OSRS Clan Members" return message def get_datetime(self, day: str) -> datetime: """ Takes in a string month and day and returns a datetime object of that Month/Day this year. Args: day (str): Month/Day in that format. Returns: datetime: Datetime representation of Month/Day. """ today = datetime.today() month = int(day.split("/")[0]) day = int(day.split("/")[1]) return datetime(today.year, month, day)