Skip to content

Instantly share code, notes, and snippets.

@temujin9
Created June 26, 2024 06:29
Show Gist options
  • Save temujin9/0ea205a772e3d08aac0c0895843f4ac6 to your computer and use it in GitHub Desktop.
Save temujin9/0ea205a772e3d08aac0c0895843f4ac6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import atproto
from session import client
at_client = client.login()
cursor = None
count = 0
while True:
result = at_client.app.bsky.graph.block.list(at_client.me.did, cursor=cursor, limit=100)
for uri,block in result.records.items():
at_client.app.bsky.graph.block.delete(at_client.me.did, atproto.AtUri.from_str(uri).rkey)
print(f"unblocked https://bsky.app/profile/{block.subject}")
count += 1
if not result.cursor: break
cursor = result.cursor
print(f"All {count} direct blocks unblocked")
import atproto
username = 'your_username_here'
app_password = 'your_app_password_here'
session_file = '/tmp/bsky_python_session'
def login():
try:
client = atproto.Client()
with open(session_file, "r") as f: client.login(session_string=f.read())
except:
client = atproto.Client() # reset session
client.login(username, app_password)
with open(session_file, "w") as f: f.write(client.export_session_string())
return client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment