"""Other handler â Telegram notification only."""
import logging
from typing import Dict, Any
from shared.notify import TelegramNotifier
logger = logging.getLogger(name)
class OtherHandler:
"""Handle uncategorized emails: just notify."""
def __init__(self, telegram: TelegramNotifier):
self.telegram = telegram
async def process(
self,
subject: str,
body: str,
sender: str,
received_at: str
) -> Dict[str, Any]:
"""Process uncategorized email.
Returns:
Dict with notification_sent
"""
result = {
"type": "other",
"notification_sent": False,
"errors": []
}
# Send simple notification
try:
await self._notify(subject, sender)
result["notification_sent"] = True
logger.info(f"Other email notification sent: {subject[:50]}...")
except Exception as e:
logger.error(f"Failed to notify about other email: {e}")
result["errors"].append(f"Notify failed: {e}")
return result
async def _notify(self, subject: str, sender: str) -> None:
"""Send Telegram notification."""
msg = f"đ§ <b>New Email</b>\n\n"
msg += f"<b>{subject}</b>\n"
msg += f"From: {sender}\n\n"
msg += f"âšī¸ Could not auto-process â check email directly"
await self.telegram.to_family(msg)