diff --git a/mattermost_bot.py b/mattermost_bot.py index 56588db..b67a629 100755 --- a/mattermost_bot.py +++ b/mattermost_bot.py @@ -10,7 +10,7 @@ from pytz import utc CHANNEL = os.environ["SUNBOT_ANNOUNCE_CHANNEL"] AUTHORIZATION = "Bearer " + os.environ["SUNBOT_ANNOUNCE_MATTERMOST_TOKEN"] -URL = os.environ["SUNBOT_ANNOUNCE_MATTERMOST_API_ENDPOINT"] + "/posts" +URL = os.environ["SUNBOT_ANNOUNCE_MATTERMOST_API_ENDPOINT"] + "/v4/posts" LOCATION = astral.LocationInfo("Gent", "Belgium", "Europe/Brussels", 51.05, 3.72) @@ -24,7 +24,8 @@ def post(message): "message": message } print("Posting " + str(payload), flush=True) - requests.post(URL, json=payload, headers={"Authorization": AUTHORIZATION}) + r = requests.post(URL, json=payload, headers={"Authorization": AUTHORIZATION}) + r.raise_for_status() def format_in(diff):