Files
claude-code/skills/gmail/scripts/check_urgent.py
OpenCode Test 05d1fa41ba Add hooks and refactor skills to use resources pattern
Phase 1 of plugin-structure refactor:

- Add hooks/hooks.json for SessionStart automation
- Refactor gmail skill:
  - Extract inline scripts to scripts/check_unread.py, check_urgent.py, search.py
  - Add references/query-patterns.md for query documentation
  - Simplify SKILL.md to reference scripts instead of inline code
- Add gcal/scripts/agenda.py for direct calendar access
- Make all scripts executable

This follows the "Skill with Bundled Resources" pattern from
developing-claude-code-plugins best practices.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 02:33:10 -08:00

39 lines
1.2 KiB
Python
Executable File

#!/usr/bin/env python3
"""Check for urgent unread emails."""
import os
# Set credentials path
os.environ.setdefault('GMAIL_CREDENTIALS_PATH', os.path.expanduser('~/.gmail-mcp/credentials.json'))
from gmail_mcp.utils.GCP.gmail_auth import get_gmail_service
def main():
service = get_gmail_service()
results = service.users().messages().list(
userId='me',
q='is:unread newer_than:3d (subject:urgent OR subject:asap OR subject:"action required" OR is:important)',
maxResults=15
).execute()
messages = results.get('messages', [])
if not messages:
print("No urgent emails found")
return
print(f"Found {len(messages)} urgent email(s):\n")
for msg in messages:
detail = service.users().messages().get(
userId='me',
id=msg['id'],
format='metadata',
metadataHeaders=['From', 'Subject', 'Date']
).execute()
headers = {h['name']: h['value'] for h in detail['payload']['headers']}
print(f"From: {headers.get('From', 'Unknown')}")
print(f"Subject: {headers.get('Subject', '(no subject)')}")
print(f"Date: {headers.get('Date', 'Unknown')}")
print("---")
if __name__ == '__main__':
main()