Browse Source

added an instruction on how to delete a file from the log when you send a media file (with the number in the message)

master
manetta 3 years ago
parent
commit
6d7009d81c
  1. 6
      LogBot/logbot.py

6
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?)"

Loading…
Cancel
Save