Readme em Português - PTBR.
SafeChat Slack Bot is an open-source project designed to enhance data security within Slack workspaces. The bot's primary objective is to provide real-time alerts to users when sensitive information such as CPF (Brazilian taxpayer registry identification), email addresses, and other personally identifiable information (PII) are shared within Slack channels. SafeChat Slack Bot identifies and notifies users about potential data breaches, promoting a safer and more secure communication environment within Slack.
The SafeChat must be a member to receive messages from a channel or dm.
- Open https://api.slack.com/apps/new and choose "From an app manifest"
- Choose the workspace you want to install the application to
- Copy the contents of manifest.json into the text box that says Paste your manifest code here (within the JSON tab) and click Next
- Review the configuration and click Create
- Click Install to Workspace and Allow on the screen that follows. You'll then be redirected to the App Configuration dashboard.
Before you can run the app, you'll need to store some environment variables.
- Open your apps configuration page from this list, click OAuth & Permissions in the left hand menu, then copy the Bot User OAuth Token. You will store this in your environment as SLACK_BOT_TOKEN.
- Click *Basic Information from the left hand menu and follow the steps in the App-Level Tokens section to create an app-level token with the connections:write scope. Copy this token. You will store this in your environment as SLACK_APP_TOKEN.
- Python 3.11 - pre-requisite
- Docker - pre-requisite
- Docker Compose - pre-requisite
- gettext - Multilingual internationalization services - pre-requisite
- Poetry - pre-requisite
- Ruff
- Slack Bolt
- i18n
Please pay attention on pre-requisites resources that you must install/configure.
Variable | Description | Available Values | Default Value | Required |
---|---|---|---|---|
ENV | The application enviroment | dev / test / qa / prod |
dev |
Yes |
PYTHONPATH | Provides guidance to the Python interpreter about where to find libraries and applications | ref | . |
Yes |
LANGUAGE | The bot language | en / pt_BR |
pt_BR |
Yes |
SLACK_BOT_TOKEN | The slack bot token | a valid token |
- |
Yes |
SLACK_APP_TOKEN | The slack app token | a valid token |
- |
Yes |
Note: When you run the install command (using docker or locally), a .env file will be created automatically based on env.template
Command | Docker | Locally | Description |
---|---|---|---|
install | make docker/install |
make local/install |
to install |
tests | make docker/tests |
make local/tests |
to run the tests with coverage |
lint | make docker/lint |
make local/lint |
to run static code analysis using ruff |
lint/fix | make docker/lint/fix |
make local/lint/fix |
to fix files using ruff |
run | make docker/run |
make local/run |
to run the project |
build image | make docker/image/build |
- | to build the docker image |
push image | make docker/image/push |
- | to push the docker image |
Helpful commands
Please, check all available commands in the Makefile for more information.
The Bot supports multiple languages using i18n pattern.
Locale file structure:
├─ src
│ ├─ locales
│ │ └─ en
│ │ └─ LC_MESSAGES
│ │ └─ base.po
│ │ └─ pt_BR
│ │ └─ LC_MESSAGES
│ │ └─ base.po
- Create a new folder in
src/locales
with the new language; - Create a new
base.po
file inside this folder (you just can copy from another language); - Translate all the messages;
- Generate the
mo
files using the commandmake generate-mo-files
; - Include the command to generate po file on Dockerfile.
This project uses a simple way to configure the log with logging.conf to show the logs on the container output console.
This project uses a simple way to manage the settings with settings.conf and ConfigParser using a config class.