Skip to content

Commit f8497d3

Browse files
committed
separate skip_zoom
1 parent f315e1a commit f8497d3

File tree

3 files changed

+97
-61
lines changed

3 files changed

+97
-61
lines changed

.github/ACDbot/scripts/handle_issue.py

Lines changed: 93 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,18 @@ def check_existing_youtube_streams(call_series, mapping):
115115

116116
return None
117117

118+
def extract_already_zoom_meeting(issue_body):
119+
"""
120+
Extracts information about whether a Zoom meeting ID already exists.
121+
Returns a boolean indicating if Zoom creation should be skipped.
122+
"""
123+
zoom_pattern = r"Already a Zoom meeting ID\s*:\s*(true|false)"
124+
125+
zoom_match = re.search(zoom_pattern, issue_body, re.IGNORECASE)
126+
skip_zoom_creation = zoom_match and zoom_match.group(1).lower() == 'true'
127+
128+
return skip_zoom_creation
129+
118130
def handle_github_issue(issue_number: int, repo_name: str):
119131
"""
120132
Fetches the specified GitHub issue, extracts its title and body,
@@ -149,13 +161,38 @@ def handle_github_issue(issue_number: int, repo_name: str):
149161
# Check for existing YouTube streams for this call series
150162
existing_youtube_streams = check_existing_youtube_streams(call_series, mapping)
151163

152-
# Extract whether the meeting is already on the Ethereum Calendar
153-
existing_series_event = next((entry for entry in mapping.values() if entry.get("call_series") == call_series), None)
154-
if existing_series_event:
155-
already_on_calendar = True
156-
comment_lines.append("\n**Note:** Meeting already exists for this call series. Skipping event creation.")
157-
else:
158-
already_on_calendar = extract_already_on_calendar(issue_body)
164+
# --- Start Refactor: Separate Zoom and GCal skip logic ---
165+
# Extract whether to skip Zoom creation
166+
skip_zoom_creation = extract_already_zoom_meeting(issue_body)
167+
# Extract whether to skip Google Calendar creation
168+
skip_gcal_creation = extract_already_on_calendar(issue_body)
169+
170+
# Automatic skip logic based on existing series (OVERRIDES issue input)
171+
existing_series_entry_for_zoom = None # Keep track if we reuse for Zoom
172+
if is_recurring and call_series:
173+
# Find the most recent entry for this call series with a meeting_id
174+
series_entries = [
175+
entry for entry in mapping.values()
176+
if entry.get("call_series") == call_series and "meeting_id" in entry
177+
]
178+
if series_entries:
179+
series_entries.sort(key=lambda e: e.get("issue_number", 0), reverse=True)
180+
existing_series_entry_for_zoom = series_entries[0]
181+
if not skip_zoom_creation:
182+
print(f"[INFO] Overriding 'Already a Zoom meeting ID: false' because an existing meeting for series '{call_series}' was found in mapping.")
183+
skip_zoom_creation = True # Force skip Zoom creation if series exists
184+
# Also force skip GCal if reusing Zoom series (assume they go together)
185+
if not skip_gcal_creation:
186+
print(f"[INFO] Overriding 'Already on Ethereum Calendar: false' because an existing meeting for series '{call_series}' was found.")
187+
skip_gcal_creation = True
188+
189+
# Add comments based on final skip decisions
190+
if skip_zoom_creation and not existing_series_entry_for_zoom: # Skipped via issue input, not series reuse
191+
comment_lines.append("\n**Note:** Zoom meeting creation skipped as requested in issue.")
192+
if skip_gcal_creation and not existing_series_entry_for_zoom: # Skipped via issue input, not series reuse
193+
comment_lines.append("\n**Note:** Google Calendar event creation skipped as requested in issue.")
194+
# Note for series reuse is added within the Zoom processing block later
195+
# --- End Refactor ---
159196

160197
# 2. Check for existing topic_id using the mapping instead of comments
161198
topic_id = None
@@ -301,36 +338,31 @@ def handle_github_issue(issue_number: int, repo_name: str):
301338
# 1. Parse time and duration first
302339
start_time, duration = parse_issue_for_time(issue_body)
303340

304-
# 2. Check if it's a recurring series and if we already have a meeting ID for it
305-
existing_series_entry = None
306-
if is_recurring and call_series:
307-
# Find the most recent entry for this call series
308-
series_entries = [
309-
entry for entry in mapping.values()
310-
if entry.get("call_series") == call_series and "meeting_id" in entry
311-
]
312-
if series_entries:
313-
# Sort by issue number descending to get the latest entry
314-
series_entries.sort(key=lambda e: e.get("issue_number", 0), reverse=True)
315-
existing_series_entry = series_entries[0]
316-
317-
if existing_series_entry:
318-
# Reuse existing meeting ID and link from the series
319-
zoom_id = existing_series_entry["meeting_id"]
320-
join_url = existing_series_entry.get("zoom_link", "Link not found in mapping")
321-
reusing_series_meeting = True
322-
print(f"[DEBUG] Reusing existing Zoom meeting {zoom_id} for call series '{call_series}'")
323-
comment_lines.append(f"\n**Zoom Meeting:** Reusing existing meeting for series '{call_series.upper()}' ({zoom_id})")
324-
comment_lines.append(f"- Join URL: {join_url}")
325-
# We don't need to call Zoom API, meeting_updated remains False unless GCal/YT changes it
341+
# 2. Check if we should skip Zoom API calls entirely
342+
if skip_zoom_creation:
343+
print("[DEBUG] Skipping Zoom meeting creation/update based on issue input or existing series.")
344+
if existing_series_entry_for_zoom:
345+
# Reuse existing meeting ID and link from the series
346+
zoom_id = existing_series_entry_for_zoom["meeting_id"]
347+
join_url = existing_series_entry_for_zoom.get("zoom_link", "Link not found in mapping")
348+
reusing_series_meeting = True # Mark that we reused
349+
print(f"[DEBUG] Reusing existing Zoom meeting {zoom_id} for call series '{call_series}'")
350+
comment_lines.append(f"\n**Zoom Meeting:** Reusing existing meeting for series '{call_series.upper()}' ({zoom_id})")
351+
comment_lines.append(f"- Join URL: {join_url}")
352+
else:
353+
# Skipped via issue input, need placeholder
354+
print("[DEBUG] Zoom creation skipped via issue input. Using placeholder Zoom ID.")
355+
zoom_id = f"placeholder-skipped-{issue.number}"
356+
join_url = "Zoom creation skipped via issue input"
326357
else:
327-
# Not reusing, proceed with create/update logic based on issue number
328-
print(f"[DEBUG] No existing meeting found for series '{call_series}' or not a recurring series call. Checking for meeting tied to issue #{issue_number}.")
358+
# Proceed with Zoom creation/update logic (as skip_zoom_creation is False)
359+
# No need to check for series again, just check for existing meeting tied to this issue
360+
print(f"[DEBUG] Proceeding with Zoom creation/update for issue #{issue_number}.")
329361
existing_item_for_issue = next(
330362
((m_id, entry) for m_id, entry in mapping.items() if entry.get("issue_number") == issue.number),
331-
None
332-
)
333-
363+
None
364+
)
365+
334366
if existing_item_for_issue:
335367
# Update existing meeting tied to this specific issue number
336368
existing_zoom_meeting_id, existing_entry = existing_item_for_issue
@@ -412,8 +444,8 @@ def handle_github_issue(issue_number: int, repo_name: str):
412444
meeting_id = str(zoom_id) # Ensure it's a string for mapping key
413445

414446
# Check if YT streams were created/reused
415-
if reusing_series_meeting and existing_series_entry and "youtube_streams" in existing_series_entry:
416-
youtube_streams = existing_series_entry["youtube_streams"]
447+
if reusing_series_meeting and existing_series_entry_for_zoom and "youtube_streams" in existing_series_entry_for_zoom:
448+
youtube_streams = existing_series_entry_for_zoom["youtube_streams"]
417449
# We might have already added the comment for existing streams earlier
418450
# Let the existing logic handle adding YT stream comments if needed
419451
else:
@@ -509,29 +541,31 @@ def handle_github_issue(issue_number: int, repo_name: str):
509541
calendar_id = "[email protected]"
510542
calendar_description = f"Issue: {issue.html_url}"
511543
event_link = None
512-
event_result = None # Define event_result
513-
514-
if reusing_series_meeting:
515-
print("[DEBUG] Reusing series meeting, skipping Google Calendar API calls.")
516-
# Optionally try to find the GCal link from the series mapping entry
517-
if existing_series_entry and existing_series_entry.get("calendar_event_id"):
518-
gcal_event_id = existing_series_entry.get("calendar_event_id")
519-
# Construct a potential link (may not be perfect)
520-
event_link = f"https://calendar.google.com/calendar/event?eid={gcal_event_id}" # Simplified link
521-
comment_lines.append("\n**Calendar Event:** Reusing existing event for series.")
522-
if event_link:
523-
comment_lines.append(f"- [Approximate Google Calendar Link]({event_link})")
524-
else:
525-
comment_lines.append("\n**Calendar Event:** Reusing existing event for series (Link not found in mapping).")
526-
elif already_on_calendar:
527-
print(f"[DEBUG] Meeting is already on Ethereum Calendar (or duplicate series), skipping calendar creation")
528-
comment_lines.append("\n**Calendar Event**")
529-
comment_lines.append("- Meeting already on Ethereum Calendar or duplicate series.")
544+
event_id = None # Initialize event_id
545+
event_result = None # Initialize event_result
546+
547+
# Use the separate skip_gcal_creation flag
548+
if skip_gcal_creation:
549+
print("[DEBUG] Skipping Google Calendar event creation/update based on issue input or existing series.")
550+
if reusing_series_meeting: # Check if we reused Zoom series
551+
if existing_series_entry_for_zoom and existing_series_entry_for_zoom.get("calendar_event_id"):
552+
gcal_event_id_from_series = existing_series_entry_for_zoom.get("calendar_event_id")
553+
# Construct a potential link (may not be perfect)
554+
event_link = f"https://calendar.google.com/calendar/event?eid={gcal_event_id_from_series}" # Simplified link
555+
comment_lines.append("\n**Calendar Event:** Reusing existing event for series.")
556+
if event_link:
557+
comment_lines.append(f"- [Approximate Google Calendar Link]({event_link})")
558+
# Store the reused event ID for mapping
559+
event_id = gcal_event_id_from_series
560+
else:
561+
comment_lines.append("\n**Calendar Event:** Reusing existing event for series (Link/ID not found in mapping).")
562+
# else: GCal skipped via issue input, no comment needed as it was added earlier
530563
else:
531-
# Proceed with GCal creation/update logic ONLY if not reusing and not already marked as on calendar
532-
# ... (insert existing GCal create/update logic here, ensuring it uses meeting_id) ...
533-
# This logic might set meeting_updated = True
534-
pass # Placeholder for the existing complex GCal logic block
564+
# Proceed with GCal creation/update logic (skip_gcal_creation is False)
565+
print(f"[DEBUG] Proceeding with Google Calendar creation/update for issue #{issue_number}.")
566+
# ... (Insert existing GCal create/update logic HERE) ...
567+
# This logic should set event_id, event_link, event_result, meeting_updated.
568+
pass # Placeholder for the existing GCal logic block
535569

536570
# --- Mapping Update Logic ---
537571
print(f"[DEBUG] Preparing to update mapping for meeting ID: {meeting_id}")
@@ -561,7 +595,7 @@ def handle_github_issue(issue_number: int, repo_name: str):
561595
# Add youtube_streams if they were generated or reused
562596
"youtube_streams": youtube_streams if 'youtube_streams' in locals() and youtube_streams else current_mapping_entry.get("youtube_streams"),
563597
# Add calendar event ID if it was determined
564-
"calendar_event_id": locals().get("event_id") or current_mapping_entry.get("calendar_event_id"),
598+
"calendar_event_id": event_id,
565599
# Add telegram message ID if it was determined
566600
"telegram_message_id": locals().get("message_id") or current_mapping_entry.get("telegram_message_id"),
567601
# Add the discourse post flag for YT streams if reusing

.github/ISSUE_TEMPLATE/onetime-protocol-call.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ assignees: ''
1111

1212
- Date and time in UTC in format `month, day, year, time` with link to savvytime.com or timeanddate.com. E.g. [Jan 16, 2025, 14:00 UTC](https://savvytime.com/converter/utc/jan-16-2025/2pm)
1313
- Duration in minutes : XXX
14-
- Already on Ethereum Calendar : false # Set to true if this meeting is already on the Ethereum public calendar
14+
- Already a Zoom meeting ID : false # Set to true if this meeting is already on the auto recording Ethereum zoom (will not create a zoom ID if true)
15+
- Already on Ethereum Calendar : false # Set to true if this meeting is already on the Ethereum public calendar (will not create calendar event)
1516
- Other optional resources
1617

1718
# Agenda

.github/ISSUE_TEMPLATE/recurring-protocol-calls.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ assignees: ''
1414
- Recurring meeting : true
1515
- Call series : (e.g ACDC ; ACDE; testing call)
1616
- Occurrence rate : weekly # Options: weekly, bi-weekly, monthly
17-
- Already on Ethereum Calendar : false # Set to true if this meeting is already on the Ethereum public calendar (will not create zoom and calendar event)
17+
- Already a Zoom meeting ID : false # Set to true if this meeting is already on the auto recording Ethereum zoom (will not create a zoom ID if true)
18+
- Already on Ethereum Calendar : false # Set to true if this meeting is already on the Ethereum public calendar (will not create calendar event)
1819
- Need YouTube stream links : true # Set to false if you don't want YouTube stream links created
1920
- Other optional resources
2021

0 commit comments

Comments
 (0)