Add entries to top of guestbook instead
This commit is contained in:
parent
9220022d3e
commit
7943e291fb
14
t0sig.py
14
t0sig.py
|
@ -46,7 +46,7 @@ async def new_message(event):
|
||||||
await event.reply('Message ID not found. Did the bot restart?')
|
await event.reply('Message ID not found. Did the bot restart?')
|
||||||
return
|
return
|
||||||
|
|
||||||
entry = '------------------------------------------------------------\n\n{} - {}'.format(data['date'], data['name'])
|
entry = '\n\n{} - {}'.format(data['date'], data['name'])
|
||||||
|
|
||||||
website = data['website']
|
website = data['website']
|
||||||
if website:
|
if website:
|
||||||
|
@ -59,10 +59,18 @@ async def new_message(event):
|
||||||
|
|
||||||
entry += ' (<a href="{0}" target="_blank" rel="noreferrer noopener">{0}</a>)'.format(website)
|
entry += ' (<a href="{0}" target="_blank" rel="noreferrer noopener">{0}</a>)'.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(entry)
|
||||||
|
f.write(entries)
|
||||||
|
|
||||||
await event.reply('Entry added to t0.vc/g')
|
await event.reply('Entry added to t0.vc/g')
|
||||||
logging.info('Added: {}'.format(data))
|
logging.info('Added: {}'.format(data))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user