Title: | Send Messages, Images, R Objects and Files to 'Slack' Channels/Users |
---|---|
Description: | 'Slack' <https://slack.com/> provides a service for teams to collaborate by sharing messages, images, links, files and more. Functions are provided that make it possible to interact with the 'Slack' platform 'API'. When you need to share information or data from R, rather than resort to copy/ paste in e-mails or other services like 'Skype' <https://www.skype.com/en/>, you can use this package to send well-formatted output from multiple R objects and expressions to all teammates at the same time with little effort. You can also send images from the current graphics device, R objects, and upload files. |
Authors: | Matt Kaye [aut, cre] (matthewrkaye.com), Bob Rudis [aut], Andrie de Vries [aut, ctb], Jay Jacobs [ctb], David Severski [ctb], Quinn Weber [ctb], Konrad Karczewski [ctb], Shinya Uryu [ctb], Gregory Jefferis [ctb], Ed Niles [ctb], Rick Saporta [ctb], Jonathan Sidi [aut, ctb], Xinye Li [ctb] |
Maintainer: | Matt Kaye <[email protected]> |
License: | MIT + file LICENSE |
Version: | 3.4.0 |
Built: | 2025-02-13 03:27:15 UTC |
Source: | https://github.com/mrkaye97/slackr |
Checks authentication & identity against the Slack API.
auth_test(token = Sys.getenv("SLACK_TOKEN"))
auth_test(token = Sys.getenv("SLACK_TOKEN"))
token |
Authentication token bearing required scopes. |
https://api.slack.com/methods/auth.test
if (Sys.getenv("SLACK_TOKEN") != "") { auth_test() }
if (Sys.getenv("SLACK_TOKEN") != "") { auth_test() }
A wrapper function to call the Slack API with authentication and pagination.
call_slack_api( path, ..., body = NULL, .method = c("GET", "POST"), token, .verbose = Sys.getenv("SLACKR_VERBOSE", "FALSE"), .next_cursor = "" )
call_slack_api( path, ..., body = NULL, .method = c("GET", "POST"), token, .verbose = Sys.getenv("SLACKR_VERBOSE", "FALSE"), .next_cursor = "" )
path |
The API definition path, e.g. |
... |
These arguments must be named and will be added to the API query string. |
body |
If |
.method |
Either "GET" or "POST". |
token |
Authentication token bearing required scopes. |
.verbose |
If TRUE, prints |
.next_cursor |
The value of the next cursor, when using pagination. |
The API response (a named list)
Convert Slack API json response to tibble.
convert_response_to_tibble(x, element)
convert_response_to_tibble(x, element)
x |
The Slack API response object, returned from call_slack_api. |
element |
The name of the list element to extract. |
A tibble
slackr_setup()
Create the config file used in slackr_setup()
create_config_file( filename = "~/.slackr", token = Sys.getenv("SLACK_TOKEN"), incoming_webhook_url = Sys.getenv("SLACK_INCOMING_WEBHOOK_URL"), icon_emoji = Sys.getenv("SLACK_ICON_EMOJI"), username = Sys.getenv("SLACK_USERNAME"), channel = Sys.getenv("SLACK_CHANNEL") )
create_config_file( filename = "~/.slackr", token = Sys.getenv("SLACK_TOKEN"), incoming_webhook_url = Sys.getenv("SLACK_INCOMING_WEBHOOK_URL"), icon_emoji = Sys.getenv("SLACK_ICON_EMOJI"), username = Sys.getenv("SLACK_USERNAME"), channel = Sys.getenv("SLACK_CHANNEL") )
filename |
the name of the config file to save. We recommend using a hidden file (starting with '.') |
token |
Authentication token bearing required scopes. |
incoming_webhook_url |
the incoming webhook URL (Default: whatever is set as an env var). |
icon_emoji |
the icon emoji to use as the default. |
username |
the username to send messages from (will default to "slackr" if no username is set). |
channel |
Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. See the chat.postMessage endpoint documentation for details. |
TRUE if successful (invisibly)
## Not run: # using `create_config_file()` after `slackr_setup()` create_config_file() # using `create_config_file()` before `slackr_setup()` create_config_file( token = "xox-", incoming_webhook_url = "https://hooks-", channel = "#general", username = "slackr", icon_emoji = "tada" ) slackr_setup() ## End(Not run)
## Not run: # using `create_config_file()` after `slackr_setup()` create_config_file() # using `create_config_file()` before `slackr_setup()` create_config_file( token = "xox-", incoming_webhook_url = "https://hooks-", channel = "#general", username = "slackr", icon_emoji = "tada" ) slackr_setup() ## End(Not run)
Unlike the slackr_dev()
function, this one takes a ggplot
object,
eliminating the need to have a graphics device (think use in scripts).
ggslackr( plot = ggplot2::last_plot(), channels = Sys.getenv("SLACK_CHANNEL"), token = Sys.getenv("SLACK_TOKEN"), file = "ggplot.png", initial_comment = NULL, thread_ts = NULL, title = NULL, ... )
ggslackr( plot = ggplot2::last_plot(), channels = Sys.getenv("SLACK_CHANNEL"), token = Sys.getenv("SLACK_TOKEN"), file = "ggplot.png", initial_comment = NULL, thread_ts = NULL, title = NULL, ... )
plot |
ggplot object to save, defaults to last plot displayed. |
channels |
Comma-separated list of channel names or IDs where the file will be shared. |
token |
Authentication token bearing required scopes. |
file |
Prefix for filenames (defaults to |
initial_comment |
The message text introducing the file in specified channels. |
thread_ts |
Provide another message's ts value to upload this file as a reply. Never use a reply's ts value; use its parent instead. |
title |
Title of file. |
... |
other arguments passed to ggsave |
httr
response object (invisibly)
## Not run: slackr_setup() ggslackr(qplot(mpg, wt, data = mtcars)) ## End(Not run)
## Not run: slackr_setup() ggslackr(qplot(mpg, wt, data = mtcars)) ## End(Not run)
Appends to the body of a function an on.exit call to run at the end of the call.
register_onexit( f, ..., header_msg = NULL, use_device = FALSE, env = parent.frame(2), channel = Sys.getenv("SLACK_CHANNEL"), username = Sys.getenv("SLACK_USERNAME"), icon_emoji = Sys.getenv("SLACK_ICON_EMOJI"), token = Sys.getenv("SLACK_TOKEN") )
register_onexit( f, ..., header_msg = NULL, use_device = FALSE, env = parent.frame(2), channel = Sys.getenv("SLACK_CHANNEL"), username = Sys.getenv("SLACK_USERNAME"), icon_emoji = Sys.getenv("SLACK_ICON_EMOJI"), token = Sys.getenv("SLACK_TOKEN") )
f |
function or character. |
... |
expressions to be sent to Slack. |
header_msg |
boolean, message to append to start of Slack output, Default: NULL. |
use_device |
boolean, passes current image in the graphics device to Slack as part of f, Default: FALSE. |
env |
environment to assign appended function to with relation to the function environment, Default: parent.frame(2) (global environment). |
channel |
Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. See the chat.postMessage endpoint documentation for details. |
username |
what user should the bot be named as (chr). |
icon_emoji |
what emoji to use (chr) |
token |
Authentication token bearing required scopes. |
If a character is passed to f then it will evaluate internally to a function.
function
You need a https://www.slack.com account and will also need to set up an API token https://api.slack.com/
Jonathan Sidi (aut)
## Not run: ctl <- c(4.17, 5.58, 5.18, 6.11, 4.50, 4.61, 5.17, 4.53, 5.33, 5.14) trt <- c(4.81, 4.17, 4.41, 3.59, 5.87, 3.83, 6.03, 4.89, 4.32, 4.69) group <- gl(2, 10, 20, labels = c("Ctl", "Trt")) weight <- c(ctl, trt) # pass a message to Slack channel 'general' register_onexit(lm, "bazinga!", channel = "#general") lm.D9 <- slack_lm(weight ~ group) # test that output keeps inheritance summary(lm.D9) # pass a message to Slack channel 'general' with a header message to begin output register_onexit( lm, "bazinga!", channel = "#general", header_msg = "This is a message to begin" ) lm.D9 <- slack_lm(weight ~ group) # onexit with an expression that calls lm.plot register_onexit( lm, { par(mfrow = c(2, 2), oma = c(0, 0, 2, 0)) plot(z) }, channel = "#general", header_msg = "This is a plot just for this output", use_device = TRUE ) lm.D9 <- slack_lm(weight ~ group) # clean up slack channel from examples slackr_delete(count = 6, channel = "#general") ## End(Not run)
## Not run: ctl <- c(4.17, 5.58, 5.18, 6.11, 4.50, 4.61, 5.17, 4.53, 5.33, 5.14) trt <- c(4.81, 4.17, 4.41, 3.59, 5.87, 3.83, 6.03, 4.89, 4.32, 4.69) group <- gl(2, 10, 20, labels = c("Ctl", "Trt")) weight <- c(ctl, trt) # pass a message to Slack channel 'general' register_onexit(lm, "bazinga!", channel = "#general") lm.D9 <- slack_lm(weight ~ group) # test that output keeps inheritance summary(lm.D9) # pass a message to Slack channel 'general' with a header message to begin output register_onexit( lm, "bazinga!", channel = "#general", header_msg = "This is a message to begin" ) lm.D9 <- slack_lm(weight ~ group) # onexit with an expression that calls lm.plot register_onexit( lm, { par(mfrow = c(2, 2), oma = c(0, 0, 2, 0)) plot(z) }, channel = "#general", header_msg = "This is a plot just for this output", use_device = TRUE ) lm.D9 <- slack_lm(weight ~ group) # clean up slack channel from examples slackr_delete(count = 6, channel = "#general") ## End(Not run)
Takes an expr
, evaluates it and sends the output to a Slack
chat destination. Useful for logging, messaging on long compute tasks or
general information sharing.
slackr( ..., channel = Sys.getenv("SLACK_CHANNEL"), username = Sys.getenv("SLACK_USERNAME"), icon_emoji = Sys.getenv("SLACK_ICON_EMOJI"), token = Sys.getenv("SLACK_TOKEN"), thread_ts = NULL, reply_broadcast = FALSE )
slackr( ..., channel = Sys.getenv("SLACK_CHANNEL"), username = Sys.getenv("SLACK_USERNAME"), icon_emoji = Sys.getenv("SLACK_ICON_EMOJI"), token = Sys.getenv("SLACK_TOKEN"), thread_ts = NULL, reply_broadcast = FALSE )
... |
expressions to be sent to Slack. |
channel |
Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. See the chat.postMessage endpoint documentation for details. |
username |
what user should the bot be named as (chr). |
icon_emoji |
what emoji to use (chr) |
token |
Authentication token bearing required scopes. |
thread_ts |
Provide another message's ts value to make this message a reply. Avoid using a reply's ts value; use its parent instead. |
reply_broadcast |
Used in conjunction with thread_ts and indicates whether reply should be made visible to everyone in the channel or conversation. Defaults to FALSE. |
By default, everything but expr
will be looked for in a "SLACK_
"
environment variable. You can override or just specify these values directly instead,
but it's probably better to call slackr_setup()
first.
the response (invisibly)
You need a https://www.slack.com account and will also need to set up an API token https://api.slack.com/
slackr_setup()
, slackr_bot()
, slackr_dev()
,
slackr_save()
, slackr_upload()
## Not run: slackr_setup() slackr("iris info", head(iris), str(iris)) ## End(Not run)
## Not run: slackr_setup() slackr("iris info", head(iris), str(iris)) ## End(Not run)
Takes an expr
, evaluates it and sends the output to a Slack
chat destination via the webhook API. Useful for logging, messaging on long
compute tasks or general information sharing.
slackr_bot( ..., incoming_webhook_url = Sys.getenv("SLACK_INCOMING_WEBHOOK_URL") )
slackr_bot( ..., incoming_webhook_url = Sys.getenv("SLACK_INCOMING_WEBHOOK_URL") )
... |
expressions to be sent to Slack. |
incoming_webhook_url |
which |
By default, everything but expr
will be looked for in a "SLACK_
"
environment variable. You can override or just specify these values directly
instead, but it's probably better to call slackr_setup()
first.
Webhook URLs look like:
https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX
OLD STYLE WEBHOOKS ARE NO LONGER SUPPORTED
You need a https://www.slack.com account and will also need to setup an incoming webhook: https://api.slack.com/. Old style webhooks are no longer supported.
slackr_setup()
, slackr()
,
slackr_dev()
, slackr_save()
,
slackr_upload()
## Not run: slackr_setup() slackr_bot("iris info", head(iris), str(iris)) # or directly slackr_bot( "Test message", incoming_webhook_url = "https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX" ) ## End(Not run)
## Not run: slackr_setup() slackr_bot("iris info", head(iris), str(iris)) # or directly slackr_bot( "Test message", incoming_webhook_url = "https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX" ) ## End(Not run)
Get a data frame of Slack channels
slackr_channels(token = Sys.getenv("SLACK_TOKEN"), exclude_archived = TRUE)
slackr_channels(token = Sys.getenv("SLACK_TOKEN"), exclude_archived = TRUE)
token |
Authentication token bearing required scopes. |
exclude_archived |
A boolean indicating whether or not to exclude archived channels. |
A data.frame of channels
Given a vector of one or more channel names, retrieve list of
active channels and try to replace channels that begin with "#
" or "@
"
with the channel ID for that channel.
slackr_chtrans(channels, token = Sys.getenv("SLACK_TOKEN"))
slackr_chtrans(channels, token = Sys.getenv("SLACK_TOKEN"))
channels |
Comma-separated list of channel names or IDs where the file will be shared. |
token |
Authentication token bearing required scopes. |
character vector - original channel list with #
or
@
channels replaced with ID's.
Quinn Weber (ctb), Bob Rudis (aut)
slackr_csv
simplifies the process of sending a data frame to Slack as a CSV file.
It is highly recommended to leave the filename
argument as the default (tempfile), as changing it will persist a csv file in your working directory.
slackr_csv( data, filename = tempfile(fileext = ".csv"), title = NULL, initial_comment = NULL, channels = Sys.getenv("SLACK_CHANNEL"), token = Sys.getenv("SLACK_TOKEN"), thread_ts = NULL, ... )
slackr_csv( data, filename = tempfile(fileext = ".csv"), title = NULL, initial_comment = NULL, channels = Sys.getenv("SLACK_CHANNEL"), token = Sys.getenv("SLACK_TOKEN"), thread_ts = NULL, ... )
data |
the data frame or tibble to upload. |
filename |
the file to save to. Defaults to a tempfile. Using the default is highly advised, as using a non-tempfile will write a file that persists on the disk (either in the working directory, or at the location specified). |
title |
Title of file. |
initial_comment |
The message text introducing the file in specified channels. |
channels |
Comma-separated list of channel names or IDs where the file will be shared. |
token |
Authentication token bearing required scopes. |
thread_ts |
Provide another message's ts value to upload this file as a reply. Never use a reply's ts value; use its parent instead. |
... |
additional arguments to be passed to |
httr
response object from POST
call (invisibly)
httr
response object from POST
call (invisibly)
Matt Kaye (aut)
Deletes the specified number of messages from the channel
slackr_delete( count, channel = Sys.getenv("SLACK_CHANNEL"), token = Sys.getenv("SLACK_TOKEN") )
slackr_delete( count, channel = Sys.getenv("SLACK_CHANNEL"), token = Sys.getenv("SLACK_TOKEN") )
count |
The number of messages to delete. |
channel |
Channel, private group, or IM channel to delete messages from. Can be an encoded ID, or a name. See the chat.postMessage endpoint documentation for details. |
token |
Authentication token bearing required scopes. |
slackr_dev
sends the graphics contents of the current device to the
specified Slack channel.
slackr_dev( channels = Sys.getenv("SLACK_CHANNEL"), token = Sys.getenv("SLACK_TOKEN"), file = "plot", initial_comment = NULL, title = NULL, thread_ts = NULL )
slackr_dev( channels = Sys.getenv("SLACK_CHANNEL"), token = Sys.getenv("SLACK_TOKEN"), file = "plot", initial_comment = NULL, title = NULL, thread_ts = NULL )
channels |
Comma-separated list of channel names or IDs where the file will be shared. |
token |
Authentication token bearing required scopes. |
file |
prefix for filenames (defaults to |
initial_comment |
The message text introducing the file in specified channels. |
title |
Title of file. |
thread_ts |
Provide another message's ts value to upload this file as a reply. Never use a reply's ts value; use its parent instead. |
httr
response object from POST
call
Konrad Karczewski (ctb), Bob Rudis (aut)
https://github.com/mrkaye97/slackr/pull/12/files
slackr_setup()
, slackr_save()
, slackr_upload()
## Not run: slackr_setup() # base library(maps) map("usa") slackr_dev("#results", file = "map") # base barplot(VADeaths) slackr_dev("@jayjacobs") ## End(Not run)
## Not run: slackr_setup() # base library(maps) map("usa") slackr_dev("#results", file = "map") # base barplot(VADeaths) slackr_dev("@jayjacobs") ## End(Not run)
Returns a dataframe of post history in a channel.
slackr_history( message_count = 100, channel = Sys.getenv("SLACK_CHANNEL"), token = Sys.getenv("SLACK_TOKEN"), posted_to_time = as.numeric(Sys.time()), duration = NULL, posted_from_time = 0, paginate = FALSE, inclusive = TRUE )
slackr_history( message_count = 100, channel = Sys.getenv("SLACK_CHANNEL"), token = Sys.getenv("SLACK_TOKEN"), posted_to_time = as.numeric(Sys.time()), duration = NULL, posted_from_time = 0, paginate = FALSE, inclusive = TRUE )
message_count |
The number of messages to retrieve (only when |
channel |
Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. |
token |
Authentication token bearing required scopes. |
posted_to_time |
Timestamp of the last post to consider.
Corresponds to |
duration |
Number of hours of history to retrieve. If neither |
posted_from_time |
Timestamp of the first post time to consider. If both
posted_to_time and duration is specifed, they take precedence.
Corresponds to |
paginate |
If TRUE, uses the Slack API pagination mechanism, and will retrieve all history inside the timeframe. Otherwise, makes a single call to the API and retrieves a maximum of |
inclusive |
Include messages with oldest or latest timestamps in results. Ignored unless either timestamp is specified. |
A tibble
with message metadata
You need one or more of these scopes enabled in your slack app: * channels:history * groups:history * im:history * mpim:history
https://api.slack.com/methods/conversations.history
Get a data frame of Slack IM ids
slackr_ims(token = Sys.getenv("SLACK_TOKEN"))
slackr_ims(token = Sys.getenv("SLACK_TOKEN"))
token |
Authentication token bearing required scopes. |
data.frame
of im ids and user names
Quinn Weber (aut), Bob Rudis (ctb)
https://github.com/mrkaye97/slackr/pull/13
Sends a message to a slack channel.
slackr_msg( txt = "", channel = Sys.getenv("SLACK_CHANNEL"), username = Sys.getenv("SLACK_USERNAME"), icon_emoji = Sys.getenv("SLACK_ICON_EMOJI"), token = Sys.getenv("SLACK_TOKEN"), thread_ts = NULL, reply_broadcast = FALSE, ... )
slackr_msg( txt = "", channel = Sys.getenv("SLACK_CHANNEL"), username = Sys.getenv("SLACK_USERNAME"), icon_emoji = Sys.getenv("SLACK_ICON_EMOJI"), token = Sys.getenv("SLACK_TOKEN"), thread_ts = NULL, reply_broadcast = FALSE, ... )
txt |
text message to send to Slack. If a character vector of length > 1 is passed in, they will be combined and separated by newlines. |
channel |
Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. See the chat.postMessage endpoint documentation for details. |
username |
what user should the bot be named as (chr). |
icon_emoji |
what emoji to use (chr) |
token |
Authentication token bearing required scopes. |
thread_ts |
Provide another message's ts value to make this message a reply. Avoid using a reply's ts value; use its parent instead. |
reply_broadcast |
Used in conjunction with thread_ts and indicates whether reply should be made visible to everyone in the channel or conversation. Defaults to FALSE. |
... |
other arguments passed to the Slack API |
the response (invisibly)
You need a https://www.slack.com account and will also need to
setup an API token https://api.slack.com/
Also, you can pass in add_user=TRUE
as part of the ...
parameters and the Slack API will post the message as your logged-in
user account (this will override anything set in username
)
slackr_setup()
, slackr_bot()
, slackr_dev()
,
slackr_save()
, slackr_upload()
## Not run: slackr_setup() slackr_msg("Hi") ## End(Not run)
## Not run: slackr_setup() slackr_msg("Hi") ## End(Not run)
slackr_save
enables you upload R objects (as an R data file)
to Slack and (optionally) post them to one or more channels
(if channels
is not empty).
slackr_save( ..., channels = Sys.getenv("SLACK_CHANNEL"), file = "slackr", token = Sys.getenv("SLACK_TOKEN"), initial_comment = NULL, title = NULL, thread_ts = NULL )
slackr_save( ..., channels = Sys.getenv("SLACK_CHANNEL"), file = "slackr", token = Sys.getenv("SLACK_TOKEN"), initial_comment = NULL, title = NULL, thread_ts = NULL )
... |
objects to store in the R data file. |
channels |
Comma-separated list of channel names or IDs where the file will be shared. |
file |
filename (without extension) to use. |
token |
Authentication token bearing required scopes. |
initial_comment |
The message text introducing the file in specified channels. |
title |
Title of file. |
thread_ts |
Provide another message's ts value to upload this file as a reply. Never use a reply's ts value; use its parent instead. |
httr
response object from POST
call
slackr_setup()
, slackr_dev()
, slackr_upload()
## Not run: slackr_setup() slackr_save(mtcars, channels = "#slackr", file = "mtcars") ## End(Not run)
## Not run: slackr_setup() slackr_save(mtcars, channels = "#slackr", file = "mtcars") ## End(Not run)
Initialize all the environment variables slackr()
will need to use to
work properly.
slackr_setup( channel = "#general", username = "slackr", icon_emoji = "", incoming_webhook_url = "", token = "", config_file = Sys.getenv("SLACKR_CONFIG_FILE_PATH", unset = "~/.slackr"), echo = FALSE, cache_dir = "" )
slackr_setup( channel = "#general", username = "slackr", icon_emoji = "", incoming_webhook_url = "", token = "", config_file = Sys.getenv("SLACKR_CONFIG_FILE_PATH", unset = "~/.slackr"), echo = FALSE, cache_dir = "" )
channel |
default channel to send the output to (chr) defaults to |
username |
the username output will appear from (chr) defaults to |
icon_emoji |
which emoji picture to use (chr) defaults to none (can be left blank in config file as well). |
incoming_webhook_url |
the Slack URL prefix to use (chr) defaults to none. |
token |
Authentication token bearing required scopes. |
config_file |
a configuration file (DCF) - see read.dcf - format with the config values. |
echo |
display the configuration variables (bool) initially |
cache_dir |
the location for an on-disk cache. defaults to an in-memory cache if no location is specified. |
By default, slackr()
(and other functions) will use the #general
room and a username of slackr()
with no emoji.
If a valid file is found at the location pointed to by config_file
, the
values there will be used. The fields should be specified as such in the file:
token: SLACK_TOKEN channel: #general username: slackr incoming_webhook_url: https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX
"Successfully connected to Slack"
You need a Slack account and all your API URLs & tokens setup to use this package.
slackr()
, slackr_dev()
, slackr_save()
,
slackr_upload()
## Not run: # reads from default file (i.e. ~/.slackr) slackr_setup() # reads from alternate config slackr_setup(config_file = "/path/to/my/slackrconfig") # the hard way slackr_setup( channel = "#code", incoming_webhook_url = "https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX" ) ## End(Not run)
## Not run: # reads from default file (i.e. ~/.slackr) slackr_setup() # reads from alternate config slackr_setup(config_file = "/path/to/my/slackrconfig") # the hard way slackr_setup( channel = "#code", incoming_webhook_url = "https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX" ) ## End(Not run)
slackr_setup()
Unset env vars created by slackr_setup()
slackr_teardown()
slackr_teardown()
TRUE if successful (invisibly)
## Not run: slackr_teardown() ## End(Not run)
## Not run: slackr_teardown() ## End(Not run)
Unlike the slackr_dev()
function, this one takes a tex
object,
eliminating the need write to pdf and convert to png to pass to slack.
slackr_tex( obj, channels = Sys.getenv("SLACK_CHANNEL"), token = Sys.getenv("SLACK_TOKEN"), ext = "png", path = NULL, title = NULL, initial_comment = NULL, thread_ts = NULL, ... )
slackr_tex( obj, channels = Sys.getenv("SLACK_CHANNEL"), token = Sys.getenv("SLACK_TOKEN"), ext = "png", path = NULL, title = NULL, initial_comment = NULL, thread_ts = NULL, ... )
obj |
character object containing tex to compile. |
channels |
Comma-separated list of channel names or IDs where the file will be shared. |
token |
Authentication token bearing required scopes. |
ext |
character, type of format to return, can be tex, pdf, or any image device, Default: 'png'. |
path |
character, path to save tex_preview outputs, if NULL then tempdir is used, Default: NULL. |
title |
Title of file. |
initial_comment |
The message text introducing the file in specified channels. |
thread_ts |
Provide another message's ts value to upload this file as a reply. Never use a reply's ts value; use its parent instead. |
... |
other arguments passed to |
Please make sure texPreview
package is installed before running this function.
For TeX setup refer to the
Setup notes on LaTeX
.
httr
response object (invisibly)
You need to setup a full API token (i.e. not a webhook & not OAuth) for this to work
Also, you can pass in add_user=TRUE
as part of the ...
parameters and the Slack API will post the message as your logged-in user
account (this will override anything set in username
)
Jonathan Sidi (aut)
slackr_upload
enables you upload files to Slack and
(optionally) post them to one or more channels (if channels
is not empty).
slackr_upload( filename, title = NULL, initial_comment = NULL, channels = Sys.getenv("SLACK_CHANNEL"), token = Sys.getenv("SLACK_TOKEN"), thread_ts = NULL )
slackr_upload( filename, title = NULL, initial_comment = NULL, channels = Sys.getenv("SLACK_CHANNEL"), token = Sys.getenv("SLACK_TOKEN"), thread_ts = NULL )
filename |
path to file. |
title |
Title of file. |
initial_comment |
The message text introducing the file in specified channels. |
channels |
Comma-separated list of channel names or IDs where the file will be shared. |
token |
Authentication token bearing required scopes. |
thread_ts |
Provide another message's ts value to upload this file as a reply. Never use a reply's ts value; use its parent instead. |
httr
response object from POST
call (invisibly)
httr
response object from POST
call (invisibly)
Quinn Weber (ctb), Bob Rudis (aut)
https://github.com/mrkaye97/slackr/pull/15/files
slackr_setup()
, slackr_dev()
, slackr_save()
Get a data frame of Slack users
slackr_users(token = Sys.getenv("SLACK_TOKEN"))
slackr_users(token = Sys.getenv("SLACK_TOKEN"))
token |
Authentication token bearing required scopes. |
data.frame
of users
Check for token-parameter mismatches
warn_for_args(token, ...)
warn_for_args(token, ...)
token |
Authentication token bearing required scopes. |
... |
Additiional arguments passed to the function called. |
No return value. Called for side effects
This loops over fun
, extracts the next_cursor
from the API response, and
injects this into the next loop. At the completion of each loop, the function convert_response_to_tibble()
is run with extract
as and argument. The results are combined with dplyr::bind_rows()
with_pagination(fun, extract)
with_pagination(fun, extract)
fun |
A function that calls the slack API. |
extract |
The name of the element to extract from the API response. |
A tibble
call_slack_api