Implemented follow

main
Paco Hope 2022-11-27 15:18:38 -05:00
parent a1cc9cbeb3
commit 9072be4648
1 changed files with 26 additions and 11 deletions

View File

@ -182,6 +182,21 @@ class Tooter(Mastodon):
def follow_random_local(self) -> int:
if( args.debug ):
print(f"{self.name} follow_random_local")
acctdict = self.me()
followlist = self.account_following(id=acctdict.id)
followed_people = {account.acct for account in followlist}
# This does outersection on sets. It's the set of all users we know about
# (from the users.toml file) minus ourselves and anyone we already follow
potentials = set(self.credentials) ^ {self.name} ^ followed_people
follow_target = random.choice(list(potentials))
target_dict = self.account_lookup(follow_target)
if( args.dry_run ):
print(f"{self.name} will follow {follow_target} (id: {target_dict.id})")
else:
self.account_follow(target_dict.id)
return( 0 )
def unfollow_random(self) -> int:
@ -217,19 +232,19 @@ class Tooter(Mastodon):
def random_interaction(self):
"""Choose one possible interaction according to the weights, and do it."""
interactions = {
self.reply_random_local: 4,
self.reply_random_local: 0,
self.reply_random_home: 0,
self.reply_random_public: 0,
self.reply_random_public: 0,
self.follow_random_local: 1,
self.unfollow_random: 1,
self.toot_plain_public: 1,
self.toot_tagged_public: 1,
self.toot_plain_unlisted: 1,
self.boost_random_local: 1,
self.favourite_random_local: 1,
self.favourite: 1,
self.federated_favourite: 1,
self.report_random_local: 1
self.unfollow_random: 0,
self.toot_plain_public: 0,
self.toot_tagged_public: 0,
self.toot_plain_unlisted: 0,
self.boost_random_local: 0,
self.favourite_random_local: 0,
self.favourite: 0,
self.federated_favourite: 0,
self.report_random_local: 0
}
chosen = random.choices(population=list(interactions.keys()),
weights=list(interactions.values()))[0]