Add configuration support

This commit is contained in:
Michael De Roover 2022-02-05 11:23:14 +01:00
parent f7d4db136d
commit d8bb26ab9b
Signed by: vim
GPG Key ID: 075496E232CE04CB
2 changed files with 14 additions and 0 deletions

View File

@ -50,5 +50,18 @@ async def log(event):
f = open(chat)
await event.edit(f.read())
if msg.startswith('.tl.set'):
import json
key = msg.split()[1]
arg = msg.split()[2]
with open('/var/telelog/settings.json', 'r+') as settings:
data = json.load(settings)
data[f'{key}'] = arg
settings.seek(0)
json.dump(data, settings, indent=4)
settings.truncate()
settings.close()
await event.edit(f'Setting changed: {key} = {arg}.\n')
client.start()
client.run_until_disconnected()

View File

@ -41,6 +41,7 @@ addfiles(){
install -dm770 -o root -g telelog /var/telelog/logs
install -m640 -o root -g telelog config.py /var/telelog/config.py
install -m755 -o root -g root bin/telelog /usr/bin/telelog
echo '{}' > /var/telelog/settings.json
# Install service files on installed inits
if [ -e /sbin/openrc ]