strongdm / accessbot

Manage access to strongDM resources via Slack
Apache License 2.0
23 stars 19 forks source link

Create a script that gives you the Slack Handle for a given Slack Display Name #136

Closed mdube667 closed 3 years ago

mdube667 commented 3 years ago

Describe the bug Customer has a user handle with a space in it and accessbot errors out: "errbot.backends.base.UserDoesNotExistError: Cannot find user ."

To Reproduce Install accessbot and add a user with a space in their handle

Expected behavior Should work as with a handle without space

camposer commented 3 years ago

You cannot have slack handles with spaces. They might be using the person field, not the nick We'll create a simple script (or similar) that tells you the nick for a given Slack person You could also get the nick by executing whoami in AccessBot, but in order to do that, you need a valid SDM_ADMIN So it's kind of a chicken and the egg type of thing

camposer commented 3 years ago

I'll update the name of the issue to reflect what we'll do, create a script that gives you the nick (slack handle) for a given person name (slack display name)

python3 get-slack-handle <slack-display-name>

The script should grab the slack tokens from environment variables, and the script output should be something like:

$ python3 get-slack-handle @Rodolfo Campos
The nick for that display name is: @rodolfo 

We need to make the script able to work with RTM and Bolt. So, 2 versions of it, same file, different "content" depending on the branch main or 1.0.x

camposer commented 3 years ago

Please take a look at: https://github.com/strongdm/errbot-slack-bolt-backend/blob/develop/errbot_slack_bolt_backend/slackbolt.py#L574

camposer commented 3 years ago

Following an example about how to use the script:

$ python tools/get-slack-handle.py -e rodolfo@strongdm.com
The nick for that user is: @rodolfo
$ python tools/get-slack-handle.py -d "Rodolfo Campos"
The nick for that user is: @rodolfo

IMPORTANT: You have to have the needed environment variables set in order to work (SLACK_BOT_TOKEN for 1.1. or SLACK_TOKEN or 1.0)