From 329ef7561eb70e9aa57474e4bf8d1c3bfb3b88b4 Mon Sep 17 00:00:00 2001 From: NatrixAeria Date: Sun, 18 Oct 2020 21:39:42 +0200 Subject: Add a tutor list --- bot.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'bot.py') diff --git a/bot.py b/bot.py index ad2f95b..61c7aeb 100644 --- a/bot.py +++ b/bot.py @@ -19,6 +19,18 @@ class Cupido(commands.Bot): self.task = None self.reaction_map = {} self.vote_map = {} + self.read_file() + + def read_file(self): + try: + with open(config.TUTOR_FILE_PATH, 'r') as f: + self.tutors = {int(line) for line in f.read().split('\n')} + except FileNotFoundError: + self.tutors = set() + + def write_file(self): + with open(config.TUTOR_FILE_PATH, 'w') as f: + f.write('\n'.join(str(t) for t in self.tutors)) async def await_coroutine(self, co): if self.task is not None: @@ -160,6 +172,14 @@ class Cupido(commands.Bot): selected=vote)[0] return await message.edit(embed=embeds[0]) + def add_tutor(self, tutor): + self.tutors.add(tutor) + self.write_file() + + def remove_tutor(self, tutor): + self.tutors.remove(tutor) + self.write_file() + def main(): token = getenv(config.TOKEN_ENV_VAR) -- cgit v1.2.3-54-g00ecf