From 925063e53156e4c0157346f7f535f133608786dd Mon Sep 17 00:00:00 2001 From: Holly Date: Mon, 16 Dec 2024 00:30:15 +0000 Subject: [PATCH] Fix API issues with automated following - Don't try to follow accounts that have migrated away (This should be a softblock?) - Wait a second between follows/unfollows so as to not so easily trip the rate limit --- mtgcardlookup.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mtgcardlookup.py b/mtgcardlookup.py index a11270c..239a6d5 100755 --- a/mtgcardlookup.py +++ b/mtgcardlookup.py @@ -2,6 +2,7 @@ import os # Used exactly once to check for the config file import shutil # Used exactly once to copy the sample config file +import time import asyncio import aiohttp import re @@ -260,16 +261,23 @@ async def update_followers(c, me): # in case someone followed while the bot was down or something. log(f'{len(to_follow)} accounts to follow:') for account in to_follow: + log(f'Following {account}...') + account_dict = await c.get(f'/api/v1/accounts/{account}') + moved_to = account_dict.get('moved') + if moved_to: + log('Account has moved, skipping...') + continue await c.account_follow(account) - log(f'Followed {account}') + time.sleep(1) else: log('No accounts to follow.') if to_unfollow: log(f'{len(to_unfollow)} accounts to unfollow:') for account in to_unfollow: - await c.account_unfollow(account) - log(f'Unfollowed {account}') + log(f'Unfollowing {account}...') + await c.account_follow(account) + time.sleep(1) else: log('No accounts to unfollow.')