Created
April 25, 2017 12:11
-
-
Save clayote/09058e43fc46624c0a84a4ef5ccb0aa6 to your computer and use it in GitHub Desktop.
JUSTFUCKINGFOLLOW.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mastodon import Mastodon | |
from collections import deque | |
import os.path | |
instance = 'cybre.space' | |
email = 'my_login_email@example.com' | |
password = 'incrediblygoodpassword' | |
if not os.path.isfile('pytooter_clientcred.txt') or not os.path.isfile('pytooter_usercred.txt'): | |
Mastodon.create_app( | |
'JUSTFUCKINGFOLLOW', | |
api_base_url = 'https://{}'.format(instance), | |
to_file = 'pytooter_clientcred.txt' | |
) | |
mastodon = Mastodon(api_base_url = 'https://{}'.format(instance), client_id = 'pytooter_clientcred.txt') | |
mastodon.log_in( | |
email, | |
password, | |
to_file = 'pytooter_usercred.txt' | |
) | |
mastodon = Mastodon( | |
api_base_url = 'https://{}'.format(instance), | |
client_id = 'pytooter_clientcred.txt', | |
access_token = 'pytooter_usercred.txt' | |
) | |
with open('following_accounts.csv') as file: | |
accounts = deque(file.readlines()) | |
n=0 | |
while accounts: | |
acc = accounts.popleft() | |
for r in mastodon.account_search(q=acc): | |
this = '{} {}'.format(acc, r) | |
try: | |
result = mastodon.account_follow(id=r['id']) | |
except: | |
print(this) | |
accounts.append(acc) | |
continue | |
try: | |
if result['following']==True: | |
n+=1 | |
else: | |
print(this) | |
accounts.append(acc) | |
except: | |
print(this) | |
accounts.append(acc) | |
print('followed {n}'.format(n)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment