diff --git a/docker/matrix-eavesdrop/src/eavesdrop/bot.py b/docker/matrix-eavesdrop/src/eavesdrop/bot.py index 2e7622d1a4..01e7a16e85 100644 --- a/docker/matrix-eavesdrop/src/eavesdrop/bot.py +++ b/docker/matrix-eavesdrop/src/eavesdrop/bot.py @@ -94,6 +94,12 @@ class Bot: data = json.load(f) return data + def get_room_path(self, room): + room_path = room['path'] + if not room_path.startswith('/'): + room_path = os.path.join(self.config['log_dir'], room_path) + return room_path + async def join_rooms(self): new = set() old = set() @@ -107,7 +113,7 @@ class Bot: # Store the canonical room id, since the one in the config # file may be an alias self.room_map[resp.room_id] = room - os.makedirs(room['path'], exist_ok=True) + os.makedirs(self.get_room_path(room), exist_ok=True) for room in old-new: self.log.info("Leave room %s", room['id']) await self.client.room_leave(room) @@ -120,9 +126,7 @@ class Bot: ts = datetime.datetime.utcfromtimestamp(event.server_timestamp/1000.0) event_date = str(ts.date()) event_time = str(ts.time())[:8] - room_path = config_room['path'] - if not room_path.startswith('/'): - room_path = os.path.join(self.config['log_dir'], room_path) + room_path = self.get_room_path(config_room) filename = f'{room_name}.{event_date}.log' logpath = os.path.join(room_path, filename) body = event.body