How timfanda35/simple-channel-notify works
Project Type and Purpose
• This is an open-source, single-binary CLI tool (written in Go) packaged as a Docker container.
• Its sole purpose is to send a simple text notification to one of several supported “channels” via each channel’s RESTful API endpoint (Telegram Bot API, LINE Notify, Hangouts Chat webhook, Slack Incoming Webhook, Discord Webhook).
Main Components
a. Host/CI System
• Local developer machine or CI/CD runner (GitHub Actions, GitLab CI, Google Cloud Build)
• Responsible for pulling the container image from ghcr.io/timfanda35/simple-channel-notify and setting environment variables for credentials.
b. Docker Container Image
• Multi-stage build (from Dockerfile) that compiles the Go code and produces a minimal runtime image.
c. Go CLI Application (inside container)
• Entry point: main.go
• Command parser: reads the first CLI argument (telegram, linenotify, slack, discord, or hangoutschat) and --message flag.
• Strategy Dispatcher: maps the channel name to the appropriate handler.
• Channel Handlers: for each supported channel, a small module/function that reads its specific environment variable(s) and formats an HTTP request.
• HTTP Client: issues a POST (or GET) to the external API endpoint with authentication and payload.
d. External Channel Services
• Telegram Bot API
• LINE Notify API
• Google Hangouts Chat Incoming Webhook
• Slack Incoming Webhook
• Discord Execute Webhook
Relationships & Data Flow
1. Developer/CI pulls the container image from GitHub Container Registry.
2. Environment variables (e.g. NOTIFY_TELEGRAM_TOKEN, NOTIFY_TELEGRAM_CHAT_ID) are injected by the host or CI runner.
3. docker run ... simple-channel-notify <channel> --message="..." starts the Go CLI inside the container.
4. The CLI parses the arguments, picks the correct channel handler, constructs an HTTP request.
5. The HTTP client in the container issues the request to the external service’s REST API.
6. The channel service returns an HTTP status; the CLI exits.
Architectural Patterns & Design Principles
• Single-responsibility: each channel handler only knows how to talk to its own API.
• Strategy pattern: a central dispatcher routes calls to the correct handler based on the CLI argument.
• Containerized deployment: isolating runtime dependencies and simplifying distribution.
• Environment-driven configuration: all secrets and endpoints are injected as environment variables.
Detail Level
• Every channel as a distinct handler component.
• Where environment variables map into each handler.