Current conditions and 5-day forecasts for any location, right in chat.
The weather module provides real-time weather information and multi-day forecasts through the Pirate Weather API. It integrates with the eevee command router via NATS and responds to !weather and !forecast (alias: !fivecast) commands in any connected channel.
When a user provides a location, the module geocodes it via OpenStreetMap Nominatim, stores the coordinates in a local SQLite database, and fetches weather data. Subsequent requests without a location automatically reuse the stored location. Users can choose their preferred units (Fahrenheit, Celsius, or Kelvin) and toggle an obscure mode that hides their location string from responses.
Weather output is colorized on IRC using temperature, wind speed, humidity, and precipitation color ranges, with weather-condition emoji prepended to each part of the report.
- Current weather for any location (city, address, postal code, landmark, etc.)
- 5-day forecast via
!forecast/!fivecast - Per-user location storage in SQLite — set it once, query without arguments
- Configurable units: imperial (°F/mph), metric (°C/km/h), or Kelvin
- Obscure mode (
-oflag) hides the location string from responses - Per-user unit preference persistence
- Colorized output on IRC with weather-condition emoji
- Rate limited to prevent abuse
- Configurable through YAML configuration
This module is part of the eevee project and is not published independently. Install it as a workspace package:
# From the eevee project root
npm installTo build and run the module standalone for development:
cd weather
npm install
npm run devCreate a config.yaml file with the following structure:
# Rate limiting configuration
ratelimit:
mode: drop # "drop" or "queue"
level: user # "user" or "channel"
limit: 5 # max requests per interval
interval: 1m # time windowAll keys are optional — sensible defaults are provided by @eeveebot/libeevee.
| Variable | Description | Required |
|---|---|---|
PIRATE_WEATHER_API_KEY |
Pirate Weather API key (get one) | Yes |
MODULE_CONFIG_PATH |
Path to the YAML configuration file | No |
MODULE_DATA |
Directory for the SQLite database (weather.db) |
Yes |
NATS_HOST |
NATS server hostname | Yes |
NATS_TOKEN |
NATS authentication token | Yes |
Get current weather for a location. If no location is provided, the user's previously stored location is used.
| Flag | Description |
|---|---|
-c |
Use Celsius / metric units |
-f |
Use Fahrenheit / imperial units |
-k |
Use Kelvin |
-o |
Toggle obscure mode (hides location in response) |
Examples:
!weather New York
!weather 90210 -c
!weather -f
!weather Tokyo -o
Get a 5-day weather forecast. Alias: !fivecast. Accepts the same flags as !weather.
Examples:
!forecast London
!fivecast Berlin -c
!forecast -k
- Postal codes (US, Canada, UK, etc.) — e.g.
10001,M5A 1A1 - City names — e.g.
New York,London,Tokyo - Addresses — e.g.
123 Main St, Anytown, ST - Landmarks — e.g.
Statue of Liberty,Eiffel Tower
┌────────────┐ NATS ┌──────────────────┐ HTTP ┌─────────────────┐
│ eevee │───────────▶│ weather module │───────────▶│ Pirate Weather │
│ router │◀──────────│ (main.mts) │◀──────────│ API │
└────────────┘ NATS └──────┬───────────┘ HTTP └─────────────────┘
│ ┌─────────────────┐
├─────────────────────────▶│ OSM Nominatim │
│ geocode location │ (geocoding) │
│◀────────────────────────│ │
│ └─────────────────┘
│
┌─────┴──────┐
│ SQLite DB │
│ weather.db │
└────────────┘
- The router dispatches matched commands (
weather,forecast/fivecast) to the module over NATS. - The module parses flags and extracts the location string.
- If a location is provided, it is geocoded via OpenStreetMap Nominatim (with special handling for US ZIP and Canadian postal codes). Coordinates are stored in SQLite for the user.
- If no location is provided, the module looks up the user's previously stored coordinates.
- Weather or forecast data is fetched from the Pirate Weather API.
- The response is formatted with colorization and emoji, then sent back to the channel via NATS.
The module uses @eeveebot/libeevee for NATS connectivity, command registration, rate limiting, help registration, metrics, and graceful shutdown.
# Install dependencies
npm install
# Lint
npm test
# Build (lint + TypeScript compile)
npm run build
# Build and run
npm run devweather/
├── src/
│ ├── main.mts # Entry point, command handlers, DB, API logic
│ └── utils/
│ └── colorize.mts # Weather-condition emoji and IRC colorization
├── config.yaml # Rate limit configuration
├── package.json
└── tsconfig.json
Contributions are welcome! Please see the eevee contributing guide for details.
CC BY-NC-SA 4.0 — see LICENSE for the full text.