Skip to main content
scripts/notify.py sends a Telegram message using the bot credentials from .env. Used by Claude agents and automation scripts to report when long-running tasks finish.

Usage

python scripts/notify.py "Your message here"
python scripts/notify.py "Optimization done: WR=78.5% PF=2.43 MaxDD=1.8% Score=21.34"

Requirements

.env must contain:
TELEGRAM_TOKEN=<bot_token>
TELEGRAM_CHAT_ID=<chat_id>

Getting Telegram credentials

  1. Message @BotFather on Telegram → /newbot → copy the token
  2. Start a conversation with your new bot, then run:
curl "https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates"
Find chat.id in the response. That is your TELEGRAM_CHAT_ID.

Testing

python scripts/notify.py "NOVOSKY notification test"
If the message arrives in Telegram, the credentials are correct.

Using in scripts

import subprocess
subprocess.run(["python", "scripts/notify.py", f"WR={wr:.1%} Score={score:.2f}"])
Or import directly:
import os, requests
from dotenv import load_dotenv
load_dotenv()
token = os.environ["TELEGRAM_TOKEN"]
chat_id = os.environ["TELEGRAM_CHAT_ID"]
requests.post(f"https://api.telegram.org/bot{token}/sendMessage",
              json={"chat_id": chat_id, "text": "your message"})