Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
082ef34
commit 040479f
Showing
40 changed files
with
1,558 additions
and
739 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
Package: slackr | ||
Type: Package | ||
Title: Send messages, images, R objects and files to Slack.com | ||
channels/users | ||
Version: 1.2 | ||
Date: 2014-09-08 | ||
Author: Bob Rudis (@hrbrmstr) & Jay Jacobs (@jayjacobs) | ||
Title: Send Messages, Images, R Objects and Files to 'Slack' | ||
Channels/Users | ||
Version: 1.4.1 | ||
Date: 2016-04-26 | ||
Author: Bob Rudis [aut, cre], Jay Jacobs [ctb], David Severski [ctb], | ||
Quinn Weber [ctb], Konrad Karczewski [ctb], Shinya Uryu [ctb], | ||
Gregory Jefferis [ctb], Ed Niles [ctb], Rick Saporta [ctb] | ||
Maintainer: Bob Rudis <bob@rudis.net> | ||
Description: Slackr contains functions that make it possible to | ||
interact with Slack.com messaging platform. When you need to share | ||
information/data from R, rather than resort to copy/paste in e-mails | ||
or other services like Skype, 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 (as RData), | ||
and upload files. | ||
Description: 'Slack' <http://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' <http://www.skype.com/>, 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 (as RData), and upload | ||
files. | ||
URL: http://github.com/hrbrmstr/slackr | ||
BugReports: https://github.com/hrbrmstr/slackr/issues | ||
License: MIT + file LICENSE | ||
Suggests: testthat | ||
Depends: R (>= 3.0.0), httr (>= 0.4.0), jsonlite, data.table (>= | ||
1.9.2), ggplot2 | ||
Packaged: 2014-09-08 11:02:54 UTC; bob | ||
Depends: R (>= 3.0.0) | ||
Imports: httr (>= 0.4.0), jsonlite, ggplot2, utils, methods, dplyr, | ||
graphics, grDevices | ||
RoxygenNote: 5.0.1 | ||
NeedsCompilation: no | ||
Packaged: 2016-04-26 22:00:50 UTC; brudis | ||
Repository: CRAN | ||
Date/Publication: 2014-09-08 13:31:26 | ||
Date/Publication: 2016-04-27 13:31:09 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,34 @@ | ||
fef8d8b51f364eddf143bad9d3b3f60f *DESCRIPTION | ||
4e18b0d8fdb0da393e1c935abdd012f2 *DESCRIPTION | ||
f9e4075add143e1c252d1e4db73539ae *LICENSE | ||
d3e581a2e114234c8da9039aadf61a09 *NAMESPACE | ||
02b30b6132e22ea5c5e52ee820047885 *R/slackr-package.R | ||
7e694dfebe3f356c6379b61dc3eea284 *R/slackr.R | ||
58992a783bc4073ec78f9b64137b6b76 *man/dev.slackr.Rd | ||
6e77df2d3c2a13f93d498afdbaac9676 *man/ggslackr.Rd | ||
f8032be0f7858b0e11bca4f0cf39c576 *man/save.slackr.Rd | ||
18a9eb8c289136343e195a3ea1409524 *man/slackr-package.Rd | ||
5716a17cb78c7b114c48185a442bf011 *man/slackr.Rd | ||
7f6f270e7a0f4c3db131c84832d9f232 *man/slackrBot.Rd | ||
8857d4952a1d21082ef6112b785ef8d4 *man/slackrChTrans.Rd | ||
94d6a8890ae522188172bd2a4a13f620 *man/slackrChannels.Rd | ||
c4026775597da46232251ee7e0c17548 *man/slackrGroups.Rd | ||
f093e736c2f7fef34db36489ffd46316 *man/slackrSetup.Rd | ||
7e53861901a4cfb64a4fa23bde3c32cb *man/slackrUpload.Rd | ||
30e14394737005d547b36f21666f0ed8 *man/slackrUsers.Rd | ||
e6eeca69e76e9ee98468cf8b395b0cba *NAMESPACE | ||
0c39a9fcfe20ac0b39e6c470e77d915b *NEWS | ||
54c547f00353e6a7cef1186e7b502118 *R/dev_slackr.R | ||
209ede075ee0a7de8a3e5d195301d569 *R/gg_slackr.R | ||
1a37aa44b648951506253399be0fd244 *R/save_slackr.R | ||
bd5a3bc2f5cb971c7273e1a1228c6166 *R/slackr-package.R | ||
7d40024f0689f05ef570b20db1950a84 *R/slackr.R | ||
113f83579ab61ec2320720cce2de82fa *R/slackr_bot.r | ||
611e6441d96bb594532631866c8e80ab *R/slackr_setup.r | ||
ca034113c824f36061740c6f2c54add4 *R/slackr_upload.R | ||
530c0da41ae4c4ecf07b369a4ed2cb3d *R/slackr_utils.R | ||
10e2455ea05a41548e543730bdf9a33e *R/text_slackr.r | ||
4703021416c0046bf4c51800145bab98 *R/zcamels.r | ||
18379754819090c6b357b43da606aa05 *README.md | ||
8b66aec20e8d1a0f2137b62a050ad69c *man/dev_slackr.Rd | ||
7b8ebeb2699383035e66cee4c2b29aef *man/ggslackr.Rd | ||
7a841c4cee2a2a1cb5545764ed778be0 *man/save_slackr.Rd | ||
ba8d7b518394b760db0dd3df2ba8888c *man/slackr-package.Rd | ||
54c9ebbfc32f6155df13e3c62dd9e9c9 *man/slackr.Rd | ||
565c444aca4e9b7abdb3abd7f972bbd7 *man/slackr_bot.Rd | ||
cfe1c3dc84a5ecda9f0bc3f8e11a1c0d *man/slackr_channels.Rd | ||
efd55e6a0844e9b138b66e99731ccffa *man/slackr_chtrans.Rd | ||
932d89f7fd39a8b7fedc8101d4b73dc3 *man/slackr_groups.Rd | ||
ffd2f335e2730af94193efc30c4bb298 *man/slackr_ims.Rd | ||
bf2815655f7722a2833279f9852a072f *man/slackr_msg.Rd | ||
29851c443cfbd16c7d827c7c4befa340 *man/slackr_setup.Rd | ||
78e840d767cbae3fc75e9bb31c56f506 *man/slackr_upload.Rd | ||
19d667ed1109467e71f1e1814a1c122a *man/slackr_users.Rd | ||
0a894fff9759890ffd7ea4e82daf35d4 *man/text_slackr.Rd | ||
eb66fd4a4ae63b00f49b70a1a7e91978 *tests/test-all.R | ||
ad09493096650ca0f03340c67afdaf8d *tests/testthat/test-slackr.R | ||
f9e956145ff0e40709fae1fe7e2ae8a5 *tests/testthat/test-textslackr.R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,41 @@ | ||
# Generated by roxygen2 (4.0.1.99): do not edit by hand | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(dev.slackr) | ||
export(dev_slackr) | ||
export(ggslackr) | ||
export(save.slackr) | ||
export(save_slackr) | ||
export(slackr) | ||
export(slackrBot) | ||
export(slackrChTrans) | ||
export(slackrChannels) | ||
export(slackrChtrans) | ||
export(slackrGroups) | ||
export(slackrIms) | ||
export(slackrMsg) | ||
export(slackrSetup) | ||
export(slackrUpload) | ||
export(slackrUsers) | ||
import(data.table) | ||
export(slackr_bot) | ||
export(slackr_channels) | ||
export(slackr_chtrans) | ||
export(slackr_groups) | ||
export(slackr_ims) | ||
export(slackr_msg) | ||
export(slackr_setup) | ||
export(slackr_upload) | ||
export(slackr_users) | ||
export(textSlackr) | ||
export(text_slackr) | ||
import(ggplot2) | ||
import(httr) | ||
import(jsonlite) | ||
import(methods) | ||
import(utils) | ||
importFrom(dplyr,bind_rows) | ||
importFrom(dplyr,data_frame) | ||
importFrom(dplyr,left_join) | ||
importFrom(grDevices,dev.copy) | ||
importFrom(grDevices,dev.off) | ||
importFrom(grDevices,png) | ||
importFrom(graphics,par) | ||
importFrom(jsonlite,toJSON) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## 1.4.1 | ||
* There is a new `slackr_msg()` function which behaves slightly differently than `text_slackr()` | ||
* Versions 1.4+ BREAK THINGS. | ||
* Support has been removed for the "old style" incoming web hooks (see "Setup" in the README for the required incoming web hook URL format). | ||
* the incoming webhook "token" is no longer required or used. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#' Send the graphics contents of the current device to a Slack channel | ||
#' | ||
#' \code{dev.slackr} sends the graphics contents of the current device to the | ||
#' specified Slack channel. | ||
#' | ||
#' @param channels list of channels to post image to | ||
#' @param ... other arguments passed into png device | ||
#' @param api_token the slack.com full API token (chr) | ||
#' @param file prefix for filenames (defaults to \code{plot}) | ||
#' @return \code{httr} response object from \code{POST} call | ||
#' @seealso \code{\link{slackrSetup}}, \code{\link{save.slackr}}, \code{\link{slackrUpload}} | ||
#' @author Konrad Karczewski [ctb], Bob Rudis [aut] | ||
#' @note You can pass in \code{add_user=TRUE} as part of the \code{...} parameters and the Slack API | ||
#' will post the message as your logged-in user account (this will override anything set in | ||
#' \code{username}) | ||
#' @references \url{https://github.com/hrbrmstr/slackr/pull/12/files} | ||
#' @rdname dev_slackr | ||
#' @examples | ||
#' \dontrun{ | ||
#' slackr_setup() | ||
#' | ||
#' # base | ||
#' library(maps) | ||
#' map("usa") | ||
#' dev_slackr("#results", filename='map') | ||
#' | ||
#' # base | ||
#' barplot(VADeaths) | ||
#' dev_slackr("@@jayjacobs") | ||
#' } | ||
#' @export | ||
dev_slackr <- function(channels=Sys.getenv("SLACK_CHANNEL"), ..., | ||
api_token=Sys.getenv("SLACK_API_TOKEN"), | ||
file="plot") { | ||
|
||
loc <- Sys.getlocale('LC_CTYPE') | ||
Sys.setlocale('LC_CTYPE','C') | ||
on.exit(Sys.setlocale("LC_CTYPE", loc)) | ||
|
||
ftmp <- tempfile(file, fileext=".png") | ||
dev.copy(png, file=ftmp, ...) | ||
dev.off() | ||
|
||
modchan <- slackrChTrans(channels) | ||
|
||
POST(url="https://slack.com/api/files.upload", | ||
add_headers(`Content-Type`="multipart/form-data"), | ||
body=list( file=upload_file(ftmp), token=api_token, channels=modchan)) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#' Post a ggplot to a Slack channel | ||
#' | ||
#' Unlike the \code{\link{dev_slackr}} function, this one takes a \code{ggplot} object, | ||
#' eliminating the need to have a graphics device (think use in scripts). | ||
#' | ||
#' @param plot ggplot object to save, defaults to last plot displayed | ||
#' @param channels list of channels to post image to | ||
#' @param scale scaling factor | ||
#' @param width width (defaults to the width of current plotting window) | ||
#' @param height height (defaults to the height of current plotting window) | ||
#' @param units units for width and height when either one is explicitly specified | ||
#' (in, cm, or mm) | ||
#' @param dpi dpi to use for raster graphics | ||
#' @param limitsize when TRUE (the default), ggsave will not save images larger | ||
#' than 50x50 inches, to prevent the common error of specifying dimensions in pixels. | ||
#' @param api_token the slack.com full API token (chr) | ||
#' @param file prefix for filenames (defaults to \code{ggplot}) | ||
#' @param ... other arguments passed to graphics device | ||
#' @note You need to setup a full API token (i.e. not a webhook & not OAuth) for this to work | ||
#' Also, uou can pass in \code{add_user=TRUE} as part of the \code{...} | ||
#' parameters and the Slack API will post the message as your logged-in user | ||
#' account (this will override anything set in \code{username}) | ||
#' @return \code{httr} response object (invisibly) | ||
#' @examples | ||
#' \dontrun{ | ||
#' slackr_setup() | ||
#' ggslackr(qplot(mpg, wt, data=mtcars)) | ||
#' } | ||
#' @export | ||
ggslackr <- function(plot=last_plot(), | ||
channels=Sys.getenv("SLACK_CHANNEL"), | ||
scale=1, | ||
width=par("din")[1], | ||
height=par("din")[2], | ||
units=c("in", "cm", "mm"), | ||
dpi=300, | ||
limitsize=TRUE, | ||
api_token=Sys.getenv("SLACK_API_TOKEN"), | ||
file="ggplot", | ||
...) { | ||
|
||
loc <- Sys.getlocale('LC_CTYPE') | ||
Sys.setlocale('LC_CTYPE','C') | ||
on.exit(Sys.setlocale("LC_CTYPE", loc)) | ||
|
||
ftmp <- tempfile(file, fileext=".png") | ||
ggsave(filename=ftmp, | ||
plot=plot, | ||
scale=scale, | ||
width=width, | ||
height=height, | ||
units=units, | ||
dpi=dpi, | ||
limitsize=limitsize, ...) | ||
|
||
modchan <- slackr_chtrans(channels) | ||
|
||
res <- POST(url="https://slack.com/api/files.upload", | ||
add_headers(`Content-Type`="multipart/form-data"), | ||
body=list(file=upload_file(ftmp), | ||
token=api_token, | ||
channels=modchan)) | ||
|
||
invisible(res) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#' Save R objects to an RData file on Slack | ||
#' | ||
#' \code{save_slackr} enables you upload R objects (as an R data file) | ||
#' to Slack and (optionally) post them to one or more channels | ||
#' (if \code{channels} is not empty). | ||
#' | ||
#' @param ... objects to store in the R data file | ||
#' @param channels slack.com channels to save to (optional) | ||
#' @param file filename (without extension) to use | ||
#' @param api_token full API token | ||
#' @rdname save_slackr | ||
#' @note You can pass in \code{add_user=TRUE} as part of the \code{...} parameters and the Slack API | ||
#' will post the message as your logged-in user account (this will override anything set in | ||
#' \code{username}) | ||
#' @return \code{httr} response object from \code{POST} call | ||
#' @seealso \code{\link{slackr_setup}}, \code{\link{dev_slackr}}, \code{\link{slackr_upload}} | ||
#' @export | ||
#' @examples \dontrun{ | ||
#' slackr_setup() | ||
#' save_slackr(mtcars, channels="#slackr", file="mtcars") | ||
#' } | ||
save_slackr <- function(..., channels="", | ||
file="slackr", | ||
api_token=Sys.getenv("SLACK_API_TOKEN")) { | ||
|
||
|
||
loc <- Sys.getlocale('LC_CTYPE') | ||
Sys.setlocale('LC_CTYPE','C') | ||
on.exit(Sys.setlocale("LC_CTYPE", loc)) | ||
|
||
ftmp <- tempfile(file, fileext=".rda") | ||
save(..., file=ftmp) | ||
|
||
on.exit(unlink(ftmp), add=TRUE) | ||
|
||
modchan <- slackr_chtrans(channels) | ||
if (length(modchan) == 0) modchan <- "" | ||
|
||
res <- POST(url="https://slack.com/api/files.upload", | ||
add_headers(`Content-Type`="multipart/form-data"), | ||
body=list(file=upload_file(ftmp), | ||
filename=sprintf("%s.rda", file), | ||
token=api_token, | ||
channels=modchan)) | ||
|
||
stop_for_status() | ||
|
||
invisible(res) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.