From 6d7009d81cfaffd52bebfd712de1ebf30fe82ea9 Mon Sep 17 00:00:00 2001 From: manetta Date: Fri, 18 Feb 2022 15:04:22 +0100 Subject: [PATCH] added an instruction on how to delete a file from the log when you send a media file (with the number in the message) --- LogBot/logbot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/LogBot/logbot.py b/LogBot/logbot.py index 7355dc1..51f4a07 100644 --- a/LogBot/logbot.py +++ b/LogBot/logbot.py @@ -148,6 +148,8 @@ class Logbot(Bot): self.db[message.room]["messages"][new_key]['date'] = date self.db._dumps() + return new_key + def _parse_room_name(self, room): """Parse room name from full MUC address string.""" return str(re.match(r".*@", room).group()).replace("@", "") @@ -209,11 +211,11 @@ class Logbot(Bot): media_post, media_type, media_mime, media_path, media_size = self._download(message) # TODO: Insert a list of accepted file types here. if media_post: - self._add_to_db(message, media_post=media_post, media_type=media_mime, media_url=media_path, media_size=media_size) + num = self._add_to_db(message, media_post=media_post, media_type=media_mime, media_url=media_path, media_size=media_size) media_type = media_type.replace("images", "image") # linguistic hack! if 'pdf' in message.url: media_type = 'PDF' # linguistic hack! - reply = f"Thanks for that { media_type }!" + reply = f"Thanks for that { media_type }! If you want to remove it from the log, you can send 'logbot @delete { num }'" else: reply = "Sorry, can't process that :( (unknown media type?)"