Skip to content

Instantly share code, notes, and snippets.

@emre

emre/unfollow.py Secret

Last active September 6, 2018 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emre/c3314a415171c91a53a68f6de575f128 to your computer and use it in GitHub Desktop.
Save emre/c3314a415171c91a53a68f6de575f128 to your computer and use it in GitHub Desktop.
Unfollow
import json
import time
from lightsteem.client import Client
from lightsteem.datastructures import Operation
def unfollow_accounts(username):
client = Client(
keys=["<posting_key>"])
account = client.account(username)
accounts = set(account.following()).difference(set(account.followers()))
print(f"{len(accounts)} accounts found.")
for account in accounts:
follow_json = json.dumps(
["follow", {
"follower": username,
"following": account,
"what": [],
}]
)
unfollow_op = Operation('custom_json', {
'required_auths': [],
'required_posting_auths': [username, ],
'id': 'follow',
'json': follow_json,
})
client.broadcast(unfollow_op)
print(f"Unfollowed {account}")
time.sleep(2)
if __name__ == '__main__':
unfollow_accounts('emrebeyler')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment