slackinvite

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2025 License: BSD-3-Clause Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

=======================
Slack Invite Automation
=======================

  Yet another hack on the internets.

Motivation:

#.  Slack expires manually generated invitations to the `Slackdump`_
    slack.
#.  Calling the `users.admin.invite` requires the Slack with
    Enterprise plan.

So I did the right thing and wrote the Slack Inviter that uses the
client token/cookie pair using the fork of slack library that I
created for the `Slackdump`_.

Demo: `Slackdump Slack invitation`_

The invitations that your guests receive are from the actual user (that means
*YOU*), i.e. "Scumbag Steve has invited you to work with them in Slack".

Possible improvements:

- my HTML skills are super sub-optimal:  it's all Web GET/POST, almost no
  JavaScript.
- error handling - just GET request to the root path with "e=" param.
- Docker container.
- this project really could use some tests.
- Actually add the database (right now the database handle is there,
  but is not used).
- Heroku deployment, the magic purple button.

Configuration
-------------

Environment Variables
~~~~~~~~~~~~~~~~~~~~~

Configuration variables can be set in environment, or defined in an
.env file.

Supported environment variables:

+-------------------+-----------------------------------------+
|**Variable**       |**Description**                          |
+-------------------+-----------------------------------------+
|CONFIG_FILE        |configuration file with template values. |
+-------------------+-----------------------------------------+
|TOKEN              |Slack xoxc- token.                       |
+-------------------+-----------------------------------------+
|COOKIE             |Slack xoxd- cookie value.                |
+-------------------+-----------------------------------------+
|ADDR               |address (or hostname) for http listener. |
+-------------------+-----------------------------------------+
|PORT               |port for http listener.                  |
+-------------------+-----------------------------------------+
|RECAPTCHA_KEY      |Google ReCaptcha V3 key (optional).      |
+-------------------+-----------------------------------------+
|RECAPTCHA_SECRET   |Google ReCaptcha V3 secret (optional).   |
+-------------------+-----------------------------------------+


Configuration file
~~~~~~~~~~~~~~~~~~

Configuration file is a yaml file and allows to define the template
values, i.e. the website url, and slack community/workspace name, that
will be shown to the user accessing the service.

Configuration file supports environment variables.  To use an
environment variable as a value, prefix text with a '$' sign,
optionally enclosing the environment variable in curly braces, "{" and
"}".  Well, you probably already know the drill (see slack_workspace
variable in the Example).

Sample configuration file:

.. code:: yaml

  slack_workspace: ${WORKSPACE_NAME}
  submit_button: Gimme, gimme!
  website: https://github.com/rusq
  copyright: 2022 Maybe Peter
  telegram_link: https://t.me/slackdump
  github_link: https://github.com/rusq/slackdump

Variables description:

+---------------+----------------------------------------+
|**Parameter**  |**Description**                         |
+---------------+----------------------------------------+
|slack_workspace|Slack workspace name                    |
+---------------+----------------------------------------+
|submit_button  |Text shown on the submit button.        |
+---------------+----------------------------------------+
|website        |URL of your website, shown in footer.   |
+---------------+----------------------------------------+
|copyright      |Copyright message, shown in footer.     |
+---------------+----------------------------------------+
|telegram_link  |Telegram channel/group URL. Shown in    |
|               |footer.                                 |
+---------------+----------------------------------------+
|github_link    |Github URL, i.e. to your project. Shown |
|               |in footer.                              |
+---------------+----------------------------------------+



Quick Start
-----------

1. Download from releases.
2. Create a config file (see slackdump.yaml for example).
3. Set your environment


.. _slackdump: https://github.com/rusq/slackdump
.. _Slackdump Slack invitation: https://slackdump.herokuapp.com/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fields

type Fields struct {
	//body
	SlackWorkspace string `yaml:"slack_workspace,omitempty"`
	//form
	SubmitButton string `yaml:"submit_button,omitempty"`
	// footer
	Website      string `yaml:"website,omitempty"`
	Copyright    string `yaml:"copyright,omitempty"`
	TelegramLink string `yaml:"telegram_link,omitempty"`
	GithubLink   string `yaml:"github_link,omitempty"`
}

func LoadFields

func LoadFields(filename string) (Fields, error)

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the http server that issues the invites.

func New

func New(addr string, db *sql.DB, client slackClient, rc recaptcha.ReCaptcha, fields Fields) (*Server, error)

func (*Server) Run

func (s *Server) Run() error

Directories

Path Synopsis
cmd
asset command
asset is a tool for rendering static html templates during development so I don't need to run the server to work on page styles.
asset is a tool for rendering static html templates during development so I don't need to run the server to work on page styles.
slackinvite command
internal
chtml
Package chtml provides convenience functions to wrap the standard html/template package.
Package chtml provides convenience functions to wrap the standard html/template package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址