From 5cd03902349427b9c6da7d0f389ac0eaf310a2c8 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 20 Jul 2019 15:01:07 +0100 Subject: [PATCH] Approve and deny handles --- epicyon.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/epicyon.py b/epicyon.py index 172d8e21..f1bba835 100644 --- a/epicyon.py +++ b/epicyon.py @@ -331,6 +331,9 @@ if args.approve: if not args.nickname: print('Specify a nickname with the --nickname option') sys.exit() + if '@' not in args.approve: + print('syntax: --approve nick@domain') + sys.exit() handle=args.nickname+'@'+domain accountsDir=baseDir+'/accounts/'+handle approveFollowsFilename=accountDir+'/followrequests.txt' @@ -338,7 +341,7 @@ if args.approve: with open(approveFollowsFilename+'.new', 'w') as approvefilenew: with open(approveFollowsFilename, 'r') as approvefile: for approveHandle in approvefile: - if approveHandle.startswith(handle): + if approveHandle.startswith(args.approve): if ':' in approveHandle: port=int(approveHandle.split(':')[1].replace('\n','')) # TODO approve follow for handle/port @@ -351,6 +354,9 @@ if args.deny: if not args.nickname: print('Specify a nickname with the --nickname option') sys.exit() + if '@' not in args.deny: + print('syntax: --deny nick@domain') + sys.exit() handle=args.nickname+'@'+domain accountsDir=baseDir+'/accounts/'+handle approveFollowsFilename=accountDir+'/followrequests.txt' @@ -358,10 +364,10 @@ if args.deny: with open(approveFollowsFilename+'.new', 'w') as approvefilenew: with open(approveFollowsFilename, 'r') as approvefile: for approveHandle in approvefile: - if not approveHandle.startswith(handle): + if not approveHandle.startswith(args.deny): approvefilenew.write(approveHandle) os.rename(approveFollowsFilename+'.new',approveFollowsFilename) - print('Follow request from '+handle+' was denied.') + print('Follow request from '+args.deny+' was denied.') sys.exit() if args.followerspending: