forked from varia/bots
parent
86c8495e88
commit
d41e4b80bd
@ -129,28 +129,37 @@ logbot @uptime: To check how long @logbot has been around
|
|||||||
@bots: To see who is around :)
|
@bots: To see who is around :)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def _parse_room_name(self, room):
|
||||||
|
"""Parse room name from entire address string."""
|
||||||
|
return str(re.match(r".*@", room).group()).replace("@", "")
|
||||||
|
|
||||||
|
def _setup_room(self, room):
|
||||||
|
"""Create directories and database entries for a new room."""
|
||||||
|
room_name = self._parse_room_name(room)
|
||||||
|
room_path = os.path.join(self.output, room_name)
|
||||||
|
self.log.info(f"Processing setup logic for: {room_path}")
|
||||||
|
|
||||||
|
if room not in self.db.keys():
|
||||||
|
self.db[room] = {}
|
||||||
|
self.db[room]["messages"] = {}
|
||||||
|
self.db[room]["title"] = room
|
||||||
|
self.log.info(f"Added to the database: { room }")
|
||||||
|
|
||||||
|
if not os.path.exists(room_path):
|
||||||
|
os.mkdir(room_path)
|
||||||
|
shutil.copy("stylesheet.css", room_path)
|
||||||
|
self.log.info(f"Created a folder for: { room }")
|
||||||
|
self.log.info(f"Copied stylesheet.css to: { room }")
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.log.info(f"Output folder is set to: { self.output }")
|
self.log.info(f"Output folder is set to: { self.output }")
|
||||||
|
|
||||||
for room in self.rooms:
|
for room in self.rooms:
|
||||||
|
self._setup_room(room)
|
||||||
|
|
||||||
roomname = str(re.match(r".*@", room).group()).replace("@", "")
|
def group_invite(self, message):
|
||||||
room_path = os.path.join(self.output, roomname)
|
"""Extend xbotlib invite response logic and do required room setup."""
|
||||||
self.log.info(f"Processing setup logic for: {room_path}")
|
super().group_invite(message)
|
||||||
|
self._setup_room(message.room)
|
||||||
# Check if the room is in the database already
|
|
||||||
if not room in self.db.keys():
|
|
||||||
self.db[room] = {}
|
|
||||||
self.db[room]["messages"] = {}
|
|
||||||
self.db[room]["title"] = room
|
|
||||||
self.log.info(f"Added to the database: { room }")
|
|
||||||
|
|
||||||
# Check if the room has an output folder already
|
|
||||||
if not os.path.exists(room_path):
|
|
||||||
os.mkdir(room_path)
|
|
||||||
shutil.copy("stylesheet.css", room_path)
|
|
||||||
self.log.info(f"Created a folder for: { room }")
|
|
||||||
self.log.info(f"Copied stylesheet.css to: { room }")
|
|
||||||
|
|
||||||
def group(self, message):
|
def group(self, message):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user