Skip to content

Update Google Calendar integration #856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Apr 7, 2025
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
352a475
google-calendar: Update requirements.txt dependencies.
Niloth-p Feb 18, 2025
81387d1
google-calendar: Replace deprecated oauth2client library.
Niloth-p Feb 18, 2025
e722e90
google-calendar: Update outdated send_message parameters.
Niloth-p Feb 18, 2025
dfe38f1
google-calendar: Narrow the permission scope to calendar events.
Niloth-p Feb 18, 2025
4b9dbb3
google-calendar: Use a constant for the tokens filename.
Niloth-p Feb 18, 2025
5b8b440
google-calendar: Fix usage of term "credentials", replace with "tokens".
Niloth-p Feb 18, 2025
2bb1b8a
google-calendar: Update command usage help.
Niloth-p Feb 18, 2025
f30a571
google-calendar: Clean up `add_argument` parameters.
Niloth-p Feb 18, 2025
f18399c
google-calendar: Add --provision argument to install dependencies.
Niloth-p Feb 18, 2025
07810c5
google-calendar: Add error handling for missing client secret file.
Niloth-p Feb 18, 2025
abf6415
google-calendar: Stop printing events unless the verbose option is set.
Niloth-p Feb 18, 2025
8b2b9dd
google-calendar: Add error handling for send_message.
Niloth-p Feb 18, 2025
06db61b
google-calendar: Improve CLIENT_SECRET_FILE occurrences.
Niloth-p Feb 18, 2025
445ee9b
google-calendar: Call get-google-credentials script internally.
Niloth-p Feb 18, 2025
8b7c536
google-calendar: Use current user's email id for send_message.
Niloth-p Feb 18, 2025
6436918
google-calendar: Use a bot to send direct messages to the bot owner.
Niloth-p Feb 18, 2025
5d3ff39
google-calendar: Support sending reminders to channels.
Niloth-p Feb 18, 2025
4c56d9b
google-calendar: Support manual authorization using auth code.
Niloth-p Feb 18, 2025
441dce9
google-calendar: Log writing to the tokens file.
Niloth-p Feb 18, 2025
c004199
google-calendar: Add options --client-secret-file and --tokens-file.
Niloth-p Feb 18, 2025
9ced7b8
google-calendar: Support loading options from the zuliprc.
Niloth-p Feb 19, 2025
e38a8e6
google-calendar: Fix type of event id, switch from int to str.
Niloth-p Feb 19, 2025
da6d896
google-calendar: Send each reminder as its own message.
Niloth-p Feb 19, 2025
8794800
google-calendar: Add TypedDict and string conversion function for event.
Niloth-p Feb 19, 2025
b468931
google-calendar: Generalize the datetime parsing for event fields.
Niloth-p Feb 19, 2025
078d307
google-calendar: Display more Event info in reminder messages.
Niloth-p Feb 19, 2025
974863e
google-calendar: Support user customization of the message template.
Niloth-p Feb 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions zulip/integrations/google/google-calendar
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ sent: Set[Tuple[int, datetime.datetime]] = set()

sys.path.append(os.path.dirname(__file__))

usage = r"""google-calendar --user EMAIL [--interval MINUTES] [--calendar CALENDAR_ID]
usage = r"""google-calendar [--interval MINUTES] [--calendar CALENDAR_ID]

This integration can be used to send Zulip messages as reminders for upcoming events from your Google Calendar.

Expand Down Expand Up @@ -69,9 +69,6 @@ except ImportError:
)
sys.exit(1)


if not options.zulip_email:
parser.error("You must specify --user")
if options.verbose:
logging.getLogger().setLevel(logging.INFO)

Expand Down Expand Up @@ -166,7 +163,7 @@ def send_reminders() -> Optional[None]:
message = "Reminder:\n\n" + "\n".join("* " + m for m in messages)

result = zulip_client.send_message(
{"type": "direct", "to": [options.zulip_email], "content": message}
{"type": "direct", "to": [zulip_client.get_profile()["email"]], "content": message}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The zulip_client.get_profile()["email"]] call should probably be at the beginning, not done every time one sends -- at least if we use a user ID rather than email. (I've not checked if later commits do that already).

Copy link
Member

@timabbott timabbott Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This moves around, but I think we might want to add a tweak to do ["id"] instead -- and also probably a to parameter to just set a user ID who it should DM, like you have for the channel/topic parameters.

(Maybe there's some precedent in zulip/examples for how to name it)

)
if result["result"] != "success":
logging.error("Error sending zulip message: %s: %s", result.get("code"), result.get("msg"))
Expand Down