AI agent skills related to using social media
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Implement most of timeline reading script

None of the agentic markdown tags for running follow-up scripts are included yet, but this at least gets most of the content out there.

+74 -3
+74 -3
bluesky/read-timeline.rkt
··· 1 1 #lang racket/base 2 2 3 3 4 - (require social-skills/atproto/xrpc) 4 + (require racket/list 5 + racket/match 6 + racket/string 7 + social-skills/atproto/xrpc) 5 8 6 9 7 10 (module+ main ··· 13 16 14 17 15 18 (define (read-timeline) 16 - (define timeline (agent-xrpc-get "app.bsky.feed.getTimeline" (hash 'limit 5))) 19 + (define timeline (agent-xrpc-get "app.bsky.feed.getTimeline" (hash 'limit 20))) 17 20 (define feed (hash-ref timeline 'feed)) 18 21 (for ([feed-item (in-list feed)]) 19 22 (define post (hash-ref feed-item 'post)) ··· 24 27 (if author-display-name 25 28 (format "~a (@~a)" author-display-name author-handle) 26 29 (format "@~a" author-handle))) 27 - (printf "~a\n\n ~a\n\n\n" author-tag (hash-ref (hash-ref post 'record) 'text)))) 30 + (define post-author-line (format "╔══ Post from ~a\n" author-tag)) 31 + (define reason (hash-ref feed-item 'reason #false)) 32 + (define reason-line 33 + (cond 34 + [(not reason) ""] 35 + [(equal? (hash-ref reason '$type) "app.bsky.feed.defs#reasonRepost") 36 + (define reposter (hash-ref reason 'by)) 37 + (define reposter-handle (hash-ref reposter 'handle)) 38 + (define reposter-display-name (hash-ref reposter 'displayName #false)) 39 + (if reposter-display-name 40 + (format "║ Reposted by ~a\n" reposter-display-name) 41 + (format "║ Reposted by @~a\n" reposter-handle))] 42 + [(equal? (hash-ref reason '$type) "app.bsky.feed.defs#reasonPin") "║ [Pinned]\n"] 43 + [else ""])) 44 + (define timestamp-line (format "║ ~a\n" (hash-ref post 'indexedAt))) 45 + (define post-text (hash-ref (hash-ref post 'record) 'text)) 46 + (define post-text-block 47 + (if (equal? post-text "") 48 + "" 49 + (string-append (string-map-lines post-text (λ (line) (string-append "║ " line))) "\n"))) 50 + (define embedded-content-line (if (hash-has-key? post 'embed) "║ (embedded content)\n" "")) 51 + (define reply-count (hash-ref post 'replyCount)) 52 + (define reply-count-line 53 + (format "║ ~a ~a\n" reply-count (pluralize reply-count "reply" "replies"))) 54 + (define repost-count (hash-ref post 'repostCount)) 55 + (define repost-count-line 56 + (format "║ ~a ~a\n" repost-count (pluralize repost-count "repost" "reposts"))) 57 + (define like-count (hash-ref post 'likeCount)) 58 + (define like-count-line (format "║ ~a ~a\n" like-count (pluralize like-count "like" "likes"))) 59 + (define spacing-line "║\n") 60 + (define uri-line (format "║ ~a\n" (hash-ref post 'uri))) 61 + (define ending-line "╚\n") 62 + (display post-author-line) 63 + (display reason-line) 64 + (display timestamp-line) 65 + (display spacing-line) 66 + (display post-text-block) 67 + (display embedded-content-line) 68 + (display spacing-line) 69 + (display reply-count-line) 70 + (display repost-count-line) 71 + (display like-count-line) 72 + (display spacing-line) 73 + (display uri-line) 74 + (display ending-line) 75 + (newline))) 76 + 77 + 78 + (define (pluralize n singular-form plural-form) 79 + (if (equal? n 1) singular-form plural-form)) 80 + 81 + 82 + (define (string-map-lines str f 83 + #:first-line [g f] 84 + #:last-line [h f] 85 + #:only-line [k f] 86 + #:no-lines [no-lines ""]) 87 + (define lines (string-split str "\n" #:trim? #false)) 88 + (define updated-lines 89 + (match lines 90 + [(list) (list)] 91 + [(list only) (list (k only))] 92 + [(list first middle ... last) 93 + (append (list (g first)) 94 + (map f middle) 95 + (list (h last)))])) 96 + (if (empty? updated-lines) 97 + no-lines 98 + (string-join updated-lines "\n"))) 28 99 29 100 30 101 (module+ main