···
244
+
# Post AtProto status updates
247
+
local prompt_message=true
248
+
local account1_name=""
249
+
local account2_name=""
250
+
local account1_jwt=""
251
+
local account2_jwt=""
253
+
# Load account information from agenix secrets
254
+
if [[ -f "/run/agenix/bluesky" ]]; then
255
+
source "/run/agenix/bluesky"
257
+
echo "Error: Bluesky credentials file not found at /run/agenix/bluesky"
262
+
while [[ $# -gt 0 ]]; do
266
+
prompt_message=false
270
+
echo "Usage: now [-m|--message \"your message\"]"
276
+
# Prompt for message if none provided
277
+
if [[ "$prompt_message" = true ]]; then
278
+
echo -n "$ACCOUNT1 is: "
281
+
if [[ -z "$message" ]]; then
282
+
echo "No message provided. Aborting."
287
+
# Generate JWT for ACCOUNT1
288
+
local account1_response=$(curl -s -X POST \
289
+
-H "Content-Type: application/json" \
291
+
"identifier": "'$ACCOUNT1'",
292
+
"password": "'$ACCOUNT1_PASSWORD'"
294
+
"https://bsky.social/xrpc/com.atproto.server.createSession")
296
+
account1_jwt=$(echo "$account1_response" | jq -r '.accessJwt')
298
+
if [[ -z "$account1_jwt" || "$account1_jwt" == "null" ]]; then
299
+
echo "Failed to authenticate account $ACCOUNT1"
300
+
echo "Response: $account1_response"
304
+
# Generate JWT for ACCOUNT2
305
+
local account2_response=$(curl -s -X POST \
306
+
-H "Content-Type: application/json" \
308
+
"identifier": "'$ACCOUNT2'",
309
+
"password": "'$ACCOUNT2_PASSWORD'"
311
+
"https://bsky.social/xrpc/com.atproto.server.createSession")
313
+
account2_jwt=$(echo "$account2_response" | jq -r '.accessJwt')
315
+
if [[ -z "$account2_jwt" || "$account2_jwt" == "null" ]]; then
316
+
echo "Failed to authenticate account $ACCOUNT2"
317
+
echo "Response: $account2_response"
321
+
# Post to ACCOUNT1 as a.status.updates
322
+
local account1_post_response=$(curl -s -X POST \
323
+
-H "Content-Type: application/json" \
324
+
-H "Authorization: Bearer $account1_jwt" \
326
+
"collection": "a.status.update",
327
+
"repo": "'$ACCOUNT1'",
329
+
"$type": "a.status.update",
330
+
"text": "'"$message"'",
331
+
"createdAt": "'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'"
334
+
"https://bsky.social/xrpc/com.atproto.repo.createRecord")
336
+
if [[ $(echo "$account1_post_response" | jq -r 'has("error")') == "true" ]]; then
337
+
echo "Error posting to $ACCOUNT1:"
338
+
echo "$account1_post_response" | jq
342
+
# Post to ACCOUNT2 as normal post
343
+
local account2_post_response=$(curl -s -X POST \
344
+
-H "Content-Type: application/json" \
345
+
-H "Authorization: Bearer $account2_jwt" \
347
+
"collection": "app.bsky.feed.post",
348
+
"repo": "'$ACCOUNT2'",
350
+
"$type": "app.bsky.feed.post",
351
+
"text": "'"$message"'",
352
+
"createdAt": "'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'"
355
+
"https://bsky.social/xrpc/com.atproto.repo.createRecord")
357
+
if [[ $(echo "$account2_post_response" | jq -r 'has("error")') == "true" ]]; then
358
+
echo "Error posting to $ACCOUNT2:"
359
+
echo "$account2_post_response" | jq
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle ':completion:*' list-colors "''${(s.:.)LS_COLORS}"
zstyle ':completion:*' menu no