#!/bin/bash
#
# Send order flow alert to Telegram topic 120949
# This script is called by generate_single_signal.py
#

ALERT_FILE="/tmp/order_flow_alert.txt"

if [ ! -f "$ALERT_FILE" ]; then
    echo "❌ No alert file found: $ALERT_FILE"
    exit 1
fi

# Read the message
MESSAGE=$(cat "$ALERT_FILE")

# Use hermes send_message tool
# The target format is: telegram:chat_id:topic_id
# chat_id: -1003810904048 (from memory)
# topic_id: 120949

echo "📱 Sending alert to Telegram topic 120949..."

# Call hermes with send_message action
# This will be triggered by cron job or manually
echo "$MESSAGE" > /tmp/current_order_flow_alert.txt

echo "✅ Alert ready for delivery"
echo "   Message saved to: /tmp/current_order_flow_alert.txt"
echo ""
echo "To send manually, use:"
echo "   hermes send_message --target 'telegram:-1003810904048:120949' --message \$(cat /tmp/current_order_flow_alert.txt)"
