Use federation list for followers

master
Bob Mottram 2019-06-29 21:34:41 +01:00
parent 0765d21b24
commit c2983c5217
3 changed files with 17 additions and 15 deletions

View File

@ -36,7 +36,7 @@ maxMessageLength=5000
maxPostsInFeed=20
# number of follows/followers per page
followsPerPage=2
followsPerPage=12
# Whether to use https
useHttps=True

View File

@ -31,7 +31,7 @@ from follow import followerOfPerson
from follow import unfollowPerson
from follow import unfollowerOfPerson
federationList=['mastodon.social']
federationList=['mastodon.social','wild.com','trees.com']
username='testuser'
#domain=socket.gethostname()
domain='mydomain.com'
@ -41,18 +41,18 @@ useTor=False
session = createSession(useTor)
clearFollows(username,domain)
followPerson(username,domain,'badger','wild.com')
followPerson(username,domain,'squirrel','secret.com')
followPerson(username,domain,'rodent','drainpipe.com')
followPerson(username,domain,'batman','mesh.com')
followPerson(username,domain,'giraffe','trees.com')
followPerson(username,domain,'badger','wild.com',federationList)
followPerson(username,domain,'squirrel','secret.com',federationList)
followPerson(username,domain,'rodent','drainpipe.com',federationList)
followPerson(username,domain,'batman','mesh.com',federationList)
followPerson(username,domain,'giraffe','trees.com',federationList)
clearFollowers(username,domain)
followerOfPerson(username,domain,'badger','wild.com')
followerOfPerson(username,domain,'squirrel','secret.com')
followerOfPerson(username,domain,'rodent','drainpipe.com')
followerOfPerson(username,domain,'batman','mesh.com')
followerOfPerson(username,domain,'giraffe','trees.com')
followerOfPerson(username,domain,'badger','wild.com',federationList)
followerOfPerson(username,domain,'squirrel','secret.com',federationList)
followerOfPerson(username,domain,'rodent','drainpipe.com',federationList)
followerOfPerson(username,domain,'batman','mesh.com',federationList)
followerOfPerson(username,domain,'giraffe','trees.com',federationList)
#unfollowPerson(username,domain,'squirrel','secret.com')
#sys.exit()

View File

@ -12,9 +12,11 @@ import os
import sys
from person import validUsername
def followPerson(username: str, domain: str, followUsername: str, followDomain: str, followFile='following.txt') -> None:
def followPerson(username: str, domain: str, followUsername: str, followDomain: str, federationList, followFile='following.txt') -> None:
"""Adds a person to the follow list
"""
if followDomain.lower().replace('\n','') not in federationList:
return
handle=username.lower()+'@'+domain.lower()
handleToFollow=followUsername.lower()+'@'+followDomain.lower()
baseDir=os.getcwd()
@ -30,8 +32,8 @@ def followPerson(username: str, domain: str, followUsername: str, followDomain:
with open(filename, "w") as followfile:
followfile.write(handleToFollow+'\n')
def followerOfPerson(username: str, domain: str, followerUsername: str, followerDomain: str) -> None:
followPerson(username, domain, followerUsername, followerDomain,'followers.txt')
def followerOfPerson(username: str, domain: str, followerUsername: str, followerDomain: str, federationList) -> None:
followPerson(username, domain, followerUsername, followerDomain, federationList, 'followers.txt')
def unfollowPerson(username: str, domain: str, followUsername: str, followDomain: str,followFile='following.txt') -> None:
"""Removes a person to the follow list