#!/usr/bin/env ruby # Example: load last 10 posts from the popular "Science" feed and print the post text, # data and author handle to the terminal. Does not require any authentication. require 'bundler/setup' require 'minisky' require 'time' # the "Science" custom feed by @bossett.bsky.social FEED_URI = "at://did:plc:jfhpnnst6flqway4eaeqzj2a/app.bsky.feed.generator/for-science" appview = Minisky.new('api.bsky.app', nil) feed = appview.get_request('app.bsky.feed.getFeed', { feed: FEED_URI, limit: 10 }) posts = feed['feed'].map { |x| x['post'] } posts.each do |post| handle = post['author']['handle'] timestamp = Time.parse(post['record']['createdAt']).getlocal rkey = post['uri'].split('/').last link = "https://bsky.app/profile/#{handle}/post/#{rkey}" puts "@#{handle} • #{timestamp} • #{link}" puts puts post['record']['text'] puts puts "=" * 120 puts end