Skip to content

Commit ae418ce

Browse files
committed
Add Sister slack message template
1 parent 5edb528 commit ae418ce

File tree

6 files changed

+69
-24
lines changed

6 files changed

+69
-24
lines changed

‎DESCRIPTION‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ LazyData: true
1414
Roxygen: list(markdown = TRUE)
1515
RoxygenNote: 7.3.2
1616
Imports:
17+
cli,
18+
clipr,
1719
dplyr,
1820
gh,
1921
glue,

‎R/coworking.R‎

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ cw_times <- function(details) {
196196
#' schedule).
197197
#'
198198
#' @param date Character/Date. Date of the coworking event (local)
199-
#' @param who_masto Character. The full mastodon handle for the cohost (i.e. [email protected])
200-
#' @param who_slack Character. The full Slack handle for the cohost (i.e. @XXXX)
201-
#' @param who_linkedin Character. The full LinkedIn handle for the cohost (i.e. @XXXX)
199+
#' @param who_masto Character. The full mastodon handle for the cohost (i.e. `[email protected]`)
200+
#' @param who_slack Character. The full API Slack id for the cohost (i.e. `<@UXXXXXXX>`)
201+
#' @param who_linkedin Character. The full LinkedIn handle for the cohost (i.e. `@XXXX`)
202202
#' @param who_main_masto Character. The full mastodon handle for the rOpenSci staff organizer.
203203
#' @param who_main_slack Character. The Slack id for the rOpenSci staff
204204
#' organizer (i.e., `<@UXXXXXXX>`. Defaults to Steffi's id.
@@ -250,7 +250,9 @@ cw_socials <- function(date, who_masto, who_slack, who_linkedin,
250250
yaml_end = purrr::map_dbl(.data$content, \(x) stringr::str_which(x, "---")[2]),
251251
yaml = purrr::map2(.data$content, .data$yaml_end, \(x, y) x[1:y] |> paste0(collapse = "\n")))
252252

253-
tz <- stringr::str_extract(event$content[[1]], "(America/Vancouver)|(Europe/Paris)|(Australia/Perth)") |>
253+
tz <- stringr::str_extract(
254+
event$content[[1]],
255+
"(America/Vancouver)|(Europe/Paris)|(Australia/Perth)") |>
254256
stats::na.omit()
255257

256258
if(!tz %in% OlsonNames()) stop("Couldn't detect timezone", call. = FALSE)
@@ -365,27 +367,42 @@ cw_slack_week <- function(x, posters_tz, dry_run = FALSE) {
365367

366368
time_post <- x |>
367369
dplyr::mutate(
368-
time_post = .data$date_local - lubridate::weeks(1),
370+
time_post = .data$date_local - lubridate::weeks(2),
369371
time_post = lubridate::with_tz(.data$time_post, .env$posters_tz)) |>
370372
dplyr::pull(time_post)
371373

372374
body <- x |>
373375
glue::glue_data(
374-
#"[SLACK WEEK BEFORE: #general & #co-working]",
375-
#"[POST AT: {time_post}]",
376-
#"\n",
377376
"Join us for Social Coworking and office hours next week!",
378377
"",
379378
":grey_exclamation: Theme: {theme}",
380379
":hourglass_flowing_sand: When: {time}",
381380
":cookie: Hosted by: {who_main_slack} and community host {who_slack}",
381+
":mag: Details: {event_url}",
382+
"",
383+
"You can use this time for...",
384+
"- General coworking",
385+
"{action1}",
386+
"- Chat with {who_slack} and other attendees about our theme!",
387+
"",
388+
.sep = "\n") |>
389+
fmt_slack()
390+
391+
# Use linkedin (i.e. Full names)
392+
body_sister <- x |>
393+
glue::glue_data(
394+
"Join us for Social Coworking and office hours next week!",
395+
"",
396+
":grey_exclamation: Theme: {theme}",
397+
":hourglass_flowing_sand: When: {time}",
398+
":cookie: Hosted by: @{who_main_linkedin} and community host @{who_linkedin}",
399+
":mag: Details: {event_url}",
382400
"",
383401
"You can use this time for...",
384402
"- General coworking",
385403
"{action1}",
386-
"- Chat with {who_slack} and others about our theme!",
404+
"- Chat with @{who_linkedin} and other attendees about our theme!",
387405
"",
388-
"{event_url}",
389406
.sep = "\n") |>
390407
fmt_slack()
391408

@@ -395,14 +412,18 @@ cw_slack_week <- function(x, posters_tz, dry_run = FALSE) {
395412
slack_posts_write(body, when = time_post, tz = posters_tz, channel = "#general")
396413
slack_posts_write(body, when = time_post, tz = posters_tz, channel = "#co-working")
397414
}
415+
416+
clipr::write_clip(body_sister)
417+
cli::cli_alert_success("Copied Sister-Slack messages to clipboard")
418+
cli::cli_alert_info(paste0("Post on ", time_post))
419+
cli::cli_code(body_sister)
398420
}
399421

400422
fmt_slack <- function(body) {
401423
stringr::str_replace_all(
402424
body, "\\[(.+)\\]\\((.+)\\)", "<\\2|\\1>")
403425
}
404426

405-
406427
#' Schedule 1-hour before messages on rOpenSci Slack
407428
#'
408429
#' Will only work if running between the time that the 1-week message was posted

‎R/slack.R‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
#' Title
1+
#' Write Slack message
2+
#'
3+
#' Write a Slack message for posting now or later.
24
#'
35
#' See https://docs.slack.dev/messaging/formatting-message-text#special-mentions
46
#' https://docs.slack.dev/messaging/formatting-message-text#mentioning-users
57
#'
6-
#' @param body
7-
#' @param when
8-
#' @param where
9-
#' @param dry_run
8+
#' @param body Character. Text of message to post.
9+
#' @param when Character or Date/time. When to post message.
10+
#' @param where Character. Channel to post message to.
11+
#' @param dry_run Logical. Test run?
1012
#'
11-
#' @returns
13+
#' @returns Success message
1214
#' @export
1315
#'
1416
#' @references

‎man/cw_socials.Rd‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎man/promoutils-package.Rd‎

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎man/slack_posts_write.Rd‎

Lines changed: 14 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)