diff --git a/t0sig.py b/t0sig.py index e224f89..ae56685 100644 --- a/t0sig.py +++ b/t0sig.py @@ -46,7 +46,7 @@ async def new_message(event): await event.reply('Message ID not found. Did the bot restart?') return - entry = '------------------------------------------------------------\n\n{} - {}'.format(data['date'], data['name']) + entry = '\n\n{} - {}'.format(data['date'], data['name']) website = data['website'] if website: @@ -59,10 +59,18 @@ async def new_message(event): entry += ' ({0})'.format(website) - entry += '\n\n{}\n\n'.format(data['message']) + entry += '\n\n{}\n\n------------------------------------------------------------'.format(data['message']) - with open('data/g/index.html', 'a') as f: + with open('data/g/index.html', 'r') as f: + page = f.read() + + with open('data/g/index.html', 'w') as f: + header, entries = page.split('===========', maxsplit=1) + + f.write(header) + f.write('===========') f.write(entry) + f.write(entries) await event.reply('Entry added to t0.vc/g') logging.info('Added: {}'.format(data))