No description
  • Python 69%
  • HTML 30.3%
  • Dockerfile 0.7%
Find a file
Ola Nyström 8d3f0ca607
All checks were successful
Docker Publish / build-and-push (push) Successful in 1m34s
BUG(app): add missing commas to WFO_MESSAGES list
2026-02-04 09:40:01 +01:00
.forgejo/workflows First iteration of webapp/webpage 2025-12-16 20:18:35 +01:00
.kilocode/rules Implement database tracking for WFH/WFO messages and enhance logging throughout the application 2025-12-17 10:29:40 +00:00
templates feat(ui): add WFH/WFO statistics dashboard 2025-12-20 11:09:27 +01:00
tests feat(ui): add WFH/WFO statistics dashboard 2025-12-20 11:09:27 +01:00
.dockerignore First iteration of webapp/webpage 2025-12-16 20:18:35 +01:00
.env.example Implement database tracking for WFH/WFO messages and enhance logging throughout the application 2025-12-17 10:29:40 +00:00
.gitignore Implement database tracking for WFH/WFO messages and enhance logging throughout the application 2025-12-17 10:29:40 +00:00
app.py BUG(app): add missing commas to WFO_MESSAGES list 2026-02-04 09:40:01 +01:00
config.ini.example Add configuration management and README documentation 2025-12-05 14:45:29 +01:00
database.py fix(db): close database connection after health check 2026-01-08 13:05:49 +01:00
docker-compose.yaml chore(config): adjust compose healthcheck timing 2025-12-20 11:48:06 +01:00
Dockerfile Fix Dockerfile to include database.py and correct logging_config.py filename 2025-12-19 10:50:30 +01:00
logging_config.py Implement database tracking for WFH/WFO messages and enhance logging throughout the application 2025-12-17 10:29:40 +00:00
morgonslack.py fix(api): close HTTP responses to prevent file descriptor leaks 2026-01-08 12:35:07 +01:00
pyproject.toml Add tests for configuration validation and message routes 2025-12-17 21:52:51 +01:00
README.md feat(ui): add WFH/WFO statistics dashboard 2025-12-20 11:09:27 +01:00
TECH.md feat(ui): add WFH/WFO statistics dashboard 2025-12-20 11:09:27 +01:00
uv.lock Add tests for configuration validation and message routes 2025-12-17 21:52:51 +01:00

MorgonSlack

A Python script that posts messages to the most active Slack thread of the day, helping you join the morning conversation without starting a new thread.

Features

  • Automatically finds the most active Slack thread from today
  • Posts your message as a reply to that thread
  • Falls back to posting a new message if no active threads are found
  • Uses browser-based authentication (no admin app approval needed)

Installation

Prerequisites

  • Python 3.11+
  • uv (Python package manager)
  • Dependencies are managed via pyproject.toml

Setup

  1. Install dependencies:

    uv sync
    
  2. Set up configuration:

    # Create config directory
    mkdir -p ~/.config/morgonslack
    
    # Copy the example config file
    cp config.ini.example ~/.config/morgonslack/config.ini
    
    # Edit the config file with your credentials
    nano ~/.config/morgonslack/config.ini
    

Docker Deployment

For containerized deployment using Docker and docker-compose.

Prerequisites

  • Docker and docker-compose installed
  • Slack credentials (token, cookie, channel)

Setup

  1. Create environment file:

    # Create .env file in project root
    touch .env
    
  2. Configure environment variables in .env:

    SLACK_TOKEN=xoxc-your-token-here
    SLACK_COOKIE=xoxd-your-cookie-here
    SLACK_CHANNEL=#your-channel
    

Build and Run

# Build the image
docker-compose build

# Run with environment variables
docker-compose up -d

# View logs
docker-compose logs -f

# Stop the service
docker-compose down

The Flask application will be available at http://localhost:5000 with web endpoints for posting WFH/WFO messages.

Configuration

The configuration file is located at ~/.config/morgonslack/config.ini

Config File Format

[slack]
# Client token (starts with 'xoxc-')
# Found in browser developer tools when logged into Slack
token = xoxc-your-token-here

# Session cookie value (the 'd' cookie)
# This authenticates the token. It looks like "xoxd-..." or a long hex string.
# To find it: In browser developer tools, go to Application > Cookies,
# find the 'd' cookie and copy its value (without the "d=" prefix).
cookie = xoxd-your-cookie-here

# Channel to post to
# You can use the channel name (e.g. #general) or the channel ID.
# To find channel ID: In Slack, right-click channel name > Copy link,
# the ID is the part after "channel/" in the URL.
channel = #your-channel

How to Get Your Slack Credentials

  1. Token:

    • Open Slack in your browser
    • Open Developer Tools (F12 or Ctrl+Shift+I)
    • Go to the Network tab
    • Refresh the page and look for API calls
    • Find the Authorization header - it contains your token
  2. Cookie:

    • In Developer Tools, go to Application > Cookies
    • Find the cookie named "d"
    • Copy the value (not including "d=")

Usage

Command Line

# Post a message to the most active thread
uv run python morgonslack.py "Good Morning, WFH"

# Post a different message
uv run python morgonslack.py "Working from office today"

# Post a longer message
uv run python morgonslack.py "Good morning everyone! Starting my day with some coffee and code."

Web Interface

When running with Docker, access the web interface at http://localhost:5000:

  • Visit / for the main interface to post WFH/WFO messages
  • Visit /stats to view statistics and analytics of your WFH/WFO patterns
  • Visit /wfh to post a random WFH message
  • Visit /wfo to post a random WFO message

How It Works

  1. The script loads your Slack credentials from ~/.config/morgonslack/config.ini
  2. It retrieves all messages from today in your specified channel
  3. It finds the message with the most replies (most active thread)
  4. If a thread is found, it posts your message as a reply to that thread
  5. If no active threads are found, it posts your message as a new message

Error Handling

  • Missing config file: The script will exit with a helpful error message pointing you to create the config file
  • Invalid credentials: If your token or cookie is invalid/expired, the script will show an authentication error
  • Network issues: Any network problems will be displayed with details

Security

  • Never commit your config.ini file - it contains sensitive credentials
  • The config.ini file is already in .gitignore to prevent accidental commits
  • Use browser-based authentication to avoid needing admin app approval

Troubleshooting

"invalid_auth" error

  • Your token or cookie may be expired
  • Try logging out and back into Slack in your browser
  • Update your credentials in the config file

No active threads found

  • Make sure you're using the correct channel name/ID
  • Check that there are actually threaded conversations in your channel today
  • The script only looks at messages from the current day (00:00:00 onwards)

License

This project is open source and available for personal use.