From 175598a2af6b2fda040dfb6f83abd2697b34bfcf Mon Sep 17 00:00:00 2001 From: Someone Date: Mon, 10 Jan 2022 18:13:06 +0100 Subject: [PATCH] modules/CommandCoronaPresenceLogger.py --- modules/CommandCoronaPresenceLogger.py | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/CommandCoronaPresenceLogger.py b/modules/CommandCoronaPresenceLogger.py index 947591a..4fbf3cf 100644 --- a/modules/CommandCoronaPresenceLogger.py +++ b/modules/CommandCoronaPresenceLogger.py @@ -49,8 +49,8 @@ class CommandCoronaPresenceLogger(AbstractCommand): elif re.match(r"^(-|—|–)+", data['text']): filename = self.datadir + datetime.date.today().isoformat()+"--"+data["user_id"] - with open(filename, "a") as f: - f.write(data["user_name"]+" -- "+datetime.datetime.now().isoformat()+"\n") + with open(filename, "a") as file: + file.write(data["user_name"]+" -- "+datetime.datetime.now().isoformat()+"\n") request.respond_cmd_temp(cleandoc(""" ## :white_check_mark: Success! :) #### ``Your presence at FSINF today has been logged.`` @@ -69,17 +69,17 @@ class CommandCoronaPresenceLogger(AbstractCommand): # racecondition if called in the same channel too fast. nonissue? def _upload_meme(self, request, data): - post_cnt = 0 - for p in self.bot.api.get_posts_for_channel(data["channel_id"]): - post_cnt += 1 - if post_cnt > 20: - break - - if "cpl-meme-upload-todo" in p["props"] and p["props"]["cpl-meme-upload-todo"] == "todo": - client = Client(self.dav_options) - file_list = client.list() - del file_list[0] - client.download_file(random.choice(file_list), '/tmp/cpl-meme.png') - - self.bot.api.create_post(p["channel_id"], '``AUTODELETE-DAY`` **``CPL, OIDA!``**', props={"from_webhook":"true"}, filepaths=['/tmp/cpl-meme.png'], root_id=p["root_id"]) - self.bot.api.delete_post(p["id"]) + post_cnt = 0 + for post in self.bot.api.get_posts_for_channel(data["channel_id"]): + post_cnt += 1 + if post_cnt > 20: + break + + if "cpl-meme-upload-todo" in post["props"] and post["props"]["cpl-meme-upload-todo"] == "todo": + client = Client(self.dav_options) + file_list = client.list() + del file_list[0] + client.download_file(random.choice(file_list), '/tmp/cpl-meme.png') + + self.bot.api.create_post(post["channel_id"], '``AUTODELETE-DAY`` **``CPL, OIDA!``**', props={"from_webhook":"true"}, filepaths=['/tmp/cpl-meme.png'], root_id=post["root_id"]) + self.bot.api.delete_post(post["id"]) -- 2.43.0