Rework message builder to format from text file.

This commit is contained in:
2023-07-01 23:10:48 -04:00
parent cb6530ff57
commit abd9be6341
5 changed files with 63 additions and 64 deletions
+37
View File
@@ -0,0 +1,37 @@
"""
Contains the MessageBuilder class.
"""
from datetime import datetime
from config import DakinyConfig
from utils import get_datetime
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
"""
with open("bot_messages/vote_start.txt", mode="r", encoding="utf8") as file:
message = file.read()
vote_end: datetime = get_datetime(self.config.election_cycles[self.cycle].voting_end)
return message.format(
clan_member_id=self.config.params.clan_member_role_id,
voting_emote_id=self.config.params.voting_emote_id,
voting_end_date=vote_end.strftime("%B %d"),
voting_end_day=vote_end.strftime("%A"),
)