Note: This project is currently in early development. Some features may be unstable, incomplete, or undergoing significant refactoring. Use at your own risk.
A Slack bot built with the Bolt for Python framework that handles blindtest submissions and manages a leaderboard.
- Leaderboard: Track user scores for correct submissions.
- Slash Commands:
/leaderboard: Display the top 5 ranking users./get_rank <user_login>: Get the specific rank and score of a user.
- Interactive Mentions: Responds to @mentions for submissions.
- Socket Mode: Easy setup without needing a public URL/ngrok for development.
git clone git@github.com:pibouill/slack_bot.git
cd slack_botUsing a virtual environment (venv) keeps your project dependencies isolated.
On Linux/macOS:
python3 -m venv .venv
source .venv/bin/activateOn Windows:
python -m venv .venv
.venv\Scripts\activatepip install -r requirements.txtTo run this bot, you need to create a Slack App and obtain two specific tokens.
- Go to Slack API: Your Apps and click Create New App (from scratch).
- Bot User Token (
SLACK_BOT_TOKEN):- Go to OAuth & Permissions.
- Under Scopes, add
app_mentions:read,chat:write,commands, andusers:read. - Install the app to your workspace.
- Copy the Bot User OAuth Token (starts with
xoxb-).
- App-Level Token (
SLACK_APP_TOKEN):- Go to Settings > Basic Information.
- Under App-Level Tokens, click Generate Token and Scopes.
- Name it (e.g.,
socket_mode) and add theconnections:writescope. - Copy the generated token (starts with
xapp-).
- Enable Socket Mode:
- Go to Settings > Socket Mode and toggle Enable Socket Mode to ON.
- Enable Event Subscriptions:
- Toggle Enable Events to ON.
- Under Subscribe to bot events, add
app_mentionandmessage.channels.
- Slash Commands:
- Go to Slash Commands and create
/leaderboardand/get_rank.
- Go to Slash Commands and create
Create a .env file in the root directory (this file is ignored by Git for security):
SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_APP_TOKEN=xapp-your-app-tokenEnsure your virtual environment is activated, then run:
python app.pyThe bot will prompt for a valid_input (the correct answer for the blindtest) in the terminal and then start listening for Slack events.