Unfollow option

master
Bob Mottram 2019-07-17 13:25:02 +01:00
parent fa454aca2b
commit 5ca47b5dc6
1 changed files with 41 additions and 9 deletions

View File

@ -79,6 +79,8 @@ parser.add_argument('-n','--nickname', dest='nickname', type=str,default=None, \
help='Nickname of the account to use')
parser.add_argument('--fol','--follow', dest='follow', type=str,default=None, \
help='Handle of account to follow. eg. nickname@domain')
parser.add_argument('--unfol','--unfollow', dest='unfollow', type=str,default=None, \
help='Handle of account stop following. eg. nickname@domain')
parser.add_argument('-d','--domain', dest='domain', type=str,default=None, \
help='Domain name of the server')
parser.add_argument('-p','--port', dest='port', type=int,default=None, \
@ -364,6 +366,9 @@ if args.announce:
if args.follow:
# follow via c2s protocol
if '.' not in args.follow:
print("This doesn't look like a fediverse handle")
sys.exit()
if not nickname:
print('Please specify the nickname for the account with --nickname')
sys.exit()
@ -371,14 +376,6 @@ if args.follow:
print('Please specify the password for '+nickname+' on '+domain)
sys.exit()
if not os.path.isdir(baseDir+'/accounts/'+nickname+'@'+domain):
print(nickname+' is not an account on the system. use --addaccount if necessary.')
sys.exit()
if '.' not in args.follow:
print("This doesn't look like a fediverse handle")
sys.exit()
followNickname=getNicknameFromActor(args.follow)
followDomain,followPort=getDomainFromActor(args.follow)
@ -398,8 +395,43 @@ if args.follow:
for t in range(20):
time.sleep(1)
# TODO some method to know if it worked
print('Ok')
sys.exit()
if args.unfollow:
# unfollow via c2s protocol
if '.' not in args.follow:
print("This doesn't look like a fediverse handle")
sys.exit()
if not nickname:
print('Please specify the nickname for the account with --nickname')
sys.exit()
if not args.password:
print('Please specify the password for '+nickname+' on '+domain)
sys.exit()
followNickname=getNicknameFromActor(args.unfollow)
followDomain,followPort=getDomainFromActor(args.unfollow)
session = createSession(domain,port,useTor)
personCache={}
cachedWebfingers={}
followHttpPrefix=httpPrefix
if args.follow.startswith('https'):
followHttpPrefix='https'
sendUnfollowRequestViaServer(session,nickname,args.password, \
domain,port, \
followNickname,followDomain,followPort, \
httpPrefix, \
cachedWebfingers,personCache, \
debug)
for t in range(20):
time.sleep(1)
# TODO some method to know if it worked
print('Ok')
sys.exit()
nickname='admin'
if args.domain:
domain=args.domain