maybe a fork of sparrowhe's "bluesky circle" webapp, to frontend only?
1from PIL import Image, ImageOps, ImageDraw 2import numpy as np 3import math 4import requests 5from io import BytesIO 6from atproto import Client 7 8def parse_friends(client: Client, handle: str) -> dict: 9 friends = dict() 10 def update_data(friendData): 11 did = friendData.pop('did') 12 if did in friends: 13 friends[did]['reply_score'] += friendData['reply_score'] 14 else: 15 friends[did] = friendData 16 # Get profile's posts. Use pagination (cursor + limit) to fetch all 17 profile_feed = client.get_author_feed(actor=handle) 18 for feed_view in profile_feed.feed: 19 if feed_view.post.record.reply != None: 20 reply_parent = feed_view.post.record.reply.parent 21 reply_parent_author = client.get_post_thread(reply_parent.uri).thread.post.author 22 if reply_parent_author.handle == handle: 23 continue 24 friendData = { 25 'did': reply_parent_author.did, 26 'avatar': reply_parent_author.avatar, 27 'display_name': reply_parent_author.display_name, 28 'reply_score': 1, 29 } 30 update_data(friendData) 31 elif feed_view.post.author.handle == handle: 32 replies = client.get_post_thread(feed_view.post.uri).thread.replies 33 for reply in replies: 34 if reply.post.author.handle == handle: 35 continue 36 friendData = { 37 'did': reply.post.author.did, 38 'avatar': reply.post.author.avatar, 39 'display_name': reply.post.author.display_name, 40 'reply_score': 1.5, 41 } 42 update_data(friendData) 43 44 return friends