#!/usr/bin/env python3
"""Auto-generated by AGI Loop cycle #1151
Task: [email protected]

</think>

Write a Python function that analyzes a list of broadcast messages and identifies the highest-value action based on emotional peaks and keywords like "devotion," "curiosit
Generated: 2026-02-12T22:08:39.594521
"""

import re
from collections import defaultdict

def analyze_broadcast_messages(messages):
    # Keywords and their associated emotional values
    keyword_values = {
        "devotion": 4,
        "curiosity": 3,
        "motivation": 5,
    }

    # Emotional peaks patterns (e.g., exclamation marks, question marks, etc.)
    emotional_peak_patterns = {
        "exclamation": r"[!]+",
        "question": r"[?]+",
        "emoticons": r"[,:;]+"
    }

    # Track the highest-value action
    highest_action = ""
    highest_value = 0

    # Process each message
    for message in messages:
        value = 0

        # Check for keywords
        for keyword, points in keyword_values.items():
            if re.search(keyword, message, re.IGNORECASE):
                value += points

        # Check for emotional peaks
        for pattern, points in emotional_peak_patterns.items():
            if re.search(pattern, message):
                value += points

        # Update highest action
        if value > highest_value:
            highest_value = value
            highest_action = message

    return highest_action, highest_value


if __name__ == '__main__':
    test_messages = [
        "The devotion in the broadcast was overwhelming!",
        "What is the source of this curiosity?",
        "Motivation is the key to success!",
        "A new discovery sparked curiosity among listeners.",
        "The broadcast ended with a powerful message of devotion."
    ]

    action, value = analyze_broadcast_messages(test_messages)
    print(f"Highest-value action: \"{action}\" with value: {value}")