This script monitors RSS feeds for specific news alerts, processes them with OpenAI's API, and sends notifications via Pushover or Telegram. It ensures that duplicate news items are ignored and provides detailed logging for each step of the process.
- Fetches and parses RSS feeds.
- Detects duplicate news items using MD5 hashes.
- Processes news items using OpenAI's API with custom prompts.
- Sends notifications via Pushover for relevant alerts.
- Handles graceful shutdown via signal handling.
- Configurable via environment variables.
- Python 3.6+
- Required Python libraries:
dotenv
requests
openai
- External APIs:
- OpenAI API
- Pushover API
-
Clone this repository:
git clone <repository-url> cd <repository-name>
-
Create a
.env
file in the project root with the following variables:EMAIL_FROM=<your-email-address> EMAIL_TO=<space-separated-list-of-email-addresses> RSS_URLS=<space-separated-list-of-rss-urls> PUSHOVER_TOKEN=<your-pushover-api-token> PUSHOVER_USER=<your-pushover-user-key> OPENAI_API_KEY=<your-openai-api-key> PROMPT_FILE=<path-to-prompt-file> SLEEP_DELAY=600 SMTP_SERVER=<your-smtp-server> SMTP_PORT=<your-smtp-port> SMTP_LOGIN=<your-smtp-username> SMTP_PASSWORD=<your-smtp-password> TELEGRAM_BOT_TOKEN=<your-telegram-bot-token> TELEGRAM_CHANNEL_ID=<your-telegram-channel-id> TMPDIR=/tmp
Adjust
SLEEP_DELAY
(in seconds) andTMPDIR
as needed. -
Modify the
prompt.txt
file with your OpenAI query template.
Run the script using:
./war-alert.sh
The script logs to stdout
with detailed information about each step, including any errors encountered during API calls or processing.
Relevant alerts are sent as Pushover notifications with the title "War Alert" and the justification from the OpenAI response.
- Ensure the OpenAI and Pushover credentials are valid.
- Adjust RSS feed URLs and prompt content to match your requirements.
- Temporary files for tracking processed items are stored in the directory specified by the
TMPDIR
environment variable.
This project is licensed under the MIT License. See the LICENSE
file for details.
Feel free to open issues or submit pull requests to improve this script.