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
This commit is contained in:
parent
b9a24cbab3
commit
925063e531
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import os # Used exactly once to check for the config file
|
import os # Used exactly once to check for the config file
|
||||||
import shutil # Used exactly once to copy the sample config file
|
import shutil # Used exactly once to copy the sample config file
|
||||||
|
import time
|
||||||
import asyncio
|
import asyncio
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import re
|
import re
|
||||||
|
@ -260,16 +261,23 @@ async def update_followers(c, me):
|
||||||
# in case someone followed while the bot was down or something.
|
# in case someone followed while the bot was down or something.
|
||||||
log(f'{len(to_follow)} accounts to follow:')
|
log(f'{len(to_follow)} accounts to follow:')
|
||||||
for account in 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)
|
await c.account_follow(account)
|
||||||
log(f'Followed {account}')
|
time.sleep(1)
|
||||||
else:
|
else:
|
||||||
log('No accounts to follow.')
|
log('No accounts to follow.')
|
||||||
|
|
||||||
if to_unfollow:
|
if to_unfollow:
|
||||||
log(f'{len(to_unfollow)} accounts to unfollow:')
|
log(f'{len(to_unfollow)} accounts to unfollow:')
|
||||||
for account in to_unfollow:
|
for account in to_unfollow:
|
||||||
await c.account_unfollow(account)
|
log(f'Unfollowing {account}...')
|
||||||
log(f'Unfollowed {account}')
|
await c.account_follow(account)
|
||||||
|
time.sleep(1)
|
||||||
else:
|
else:
|
||||||
log('No accounts to unfollow.')
|
log('No accounts to unfollow.')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue