Documentation: - Add commands/README.md documenting all slash commands - Add skills/README.md documenting skill structure and patterns - Add .claude-plugin/marketplace.json for local dev testing Hooks: - Add PreCompact hook to remind about context preservation - Update hooks/README.md with new hook GCal improvements: - Add scripts/next_event.py for single event lookup - Update SKILL.md with simplified format and allowed-tools: Read 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
62 lines
1.6 KiB
Python
Executable File
62 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Get the next upcoming calendar event."""
|
|
import os
|
|
from datetime import datetime
|
|
|
|
# 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_calendar_service
|
|
|
|
|
|
def format_event(event):
|
|
"""Format a single event for display."""
|
|
start = event['start'].get('dateTime', event['start'].get('date'))
|
|
|
|
if 'T' in start:
|
|
start_dt = datetime.fromisoformat(start.replace('Z', '+00:00'))
|
|
time_str = start_dt.strftime('%I:%M %p').lstrip('0')
|
|
date_str = start_dt.strftime('%A, %b %d')
|
|
else:
|
|
time_str = "All day"
|
|
date_str = start
|
|
|
|
summary = event.get('summary', '(No title)')
|
|
location = event.get('location', '')
|
|
|
|
print(f"📅 Next Event — {date_str}")
|
|
print()
|
|
print(f" {time_str} {summary}")
|
|
if location:
|
|
print(f" 📍 {location}")
|
|
|
|
# Show attendees if available
|
|
attendees = event.get('attendees', [])
|
|
if attendees:
|
|
print(f" 👥 {len(attendees)} attendees")
|
|
|
|
|
|
def main():
|
|
service = get_calendar_service()
|
|
now = datetime.utcnow().isoformat() + 'Z'
|
|
|
|
events_result = service.events().list(
|
|
calendarId='primary',
|
|
timeMin=now,
|
|
maxResults=1,
|
|
singleEvents=True,
|
|
orderBy='startTime'
|
|
).execute()
|
|
|
|
events = events_result.get('items', [])
|
|
|
|
if not events:
|
|
print("📅 No upcoming events")
|
|
return
|
|
|
|
format_event(events[0])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|