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