"""
Slack — Post Message Demo
==========================
A minimal, ready-to-run example of posting a message via an Incoming Webhook.

Get a webhook URL (free):
    1. Go to https://api.slack.com/apps and click "Create New App"
       (choose "From scratch" and pick your workspace).
    2. Open "Incoming Webhooks" and toggle it on.
    3. Click "Add New Webhook to Workspace", pick a channel, and copy
       the generated webhook URL.

Setup:
    pip install requests
    export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/..."

Run:
    python slack_demo.py
"""

import os
import requests


def post_message(text: str) -> int:
    """Post a message to a Slack channel and return the HTTP status code."""
    response = requests.post(
        os.environ.get("SLACK_WEBHOOK_URL"),
        json={"text": text},
    )
    response.raise_for_status()
    return response.status_code


if __name__ == "__main__":
    status = post_message("Hello from krueng.ai 👋")
    print(f"Status: {status}")
