PyWX is a multi-component system providing weather information, emergency scanner alerts, and IRC bot functionality.
- IRC Bot: Interactive command-based bot responding to user queries
- Weather Information: Detailed weather data with custom formatting
- Scanner Alert Monitoring: Transcribes emergency scanner audio and sends notifications
- Web Interface: View and search emergency alerts and events
- Python 3.9+
- SQLite
- FFmpeg (for audio processing)
- API keys for:
- Google Maps (geocoding)
- OpenWeatherMap and/or ForecastIO (weather data)
- OpenAI (optional, for enhanced transcription)
-
Clone the repository:
git clone https://github.com/dferrante/pywx.git cd pywx -
Create a configuration file:
# Create data directory if it doesn't exist mkdir -p data # Copy the example config and edit as needed cp example_config.py data/local_config.json # Edit the config file with your API keys and settings
-
Install dependencies:
# Using pip pip install -r requirements.txt # OR using the provided uv lock file uv sync --locked
python pywx.pyflask --app webscanner run --debugpython transcribe_alerts.pyBuild and run the application with Docker:
docker build -t pywx .
docker run -it --mount type=bind,source=./data,target=/data -p 8080:443 pywxpythabot.py: Core IRC bot implementationpywx.py: Main application entry pointtranscribe_alerts.py: Scanner alert monitoring and transcriptionwebscanner.py: Flask web interfacemodules/: Command modules and extensionsregistry.py: Command registration systembase.py: Base classes for commandsweather.py: Weather data servicesalerts.py: Alert notification functionality- Various other service modules
data/: Configuration and database storagelocal_config.json: Local configurationalerts.db: SQLite database for scanner alertspywx.db: SQLite database for weather data
Create a new module or extend an existing one using the registry pattern:
from . import base
from .registry import register
@register(['mynewcommand'])
class MyNewCommand(base.Command):
template = "Response: {{ result }}"
def context(self, msg):
# Process the command
return {'result': 'Processed result'}Register tasks that run at specified intervals:
from .registry import register_periodic
@register_periodic('periodic_task', run_every=300) # Run every 5 minutes
class PeriodicTask(base.Command):
template = "Periodic update: {{ result }}"
def context(self, msg):
# Periodic task logic
return {'result': 'Updated data'}Templates use Jinja2 with custom IRC color filters:
template = "Weather: {{ temp|c('red') }} | Wind: {{ wind|c('aqua') }}"- Copy production database:
# Run the predefined task # This requires SSH access to the production server rm data/alerts.db* && scp mach5@colin.home:/etc/pywx/mefi/alerts* data/
[License Information]
- OpenAI Whisper for audio transcription
- Google Maps API for geocoding
- Weather data providers (OpenWeatherMap, ForecastIO)