Learn R Programming

slackr (version 3.3.1)

slackr_setup: Setup environment variables for Slack API access

Description

Initialize all the environment variables slackr() will need to use to work properly.

Usage

slackr_setup(
  channel = "#general",
  username = "slackr",
  icon_emoji = "",
  incoming_webhook_url = "",
  token = "",
  config_file = "~/.slackr",
  echo = FALSE,
  cache_dir = ""
)

Value

"Successfully connected to Slack"

Arguments

channel

default channel to send the output to (chr) defaults to #general.

username

the username output will appear from (chr) defaults to slackr.

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 FALSE.

cache_dir

the location for an on-disk cache. defaults to an in-memory cache if no location is specified.

Details

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 locaiton 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

See Also

slackr(), slackr_dev(), slackr_save(), slackr_upload()

Examples

Run this code
if (FALSE) {
# 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"
)
}

Run the code above in your browser using DataLab