Skip to content

Commit 078d307

Browse files
google-calendar: Display more Event info in reminder messages.
Added the following Event fields to the message template: - event end time - description - link to event in Google Calendar - location of event, if any - link to Google Meet, if any Co-authored-by: Vedant Joshi <[email protected]>
1 parent b468931 commit 078d307

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

zulip/integrations/google/google-calendar

+24-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ class GoogleCalendarOptions:
4646
class Event(TypedDict):
4747
id: str
4848
start: datetime.datetime
49+
end: datetime.datetime
50+
html_link: str
51+
# The following fields are optional, and may not be present in all events.
4952
summary: str
53+
description: str
54+
location: str
55+
hangout_link: str
5056

5157

5258
# Our cached view of the calendar, updated periodically.
@@ -234,16 +240,30 @@ def populate_events() -> Optional[None]:
234240
{
235241
"id": event["id"],
236242
"start": get_start_or_end(event, "start"),
243+
"end": get_start_or_end(event, "end"),
237244
"summary": event.get("summary", "(No Title)"),
245+
"description": event.get("description", ""),
246+
"html_link": event["htmlLink"],
247+
"location": event.get("location", ""),
248+
"hangout_link": event.get("hangoutLink", ""),
238249
}
239250
)
240251

241252

242253
def construct_message_from_event(event: Event) -> str:
243-
if event["start"].hour == 0 and event["start"].minute == 0:
244-
message = f"{event["summary"]} is today."
245-
else:
246-
message = "{} starts at {}".format(event["summary"], event["start"].strftime("%H:%M"))
254+
time_period = (
255+
"today"
256+
if event["start"].hour == 0 and event["start"].minute == 0
257+
else f"""scheduled from {event["start"].strftime('%H:%M')} to {event["end"].strftime('%H:%M')}"""
258+
)
259+
location = f""", at {event["location"]},""" if event["location"] else ""
260+
description = f"""\n> {event["description"]}\n""" if event["description"] else ""
261+
google_meet_link = (
262+
f"""\n[Join call]({event["hangout_link"]}).""" if event["hangout_link"] else ""
263+
)
264+
265+
message = f"""[{event["summary"]}]({event["html_link"]}){location} is {time_period}.{description}{google_meet_link}"""
266+
247267
return message
248268

249269

0 commit comments

Comments
 (0)