Improve variable assignments

This commit is contained in:
Michael De Roover 2021-03-22 10:47:38 +01:00
parent da4b5aa24d
commit d16ad8e70f
Signed by: vim
GPG Key ID: 075496E232CE04CB

12
ubot.py
View File

@ -17,7 +17,7 @@ async def edit(event):
await event.edit(rpl) await event.edit(rpl)
if '.shg' in msg: if '.shg' in msg:
rpl = f"¯\_(ツ)_/¯" rpl = "¯\_(ツ)_/¯"
msg = event.text.replace('.shg', rpl) msg = event.text.replace('.shg', rpl)
await event.edit(msg) await event.edit(msg)
@ -97,17 +97,17 @@ async def edit(event):
user = os.environ['USER'] user = os.environ['USER']
out = os.popen(cmd).read() out = os.popen(cmd).read()
rpl = '`' + user + '@' + host + ' $ ' + cmd + '`\n' rpl = f'`{user}@{host}$ {cmd}`\n'
rpl += '`' + out + '`\n' rpl += f'`{out}`\n'
await event.edit(rpl) await event.edit(rpl)
if '.sys' in msg: if '.sys' in msg:
mem = os.popen('free -m').readlines()[1].split()[2] mem = os.popen('free -m').readlines()[1].split()[2]
disk = os.popen('df -h /').readlines()[1].split()[2] disk = os.popen('df -h /').readlines()[1].split()[2]
rpl = '**System usage stats:**\n' rpl = f'**System usage stats:**\n'
rpl += '**Memory:** ' + mem + 'M\n' rpl += f'**Memory:** {mem}M\n'
rpl += '**Disk:** ' + disk + '\n' rpl += f'**Disk:** {disk}\n'
await event.edit(rpl) await event.edit(rpl)
if '.sauce' in msg: if '.sauce' in msg: