diff --git a/docker-compose.jsonnet b/docker-compose.jsonnet index bdba589..61814d0 100644 --- a/docker-compose.jsonnet +++ b/docker-compose.jsonnet @@ -273,7 +273,7 @@ // Creds for accessing the schedule google sheet schedule_sheet_id: "", schedule_sheet_name: "All-Everything", - google_credentials: import "./google_creds.json", + google_credentials_file: "./google_creds.json", // Map from group names to zulip internal ids groups: { Sheeter: 16, @@ -726,8 +726,9 @@ url: $.zulip_url, start_time: $.bustime_start, schedule: "/schedule", + google_credentials_file: "/creds.json", }, $.schedulebot.args) + { - volumes: ["%s:/schedule" % $.schedulebot.schedule_path], + volumes: ["%s:/creds.json" % $.schedulebot.google_credentials_file], }, [if $.enabled.tootbot then "tootbot"]: diff --git a/zulip_bots/zulip_bots/schedulebot.py b/zulip_bots/zulip_bots/schedulebot.py index e09eb3e..9d12844 100644 --- a/zulip_bots/zulip_bots/schedulebot.py +++ b/zulip_bots/zulip_bots/schedulebot.py @@ -2,6 +2,7 @@ import gevent.monkey gevent.monkey.patch_all() +import json import logging import time from calendar import timegm @@ -241,10 +242,11 @@ def main(conf_file, hour=-1, no_groups=False, stream="General", no_mentions=Fals start_time: Time of the first hour, as UTC timestamp string schedule_sheet_id: Google Sheet ID schedule_sheet_name: Google Sheet tab name - google_credentials: (With Read access to schedule_sheet_id) - client_id - client_secret - refresh_token + google_credentials_file: (With Read access to schedule_sheet_id) + Path to json file containing at least: + client_id + client_secret + refresh_token members: NAME: USER_ID groups: @@ -260,10 +262,12 @@ def main(conf_file, hour=-1, no_groups=False, stream="General", no_mentions=Fals send_auth = config.get("send_user", config["api_user"]) send_client = Client(config["url"], send_auth["email"], send_auth["api_key"]) group_ids = config["groups"] + with open(config["google_credentials_file"]) as f: + sheets_creds = json.load(f) sheets_client = Sheets( - config["google_credentials"]["client_id"], - config["google_credentials"]["client_secret"], - config["google_credentials"]["refresh_token"], + sheets_creds["client_id"], + sheets_creds["client_secret"], + sheets_creds["refresh_token"], ) reload_schedule = lambda: parse_schedule( sheets_client,