From 729b322a598921ef0d5d54e540187a289ccb8a67 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Thu, 30 Mar 2023 02:35:48 +0200 Subject: [PATCH] chatlogs --- .gitignore | 1 + matrix_pygmalion_bot/core.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index d6e6602..94e6881 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ bot.conf .store images/ +chatlogs/ runpod-test* # Byte-compiled / optimized / DLL files diff --git a/matrix_pygmalion_bot/core.py b/matrix_pygmalion_bot/core.py index bea3aa1..77dacee 100644 --- a/matrix_pygmalion_bot/core.py +++ b/matrix_pygmalion_bot/core.py @@ -64,6 +64,9 @@ class Callbacks(object): room.display_name, room.user_name(event.sender), event.body ) ) + os.makedirs("./chatlogs", exist_ok=True) + with open("chatlogs/" + self.bot.name + "_" + room.display_name + ".txt", "a") as f: + f.write("{}: {}\n".format(room.user_name(event.sender), event.body)) await self.client.room_read_markers(room.room_id, event_id, event_id) # Ignore messages from ourselves if is_own_message: