Code Monkey home page Code Monkey logo

slack-bulkinviter's Introduction

slack-bulkinviter

Super quick and dirty Python script to bulk invite ALL users in a slack team to a specific channel. We need to do this regulary with Counterparty when we create a new channel that everyone should be in, or move things around.

To use:

  • Install the slacker library via pip
  • Get an API key
  • Optionally, if not using --apikey, create a file in the same directory as slack-bulkinviter.py containing your API key and pass the filename to the argument --apikey or -k
  • Execute the script, passing the name of the channel where all users will be invited, such as ./slack-bulkinviter.py --channel mychannel --apikey myapistring
  • Sit back and let it do its work

Also, here's a best practice that any Slack workspace member can do very quickly directly in Slack. No Python script required.

  1. Type the /who command in a channel where you most of the people you want to add already hang out
  2. Copy the output
  3. Paste it in the channel where you want to invite them
  4. Press Enter

Slackbot tells you that you have mentioned people who "are not in this channel" and gives you an Invite Them button.

Hat tip: jonareyes at StackExchange

slack-bulkinviter's People

Contributors

chen-fam avatar donnoman avatar memviacbs avatar orrchen avatar robby-d avatar tbc avatar tdemarest avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

slack-bulkinviter's Issues

Easily run this script with Docker

Not an issue, but I thought it would be helpful to other people to easily run this.

Create a new directory named "slack-bulkinviter", then once in that directory, copied the raw file there:

mkdir slack-bulkinviter && cd $_
curl -O https://raw.githubusercontent.com/robby-dermody/slack-bulkinviter/master/slack-bulkinviter.py

You'll also want to create your apikey.txt file in this same directory with the contents of your API key.

I then created file named Dockerfile and pasted in the following contents:

FROM python:3.8.2-buster

RUN pip install --no-cache-dir slacker

COPY slack-bulkinviter.py .
COPY apikey.txt .

Then built the docker image with:

docker build -t slack-bulkinviter .

At this point you should be all set, and can run the script like so:

docker run -it --rm slack-bulkinviter python slack-bulkinviter.py your-channel

Hope this is helpful to someone who doesn't have python already installed on their system, or just wants a clean disposable way to run this script!

Reading key from filesystem does not work for me, manual init works just fine

Traceback (most recent call last):
  File "inviter.py", line 30, in <module>
    response = slack.channels.list()
  File "/Library/Python/2.7/site-packages/slacker/__init__.py", line 212, in list
    params={'exclude_archived': exclude_archived})
  File "/Library/Python/2.7/site-packages/slacker/__init__.py", line 68, in get
    return self._request(requests.get, api, **kwargs)
  File "/Library/Python/2.7/site-packages/slacker/__init__.py", line 63, in _request
    raise Error(response.error)
slacker.Error: invalid_auth

But when I do like here:

from slacker import Slacker

slack = Slacker('<your-slack-api-token-goes-here>')

# Send a message to #general channel
slack.chat.post_message('#general', 'Hello fellow slackers!')

# Get users list
response = slack.users.list()
users = response.body['members']

# Upload a file
slack.files.upload('hello.txt')

It works just fine... I have no experience in Python whatsoever, I've just managed to hack use their initialisation method...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.