T support for /Moon (fixes #175)

This commit is contained in:
Igor Chubin 2019-02-01 12:14:01 +01:00
parent 067be9c319
commit 4bbbdaca7b
2 changed files with 8 additions and 2 deletions

View File

@ -207,7 +207,10 @@ def get_wetter(location, ip, html=False, lang=None, query=None, location_name=No
return open(filename).read()
def get_moon(location, html=False, lang=None):
def get_moon(location, html=False, lang=None, query=None):
if query is None:
query = {}
date = None
if '@' in location:
date = location[location.index('@')+1:]
@ -228,6 +231,9 @@ def get_moon(location, html=False, lang=None):
p = Popen(cmd, stdout=PIPE, stderr=PIPE, env=env)
stdout = p.communicate()[0]
if query.get('no-terminal', False):
stdout = remove_ansi(stdout)
if html:
p = Popen(["bash", ANSI2HTML, "--palette=solarized", "--bg=dark"], stdin=PIPE, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate(stdout)

View File

@ -230,7 +230,7 @@ def wttr(location, request):
return response
if location == 'moon' or location.startswith('moon@'):
output = get_moon(location, html=html_output, lang=lang)
output = get_moon(location, html=html_output, lang=lang, query=query)
else:
output = get_wetter(location, ip_addr,
html=html_output,