├── run.sh ├── requirements.txt ├── README.md ├── app.py ├── .gitignore └── templates ├── success.html ├── failure.html └── hello.html /run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | export FLASK_APP=app.py 4 | python -m flask run 5 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | base58==0.2.3 2 | boto3==1.4.0 3 | botocore==1.4.46 4 | click==6.6 5 | docutils==0.12 6 | Flask==0.11.1 7 | futures==3.0.5 8 | hjson==2.0.0 9 | itsdangerous==0.24 10 | Jinja2==2.8 11 | jmespath==0.9.0 12 | kappa==0.6.0 13 | lambda-packages==0.8.0 14 | MarkupSafe==0.23 15 | placebo==0.8.1 16 | python-dateutil==2.5.3 17 | python-slugify==1.2.0 18 | PyYAML==3.11 19 | requests==2.11.1 20 | s3transfer==0.1.2 21 | six==1.10.0 22 | tqdm==4.8.3 23 | Unidecode==0.4.19 24 | Werkzeug==0.11.10 25 | wsgi-request-logger==0.4.5 26 | zappa==0.23.0 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Slacker 3 |

4 | 5 | # zappa-slack-inviter 6 | 7 | A teeny tiny server-less Slack channel inviter. 8 | 9 | ## Installation 10 | 11 | ``` 12 | git clone https://github.com/Miserlou/zappa-slack-inviter 13 | cd zappa-slack-inviter 14 | virtualenv env && source env/bin/activate && pip install -r requirements.txt 15 | ``` 16 | 17 | Then add your [token](https://api.slack.com/docs/oauth-test-tokens) and channel settings into `app.py` using your favorite text editor, then `zappa init` and `zappa deploy`. 18 | 19 | ## Custom Domains 20 | 21 | To deploy your inviter with a custom domain and auto-renewing Let's Encrypt certificate, see [this chapter of the Zappa documentation](https://github.com/Miserlou/Zappa/blob/master/docs/domain_with_free_ssl_dns.md). 22 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, request 2 | import requests 3 | 4 | ## 5 | # Configuration 6 | # 7 | # Change these values to your team's information! 8 | # Get your token from here: https://api.slack.com/docs/oauth-test-tokens 9 | ## 10 | 11 | TEAM_NAME = "Zappa" 12 | SLACK_TOKEN = "xoxp-Z4PP4Z4PP4-Z4PP4Z4PP4-Z4PP4Z4PP4-Z4PP4Z4PP4" 13 | SLACK_DOMAIN = "zappateam.slack.com" 14 | 15 | ## 16 | # Application 17 | ## 18 | 19 | app = Flask(__name__) 20 | 21 | 22 | @app.route('/', methods=['GET']) 23 | def hello(): 24 | return render_template( 25 | 'hello.html', 26 | team_name=TEAM_NAME, 27 | ) 28 | 29 | 30 | @app.route('/', methods=['POST']) 31 | def join(): 32 | email = request.form['email'] 33 | data = { 34 | 'email': email, 35 | 'token': SLACK_TOKEN, 36 | 'set_active': True 37 | } 38 | url = 'https://' + SLACK_DOMAIN + '/api/users.admin.invite' 39 | 40 | resp = requests.post(url, data=data) 41 | if resp.status_code == 200: 42 | return render_template( 43 | 'success.html', 44 | team_name=TEAM_NAME, 45 | ) 46 | else: 47 | return render_template( 48 | 'failure.html', 49 | team_name=TEAM_NAME, 50 | ) 51 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.zip 3 | 4 | # Byte-compiled / optimized / DLL files 5 | __pycache__/ 6 | *.py[cod] 7 | *$py.class 8 | 9 | # C extensions 10 | *.so 11 | 12 | # Distribution / packaging 13 | .Python 14 | env/ 15 | build/ 16 | develop-eggs/ 17 | dist/ 18 | downloads/ 19 | eggs/ 20 | .eggs/ 21 | lib/ 22 | lib64/ 23 | parts/ 24 | sdist/ 25 | var/ 26 | *.egg-info/ 27 | .installed.cfg 28 | *.egg 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *,cover 49 | .hypothesis/ 50 | 51 | # Translations 52 | *.mo 53 | *.pot 54 | 55 | # Django stuff: 56 | *.log 57 | 58 | # Sphinx documentation 59 | docs/_build/ 60 | 61 | # PyBuilder 62 | target/ 63 | 64 | # PyCharm 65 | # Project settings from the PyCharm IDE are stored in the .idea folder 66 | .idea/ 67 | 68 | # Apple OS X specific files are put into the .DS_Store file 69 | .DS_Store 70 | 71 | # Vim stuff: 72 | *.swp 73 | *.swo 74 | *~ 75 | tests/zappa_settings.json 76 | -------------------------------------------------------------------------------- /templates/success.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Success! 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 56 | 57 | 58 | 59 | 60 |
61 | 64 | 65 |

Check your email for an invite!

66 | 67 |
68 | 69 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /templates/failure.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Join {{team_name}}'s Slack! 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 56 | 57 | 58 | 59 | 60 |
61 | 64 | 65 |

Something went wrong, sorry!

66 | 67 |
68 | 69 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /templates/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Join {{team_name}}'s Slack! 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 56 | 57 | 58 | 59 | 60 |
61 | 64 | 65 | 66 |
67 |
68 | 69 |
70 | 71 |
72 |
73 |
74 |
75 | 76 |
77 |
78 |
79 | 80 |
81 | 82 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | --------------------------------------------------------------------------------