Unfollow rather than changing following handle

main
Bob Mottram 2021-01-09 17:41:41 +00:00
parent 579aa7f63d
commit 118da84fa6
1 changed files with 18 additions and 28 deletions

View File

@ -120,36 +120,26 @@ def _updateMovedHandle(baseDir: str, nickname: str, domain: str,
return ctr return ctr
with open(followingFilename, "r") as f: with open(followingFilename, "r") as f:
followingHandles = f.readlines() followingHandles = f.readlines()
movedToHandle = movedToNickname + '@' + movedToDomainFull movedToHandle = movedToNickname + '@' + movedToDomainFull
movedToHandleLower = movedToHandle.lower()
handleLower = handle.lower() handleLower = handle.lower()
# does the new handle already exist in the following list?
alreadyFollowingHandle = False # unfollow the old handle
for followHandle in followingHandles: with open(followingFilename, 'w+') as f:
if followHandle.strip("\n").strip("\r").lower() == \ for followHandle in followingHandles:
movedToHandleLower: if followHandle.strip("\n").strip("\r").lower() != \
alreadyFollowingHandle = True handleLower:
if not alreadyFollowingHandle: f.write(followHandle)
# replace the old handle with the new one else:
with open(followingFilename, 'w+') as f: handleNickname = handle.split('@')[0]
for followHandle in followingHandles: handleDomain = handle.split('@')[1]
if followHandle.strip("\n").strip("\r").lower() != \ unfollowAccount(baseDir, nickname, domain,
handleLower: handleNickname,
f.write(followHandle) handleDomain,
else: followFile, debug)
f.write(movedToHandleLower + '\n') ctr += 1
ctr += 1 print('Unfollowed ' + handle + ' who has moved to ' +
print('Follow moved from ' + handleLower + movedToHandle)
' to ' + movedToHandleLower)
else:
# remove the old handle
with open(followingFilename, 'w+') as f:
for followHandle in followingHandles:
if followHandle.strip("\n").strip("\r").lower() != \
handleLower:
f.write(followHandle)
else:
ctr += 1
return ctr return ctr