File size: 2,500 Bytes
86ffe15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# main.py
#!/usr/bin/env python3
"""
Entry point for the Complaint Tracker Suite.
Runs the scheduler in the background and provides a CLI menu.
"""
import sys
import time
import logging
from datetime import datetime
from config import Config
from pdf_parser import extract_text_from_pdf, parse_email_thread, get_days_without_account
from email_watcher import check_for_new_fos_email
from notifier import send_telegram_message, send_email_notification
from scheduler import start_scheduler

logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

def print_banner():
    print("""
    ╔══════════════════════════════════════════════╗
    β•‘   πŸ”₯ Complaint Tracker Suite – v2.0         β•‘
    β•‘   Monitoring your FOS case 24/7             β•‘
    β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
    """)

def generate_initial_report():
    """Produce a full report from the PDF and display it."""
    text = extract_text_from_pdf()
    emails = parse_email_thread(text)
    days = get_days_without_account(text)
    
    print(f"\nπŸ“Š REPORT – {datetime.now().strftime('%Y-%m-%d %H:%M')}")
    print(f"Days without a functional account: {days}")
    print(f"Total emails in thread: {len(emails)}")
    if emails:
        last = emails[-1]
        print(f"Last email from: {last['from']} on {last['date']}")
        print(f"Subject: {last['subject']}")
        print("Preview:", last['body'][:200].replace('\n', ' '), "...")
    else:
        print("No emails found.")
    
    # Also send a startup notification via Telegram
    send_telegram_message(f"πŸš€ Complaint Tracker started.\nDays without account: {days}")

def main():
    print_banner()
    
    # 1. Run initial report
    generate_initial_report()
    
    # 2. Send a daily summary to landlord immediately (optional)
    # You can also let the scheduler handle it.
    
    # 3. Start the background scheduler
    scheduler = start_scheduler()
    
    # 4. Keep the main thread alive, or provide a simple CLI menu
    print("\nPress Ctrl+C to stop.")
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        print("\nShutting down scheduler...")
        scheduler.shutdown()
        print("Goodbye.")
        sys.exit(0)

if __name__ == "__main__":
    main()