-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunner-bsky.R
More file actions
50 lines (40 loc) · 1.24 KB
/
runner-bsky.R
File metadata and controls
50 lines (40 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Do the common tasks.
source("runner-shared.R", local = TRUE)
# Skeet.
source("helpers-bsky.R", local = TRUE)
bsky_msg_start <- stringr::str_replace(
status_msg_start,
"https://DSLC.io welcomes you",
"@dslc.io welcomes you"
)
bsky_msg <- paste(bsky_msg_start, status_msg_end, sep = "\n")
if (
length(article_msg) && bsky_nchar(article_msg) + bsky_nchar(bsky_msg) < 300
) {
bsky_msg_start <- paste(bsky_msg_start, article_msg, sep = "\n")
bsky_msg <- paste(bsky_msg_start, status_msg_end, sep = "\n")
}
bsky_credit <- stringr::str_replace(
metadata$credit$bluesky,
"https://bsky.app/profile/",
"@"
)
credit <- glue::glue("Curator: {bsky_credit}")
bskyr::set_bluesky_user("jonthegeek.com")
bskyr::set_bluesky_pass(Sys.getenv("BSKY_APP_PASS"))
bskyr::bs_auth(bskyr::get_bluesky_user(), bskyr::get_bluesky_pass(), NULL)
if (length(img_paths) > 4) {
img_paths <- setdiff(img_paths, img_paths[[2]])
alt_text <- setdiff(alt_text, alt_text[[2]])
img_paths <- img_paths[1:4]
alt_text <- alt_text[1:4]
}
result <- tt_skeet(bsky_msg, img_paths, alt_text)
attr(result, "week") <- lubridate::week(lubridate::now())
saveRDS(result, "bsky_result.rds")
if (length(credit) && nchar(credit)) {
bskyr::bs_post(
credit,
reply = result$uri
)
}