support utc offset

This commit is contained in:
Nils Büchner 2024-09-14 12:21:19 +02:00
parent 1b63230850
commit c8908b4b5c

View file

@ -272,7 +272,7 @@ class Ubottu(Plugin):
if command_name == 'time' or command_name == 'utc': if command_name == 'time' or command_name == 'utc':
if command_name == 'utc': if command_name == 'utc':
city = 'London' city = 'UTC'
else: else:
city = " ".join(args) city = " ".join(args)
api_url = 'http://127.0.0.1:8000/factoids/api/citytime/' + city + '/?format=json' api_url = 'http://127.0.0.1:8000/factoids/api/citytime/' + city + '/?format=json'
@ -280,7 +280,10 @@ class Ubottu(Plugin):
if resp and resp.status == 200: if resp and resp.status == 200:
data = await resp.json() data = await resp.json()
if data: if data:
await evt.respond('The current time in ' + data['location'] + ' is ' + data['local_time']) if city == 'UTC':
await evt.respond('The current UTC time is ' + data['local_time'])
else:
await evt.respond('The current time in ' + data['location'] + ' is ' + data['local_time'] + ' ' + data['utc_offset'])
if command_name == 'lpbug' or command_name == 'lp': if command_name == 'lpbug' or command_name == 'lp':
if len(args) == 1: if len(args) == 1: