mrkaye97 / slackr

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

slackr_msg() error #114

Closed adrian-pascual closed 3 years ago

adrian-pascual commented 3 years ago

When using slackr v2.0 after running slackr_setup(config_file = "~/file/path"), slackr_msg() encounters this error:

slackr_msg(text= "testing", channel = "#random") 
# Error: `x` and `y` must share the same src, set `copy` = TRUE (may be slow).

Checked where the error was occurring with rlang::last_error()

# Backtrace:
# 1. slackr::slackr_msg(text = "testing", channel = "#data-test")
# 5. slackr::slackr_chtrans(channel)
# 6. slackr::slackr_ims(bot_user_oauth_token)
# 8. dplyr:::left_join.data.frame(users, ims, by = "id")
# 9. dplyr::auto_copy(x, y, copy = copy)
# 10. dplyr:::glubort(...)

slacker_ims(bot_user_oauth_token) also fails with the same error. Any wisdom on this? My initial hunch was that it's an API scope issue but I've added a bunch of scopes to the Slack app and seen nothing change.

mrkaye97 commented 3 years ago

@adrian-pascual I'll look into this tonight

In the meantime, try just doing slackr(text = "testing", channel = "#data-test").

adrian-pascual commented 3 years ago

@mrkaye97, running into the same error, almost positive this is because slack_users() is returning an empty data frame within slackr(), which breaks the dplyr:::left_join.data.frame(users, ims, by = "id")

slackr_users(bot_user_oauth_token)
# data frame with 0 columns and 0 rows
mrkaye97 commented 3 years ago

@adrian-pascual yep, this is my guess too. I'll see if I can replicate this locally tonight. What's in your config file? Also, what scopes do you have turned on?

adrian-pascual commented 3 years ago

I actually managed to get slackr_users(bot_user_oauth_token) to return a data frame with more scopes! I have all the scopes except for the identity ones and the admin ones.

However, still getting the same error message when I run slackr_msg, the issue now is that r chan <- slackr::slackr_channels(bot_user_oauth_token) only returns public and not private channels. This causes an error if the channel I use for the slack_msg(channel = test-channel) is private. Assuming there's no way to fix this without manually adding the private channel to this line.

mrkaye97 commented 3 years ago

@adrian-pascual great news! Thanks for the update. Actually, it's this line that deals with private channels, and that should be set up okay. this is probably still a scopes issue, I assume. If you're going to dig around in which scopes are needed, would you mind recording them by the way? That'd be a great resource, since I don't actually know and this seems to be a constant issue.

Edit: FYI, you can test that the requests are working here: https://api.slack.com/methods/conversations.list/test

adrian-pascual commented 3 years ago

Ah ok, at this point the only scopes I haven't added are Admin ones, but I don't have Admin privileges for the Slack Workspace I'm in, so I assume a scope like admin.usergroups:read would be necessary

mrkaye97 commented 3 years ago

You shouldn't need any of the admin scopes. These are the ones I have:

Screen Shot 2020-12-07 at 4 47 44 PM
mrkaye97 commented 3 years ago

@adrian-pascual I just tested a private channel on my machine, and am having the same issue. I then went to the Slack API here: https://api.slack.com/methods/conversations.list/test

I put in my bot user token from my Slack app, and put private_channel in the types box, and didn't see any private channels. As far as I can tell, this is an issue with the Slack API. These are the scopes I have enabled.

Screen Shot 2020-12-07 at 8 09 21 PM

If you play around with it and find a scope that lets private channels show up, please report back because that'd be great info. Thanks, and sorry about this!

adrian-pascual commented 3 years ago

Thanks for testing @mrkaye97! Quite relieved that you're helping manage this package, it was inactive for a while and didn't think it would ever be updated.