From 3282fe91dd01f006b416c0057f8c59f3b1b950d9 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Sun, 17 Sep 2017 14:25:45 +0200 Subject: fixed 'add' when the username is empty --- lib/commands.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/commands.py b/lib/commands.py index 942bc0e..3df279c 100644 --- a/lib/commands.py +++ b/lib/commands.py @@ -88,8 +88,10 @@ class Commands(object): msg = ' '.join(cmd[1:]) #join first word after 'add' to last word try: - with open(co['path'], 'ab') as fout: - fout.seek(1, 1) + with open(co['path'], 'ab+') as fout: + if fout.readline().decode('utf-8') == '': + fout.write(('\n').encode('utf-8')) + fout.write((msg + '\n').encode('utf-8')) print('Ok') -- cgit v1.2.3-18-g5258