Browse Source

setting room_path back to self.output + message.room in download() and write_log()

master
manetta 10 months ago
parent
commit
ad1cb276b9
  1. 12
      LogBot/logbot.py

12
LogBot/logbot.py

@ -22,7 +22,7 @@ def del_from_db(self, message, key):
def write_log(self, message):
template = jinja2.Template(open('template.html').read())
log_path = os.path.join(self.room_path, 'index.html')
log_path = os.path.join(self.output, message.room, 'index.html')
with open(log_path,'w') as out:
html = template.render(title=self.db[message.room]['title'], db=self.db[message.room]['messages'])
out.write(html)
@ -48,7 +48,7 @@ def download(self, message):
parsed_url = urlparse(message.url)
filename = os.path.basename(parsed_url.path).replace(' ','_').replace('%20','_') # safe url's
print('as the file: ', filename)
path = os.path.join(self.room_path, media_type)
path = os.path.join(self.output, message.room media_type)
if not os.path.isdir(path):
os.mkdir(path)
file_path = os.path.join(path, filename)
@ -94,10 +94,13 @@ logbot @uptime: To check how long @logbot has been around
@bots: To see who is around :)
'''
def setup(self):
print('INFO ', f'Output folder is set to: { self.output }')
for room in self.rooms:
roomname = str(re.match(r'.*@', room).group()).replace('@','')
self.room_path = os.path.join(self.output, roomname)
print('INFO ', f'Room path is set to: { self.room_path }')
# Check if the room is in the database already
if not room in self.db.keys():
@ -113,9 +116,6 @@ logbot @uptime: To check how long @logbot has been around
print('INFO ', f'Created a folder for: { room }')
print('INFO ', f'Copied stylesheet.css to: { room }')
print('INFO ', f'Output folder is set to: { self.output }')
print('INFO ', f'Room path is set to: { self.room_path }')
def group(self, message):
# to debug in the terminal
@ -132,7 +132,7 @@ logbot @uptime: To check how long @logbot has been around
media_type = media_type.replace('images', 'image') # linguistic hack!
reply = f'Thanks for that { media_type }!'
else:
reply = 'Sorry, can\'t touch that :('
reply = 'Sorry, can\'t process that :('
elif '@add' in message.text:
add_to_db(self, message)

Loading…
Cancel
Save