Vals using @atproto/api
Description from the NPM package:
Client library for atproto and Bluesky
jonasmerlin
bluesky_bot_template
Cron
This is a very simple template for the kind of Bluesky bot I build. It's very much all over the place. e.g. it sets up the "Agent" to post (because that part is documented well), but doesn't use it to search for posts. You can do that if you want (if you do, look here ), but I like to simply rawdogg the API, so that is what I'm doing here.
The custom Post type is incomplete and only contains the stuff I found relevant.
Error handling is payed only lip service to (at best) as well. ...But it works for me! How to use If you want to use this, you will have to set 2 environment variables for your val:
BLUESKY_USERNAME
BLUESKY_PASSWORD
From what I can tell from my testing: BLUESKY_USERNAME can be both the bot account's handle as well as the email you use to log into it with. BLUESKY_PASSWORD can be both the account's main password as well as an app password. The rest is commented in the code. If you have any questions, feel free to message me on Bluesky: Jonas-Merlin Schumacher (@jonasmerlin.bsky.social) — Bluesky
2
stevekrouse
blueskySearchPostsDemo
Script
app.bsky.feed.searchPosts API Docs: https://docs.bsky.app/docs/api/app-bsky-feed-search-posts Example Response XRPCResponse {
data: {
posts: [
{
uri: "at://did:plc:uqtqvy3ydp2pcqbgr2yjppcj/app.bsky.feed.post/3lbsfypbbdk26",
cid: "bafyreiesbymbxclbatvh3slqmmrbazkupng4kcwn5tojnojvvrb3pzock4",
author: {
did: "did:plc:uqtqvy3ydp2pcqbgr2yjppcj",
handle: "kyrre.dev",
displayName: "Kyrre",
avatar: "https://cdn.bsky.app/img/avatar/plain/did:plc:uqtqvy3ydp2pcqbgr2yjppcj/bafkreiadk656yzrvkpgr5avgcab6ftmptig4slqyn3hturou3eaox5o24i@jpeg",
labels: [],
createdAt: "2023-11-26T00:05:04.154Z"
},
record: {
"$type": "app.bsky.feed.post",
createdAt: "2024-11-25T20:58:07.518Z",
facets: [Array],
langs: [Array],
reply: [Object],
text: "Cool, @val.town is awesome!"
},
replyCount: 0,
repostCount: 0,
likeCount: 2,
quoteCount: 0,
indexedAt: "2024-11-25T20:58:07.955Z",
labels: []
},
{
uri: "at://did:plc:4op2gckllrrttktwi4vg2j2p/app.bsky.feed.post/3lbs6qjce6k2c",
cid: "bafyreicx6nivr22zdpuxvnihfk3ifk3d6y37ug5e32tqzkcefmwnxsqt6a",
author: {
did: "did:plc:4op2gckllrrttktwi4vg2j2p",
handle: "gksh.dev",
displayName: "Gustavo Karkow",
avatar: "https://cdn.bsky.app/img/avatar/plain/did:plc:4op2gckllrrttktwi4vg2j2p/bafkreib5m52xjyidrsnfvyxoie7zwpusus6wzacr4k2tpobue5o7ysr3o4@jpeg",
associated: [Object],
labels: [],
createdAt: "2023-07-28T21:31:46.738Z"
},
record: {
"$type": "app.bsky.feed.post",
createdAt: "2024-11-25T18:48:16.611Z",
embed: [Object],
facets: [Array],
langs: [Array],
text: "@stevekrouse.com can't tell what happened, but I was using Townie for a thing and it inverted the reasoning and code outputs for whatever reason."
},
embed: { "$type": "app.bsky.embed.images#view", images: [Array] },
replyCount: 1,
repostCount: 0,
likeCount: 1,
quoteCount: 0,
indexedAt: "2024-11-25T18:48:19.130Z",
labels: []
},
{
uri: "at://did:plc:hkutgcisjksjzjl7j2xwjbsw/app.bsky.feed.post/3lbrrmgknxs2f",
cid: "bafyreiesuxytdmwqb27tw32r6hrmcvq6up7xffs27mxmayfjph3yvsehmi",
author: {
did: "did:plc:hkutgcisjksjzjl7j2xwjbsw",
handle: "bezbac.me",
displayName: "Ben Bachem",
avatar: "https://cdn.bsky.app/img/avatar/plain/did:plc:hkutgcisjksjzjl7j2xwjbsw/bafkreienzxwrlwwocthenmzs57xptthtvahgjbh7k4qg47mvpvx2lapdfu@jpeg",
associated: [Object],
labels: [],
createdAt: "2023-08-29T19:30:57.132Z"
},
record: {
"$type": "app.bsky.feed.post",
createdAt: "2024-11-25T14:53:20.897Z",
facets: [Array],
langs: [Array],
reply: [Object],
text: "Congrats! I’m always impressed by product and team at @val.town"
},
replyCount: 0,
repostCount: 0,
likeCount: 2,
quoteCount: 0,
indexedAt: "2024-11-25T14:53:21.757Z",
labels: []
},
{
uri: "at://did:plc:zxkg5d6y6uhrsoctq7wgwqul/app.bsky.feed.post/3lbrrjwuz422q",
cid: "bafyreic7m5lf4ta5az2hwcaa7hzka6dawadsohiqxyikmeb7ql4k3q3bwq",
author: {
did: "did:plc:zxkg5d6y6uhrsoctq7wgwqul",
handle: "just-be.dev",
displayName: "Justin",
avatar: "https://cdn.bsky.app/img/avatar/plain/did:plc:zxkg5d6y6uhrsoctq7wgwqul/bafkreidbly6rg5tzb3pnlizsxevgd3nvu42ko4r6igetudvwvp2qnbx2fa@jpeg",
labels: [],
createdAt: "2023-04-24T14:47:37.014Z"
},
record: {
"$type": "app.bsky.feed.post",
createdAt: "2024-11-25T14:51:57.352Z",
facets: [Array],
langs: [Array],
text: "Hey friends! Big news. I'm working at @val.town now!"
},
replyCount: 16,
repostCount: 4,
likeCount: 72,
quoteCount: 0,
indexedAt: "2024-11-25T14:51:57.665Z",
labels: []
},
{
uri: "at://did:plc:jfbrs3p2mytb4qh4kgzdnild/app.bsky.feed.post/3lbprmrkbo22q",
cid: "bafyreieoufjenhjflt2n4lr6k45wys7j3f6nfehs5ndkbs6g2ng2cw7al4",
author: {
did: "did:plc:jfbrs3p2mytb4qh4kgzdnild",
handle: "daniel-levine.bsky.social",
displayName: "Dan Levine",
avatar: "https://cdn.bsky.app/img/avatar/plain/did:plc:jfbrs3p2mytb4qh4kgzdnild/bafkreibjeo2eqdinlrfm6xa2mprnyyaryb3gaajrmhslx5bq2o3xx2ftby@jpeg",
labels: [],
createdAt: "2024-11-04T19:07:59.180Z"
},
record: {
"$type": "app.bsky.feed.post",
createdAt: "2024-11-24T19:48:12.943Z",
embed: [Object],
facets: [Array],
langs: [Array],
reply: [Object],
text: "💯 I want to see a ton of Val.town apps that make use of Bluesky :) cc @stevekrouse.com"
},
embed: { "$type": "app.bsky.embed.external#view", external: [Object] },
replyCount: 1,
repostCount: 0,
likeCount: 1,
quoteCount: 0,
indexedAt: "2024-11-24T19:48:16.162Z",
labels: []
}
]
},
headers: {
"access-control-allow-origin": "*",
"atproto-content-labelers": "did:plc:ar7c4by46qjdydhdevvrndac;redact",
"cache-control": "public, max-age=30",
"cdn-cache": "MISS",
"cdn-cachedat": "11/25/2024 21:38:59",
"cdn-edgestorageid": "894",
"cdn-proxyver": "1.06",
"cdn-pullzone": "1816608",
"cdn-requestcountrycode": "US",
"cdn-requestid": "a5715b0e4a5fa58d0ce748a59a8a66aa",
"cdn-requestpullcode": "200",
"cdn-requestpullsuccess": "True",
"cdn-requesttime": "0",
"cdn-status": "200",
"cdn-uid": "57ad37ea-0c96-40cb-9722-d1abe3b3ecd9",
"content-type": "application/json; charset=utf-8",
date: "Mon, 25 Nov 2024 21:38:59 GMT",
server: "BunnyCDN-IL1-1206",
"strict-transport-security": "max-age=63072000",
vary: "Accept-Encoding",
"x-powered-by": "Express"
},
success: true
}
0