mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-05-04 09:21:12 -05:00
Fix some spacing on output, alerts display, etc.
This commit is contained in:
parent
194ae52481
commit
ae28e4eab8
16
plugin.py
16
plugin.py
@ -319,6 +319,7 @@ class Weather(callbacks.Plugin):
|
|||||||
'wind':self.registryValue('showWind'),
|
'wind':self.registryValue('showWind'),
|
||||||
'updated':self.registryValue('showUpdated'),
|
'updated':self.registryValue('showUpdated'),
|
||||||
'forecast':False,
|
'forecast':False,
|
||||||
|
'humidity':False,
|
||||||
'strip':False,
|
'strip':False,
|
||||||
'uv':False,
|
'uv':False,
|
||||||
'visibility':False,
|
'visibility':False,
|
||||||
@ -336,6 +337,8 @@ class Weather(callbacks.Plugin):
|
|||||||
args['almanac'] = True
|
args['almanac'] = True
|
||||||
if key == 'pressure':
|
if key == 'pressure':
|
||||||
args['pressure'] = True
|
args['pressure'] = True
|
||||||
|
if key == 'humidity':
|
||||||
|
args['humidity'] = True
|
||||||
if key == 'wind':
|
if key == 'wind':
|
||||||
args['wind'] = True
|
args['wind'] = True
|
||||||
if key == 'uv':
|
if key == 'uv':
|
||||||
@ -531,17 +534,23 @@ class Weather(callbacks.Plugin):
|
|||||||
# handle alerts
|
# handle alerts
|
||||||
if args['alerts']: # only look for alerts if there.
|
if args['alerts']: # only look for alerts if there.
|
||||||
if data['alerts']: # alerts is a list. it can also be empty.
|
if data['alerts']: # alerts is a list. it can also be empty.
|
||||||
outdata['alerts'] = data['alerts'][:300] # limit chars to 300.
|
outdata['alerts'] = data['alerts']['message'] # need to do some formatting below.
|
||||||
|
outdata['alerts'] = outdata['alerts'].replace('\n', ' ')[:300] # \n->' ' and max 300 chars.
|
||||||
|
outdata['alerts'] = utils.str.normalizeWhitespace(outdata['alerts']) # fix pesky double whitespacing.
|
||||||
else: # no alerts found (empty).
|
else: # no alerts found (empty).
|
||||||
outdata['alerts'] = "No alerts."
|
outdata['alerts'] = "No alerts."
|
||||||
|
|
||||||
# OUTPUT.
|
# OUTPUT.
|
||||||
# we go step-by-step to build the proper string. ° u" \u00B0C"
|
# we go step-by-step to build the proper string. ° u" \u00B0C"
|
||||||
output = "Weather for {0} :: {1}".format(self._bold(outdata['location'].encode('utf-8')), outdata['weather'].encode('utf-8'))
|
output = "{0} :: {1} ::".format(self._bold(outdata['location'].encode('utf-8')), outdata['weather'].encode('utf-8'))
|
||||||
if args['nocolortemp']: # don't color temp.
|
if args['nocolortemp']: # don't color temp.
|
||||||
output += " {0}".format(outdata['temp'])
|
output += " {0}".format(outdata['temp'])
|
||||||
else: # colored temperature.
|
else: # colored temperature.
|
||||||
output += " {0}".format(self._temp(outdata['temp']))
|
output += " {0}".format(self._temp(outdata['temp']))
|
||||||
|
if args['humidity']: # display humidity?
|
||||||
|
output += " (Humidity: {0}) ".format(outdata['humidity'])
|
||||||
|
else:
|
||||||
|
output += " "
|
||||||
# windchill/heatindex are conditional on season but test with startswith to see what to include
|
# windchill/heatindex are conditional on season but test with startswith to see what to include
|
||||||
if not outdata['windchill'].startswith("NA"): # windchill.
|
if not outdata['windchill'].startswith("NA"): # windchill.
|
||||||
if args['nocolortemp']: # don't color windchill.
|
if args['nocolortemp']: # don't color windchill.
|
||||||
@ -584,7 +593,7 @@ class Weather(callbacks.Plugin):
|
|||||||
irc.reply(output)
|
irc.reply(output)
|
||||||
# handle astronomy if --astronomy is given.
|
# handle astronomy if --astronomy is given.
|
||||||
if args['astronomy']:
|
if args['astronomy']:
|
||||||
output = "{0} Moon illum: {1}% Moon age: {2}d Sunrise: {3} Sunset: {4} Length of Day: {5}".format(\
|
output = "{0} :: Moon illum: {1}% Moon age: {2}d Sunrise: {3} Sunset: {4} Length of Day: {5}".format(\
|
||||||
self._bu('Astronomy:'), outdata['moonilluminated'], outdata['moonage'],outdata['sunrise'],\
|
self._bu('Astronomy:'), outdata['moonilluminated'], outdata['moonage'],outdata['sunrise'],\
|
||||||
outdata['sunset'], outdata['lengthofday'])
|
outdata['sunset'], outdata['lengthofday'])
|
||||||
# irc output now.
|
# irc output now.
|
||||||
@ -613,6 +622,7 @@ class Weather(callbacks.Plugin):
|
|||||||
'uv':'',
|
'uv':'',
|
||||||
'visibility':'',
|
'visibility':'',
|
||||||
'dewpoint':'',
|
'dewpoint':'',
|
||||||
|
'humidity':'',
|
||||||
'metric':'',
|
'metric':'',
|
||||||
'nocolortemp':'',
|
'nocolortemp':'',
|
||||||
'help':''}), optional('text')])
|
'help':''}), optional('text')])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user