mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 02:49:27 +01:00
Geography: Properly handle missing timezones
This commit is contained in:
parent
93a407a9ac
commit
76b9d6f0ce
@ -90,6 +90,9 @@ class Geography(callbacks.Plugin):
|
|||||||
# Get the timezone object (and handle various errors)
|
# Get the timezone object (and handle various errors)
|
||||||
timezone = timezone_from_uri(irc, uri)
|
timezone = timezone_from_uri(irc, uri)
|
||||||
|
|
||||||
|
if timezone is None:
|
||||||
|
continue
|
||||||
|
|
||||||
# Get the local time
|
# Get the local time
|
||||||
now = datetime.datetime.now(tz=timezone)
|
now = datetime.datetime.now(tz=timezone)
|
||||||
|
|
||||||
@ -102,6 +105,10 @@ class Geography(callbacks.Plugin):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
irc.error(
|
||||||
|
_("Could not find the timezone of this location."), Raise=True
|
||||||
|
)
|
||||||
|
|
||||||
@wrap(["text"])
|
@wrap(["text"])
|
||||||
def timezone(self, irc, msg, args, query):
|
def timezone(self, irc, msg, args, query):
|
||||||
"""<location name to search>
|
"""<location name to search>
|
||||||
@ -123,6 +130,9 @@ class Geography(callbacks.Plugin):
|
|||||||
# Get the timezone object (and handle various errors)
|
# Get the timezone object (and handle various errors)
|
||||||
timezone = timezone_from_uri(irc, uri)
|
timezone = timezone_from_uri(irc, uri)
|
||||||
|
|
||||||
|
if timezone is None:
|
||||||
|
continue
|
||||||
|
|
||||||
# Extract a human-friendly name, depending on the type of
|
# Extract a human-friendly name, depending on the type of
|
||||||
# the timezone object:
|
# the timezone object:
|
||||||
if hasattr(timezone, "key"):
|
if hasattr(timezone, "key"):
|
||||||
|
Loading…
Reference in New Issue
Block a user