From 76b9d6f0ce6e65c7ce29e373240ef61daa63f8f7 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Tue, 9 Nov 2021 23:38:31 +0100 Subject: [PATCH] Geography: Properly handle missing timezones --- plugins/Geography/plugin.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/Geography/plugin.py b/plugins/Geography/plugin.py index 07c75122a..95c66acaa 100644 --- a/plugins/Geography/plugin.py +++ b/plugins/Geography/plugin.py @@ -90,6 +90,9 @@ class Geography(callbacks.Plugin): # Get the timezone object (and handle various errors) timezone = timezone_from_uri(irc, uri) + if timezone is None: + continue + # Get the local time now = datetime.datetime.now(tz=timezone) @@ -102,6 +105,10 @@ class Geography(callbacks.Plugin): return + irc.error( + _("Could not find the timezone of this location."), Raise=True + ) + @wrap(["text"]) def timezone(self, irc, msg, args, query): """ @@ -123,6 +130,9 @@ class Geography(callbacks.Plugin): # Get the timezone object (and handle various errors) timezone = timezone_from_uri(irc, uri) + if timezone is None: + continue + # Extract a human-friendly name, depending on the type of # the timezone object: if hasattr(timezone, "key"):