mrkaye97 / slackr

An R package for sending messages from R to Slack
https://matthewrkaye.com/slackr/
Other
307 stars 85 forks source link

slackr_setup() in v3.0.0 no longer works with bot_user_oauth_token? #161

Closed achubaty closed 3 years ago

achubaty commented 3 years ago

Following the instructions here to setup a scoped bot token no longer works for slackr v3.0.0. Changing bot_user_oauth_token to token works, but then this is treated as a single channel bot, and any channel specification is ignored.

> library(slackr)
> slackr_setup()
Error in if (substr(token, 1L, 4L) == "xoxp") { : 
  missing value where TRUE/FALSE needed
> 
> slackr_setup(bot_user_oauth_token = 'xoxp-mytoken')
Error in slackr_setup(bot_user_oauth_token = "xoxp-mytoken") : 
  unused argument (bot_user_oauth_token = "xoxp-mytoken")

If using bot tokens is deprecated, the docs need updating -- and users need to be warned to setup personal tokens.

mrkaye97 commented 3 years ago

Ah, thanks @achubaty. The bot_user_oauth_token was deprecated in slackr 2.4.0 in favor of token, and was removed in slackr 3.0.0. Note: The use of bot tokens was not deprecated. Only the name of the argument was changed.

I will update the vignette tonight to explain the change. Thanks again for pointing this out!

I'll also add a little bit of error handling, since that error you got isn't very helpful.

mrkaye97 commented 3 years ago

Alright @achubaty, #162 should close this issue and fix the documentation and error handling.

Re: channel specification -- which slackr function are you using? slackr_bot will only post to the channel that's attached to the webhook, and the channel argument won't work

achubaty commented 3 years ago

Thank you. I was previously able to set the channel and the user in the config file. Looks like it's only the user it is complaining about (sorry, I misread the error).

I have it working now.

mrkaye97 commented 3 years ago

Aha, sounds good! If you are using a user token (e.g. xoxp), specifying a username won't do anything, since it'll post as you. Just to confirm: is that what you were seeing? It'd be great if you could post the error message -- then I'll know for sure and can merge #162 and ship these fixes

achubaty commented 3 years ago

After getting rid of user, my ~/.slackr contains token, incoming_webhook_url, and channel.

> slackr_setup()
[1] "Successfully connected to Slack"
Warning message:
You're using a user token but also specified the following parameter(s): NA, NA. These arguments will have no effect.
This warning is displayed once per session. 

Sending a message, the username appears as NA.

mrkaye97 commented 3 years ago

Ah, okay. this is another good one for me to fix! Thanks again!

mrkaye97 commented 3 years ago

Last thing @achubaty: Do you mind pasting your config file here (and removing the secrets, of course)? I can't reproduce this issue. The NA NA seems a little weird.

achubaty commented 3 years ago
achubaty@machine:~$ cat ~/.slackr 
token: xoxp-my_token
incoming_webhook_url: https://hooks.slack.com/services/my_webhook
mrkaye97 commented 3 years ago

Got it. thanks @achubaty. I still couldn't repro the NA issue, but I've made an attempt at a patch in #162 which I'll merge now. Do you mind installing the latest dev version with devtools::install_github("mrkaye97/slackr") and giving it a shot?

achubaty commented 3 years ago

Not seeing the warning now. THanks!