Package: slack-groupmgr
membership tools for private groupsSlack channels are great, anyone who is a member of your team can join
or leave a channel as they want. Slack also supports private groups (aka
private channels) which are invite-only. These private groups are
invisible to anyone who is not a member of the group, and are
appropriate for subsets of the team who need to work on particular
projects.Unfortunately, there’s nothing in-between team-wide public channels and
single private groups.For example, you may have a subset of the team, such as “finance” who
may want to be able to leave or join any of a number of private groups
relating to finance. However, unless they’ve been manually invited to
all of the private “finance” groups, and added to any new finance groups
that may be created in the future, there is a chance they can be kept in
the dark about the activites of their own team.One way to solve this would be to create a finance-only Slack team for
just the finance department. Another way, while definitely not perfect,
is to use a custom integration to create “private-group-clusters.”For example, one can add all the members of the finance department to a
private group, such as “finance-department” and they may join any other
private group matching a regular expression or expressions (e.g.
“finance-.*” and “sales-forecast”).AudienceBe familiar with Apache, CGI programs, Python, and JSON, and creating
Slack integrations before attempting this.Installationpip3 install slack-groupmgrwill create three new commands,groupmgr,groupmgr-cgi, andgroupmgr-flask.  They are, in turn, the commandline, CGI, and
a standalone Flask/WSGI debugging server.In production, we strongly reccomand using the WSGI version of
group manager, and running it under Apache or ngnix or gunicorn
or one of the many WSGI capable webservers out there.The CGI version is legacy and might be abandoned in the future.Configuration:Create a “Group Manager” account, it does not need special privileges,
but it must have access to the Web API. At this time it cannot be a
“bot” account, it must be a regular account to use the API’s group
invite mechanism.Invite this “Group Manager” account to all of the private groups you
want it to manage. Slack users, even team owners, do not have any
visibility into groups that they are not a member of, and “Group
Manager” is no different.Acquire a WEB API token for the Group Manager account.https://api.slack.com/docs/oauth-test-tokensCreate a custom slash command integration for your copy of Group Manager
with the following parameters:Command: /groupmgr (or whatever you want to call it)URL: point to your server hosting groupmgrMethod: POSTToken: (generated by Slack, record this, you’ll need it below
(SLASH-TOKEN)Customize Name: “Group Manager”Customize Icon: (your choice)Autocomplete Description: Add yourself to semi-private groupsAutocomplete Help: Use ‘list’, ‘add’, and ‘help’ for more infoConfigure your webserver to execute the groupmgr python script as CGI at
the URL you chose above.Note: Python 3 has some issues with Unicode encoding if theLANGenvironment variable is not set properly before the interepreter
executes code. Make sure thatLANGis set to a utf-8 encoding such
asC.utf-8orEN_us.utf-8.Finally, configure the script itself, look atexamples/config.jsonThe script, by default, will look for config.json in$HOME/.config/groupmgr/config.jsondefault-teamis only used when using the command lineteam_idis the Slack ID (starts with T0…..) of your teamapi_tokenis the Slack Web API token that groupmgr will use to
control Slackinbound_tokensare a list of valid SLASH-TOKENs from the slash
commandsadministratorsare the names of users who can use groupmgr admin
commandsFinally, configure your groups, the dictionary is indexed by a master
group followed by a list of regular expressions. See the example file
for the format.