change style to semicolons; take areas out of name search
This commit is contained in:
parent
9cf0a58c49
commit
50c702e381
|
@ -5,11 +5,15 @@ import arrest
|
||||||
MAX_MSG_LEN = 160
|
MAX_MSG_LEN = 160
|
||||||
DIGIT = re.compile(r"\d{1,3}")
|
DIGIT = re.compile(r"\d{1,3}")
|
||||||
PUNCT = re.compile(r"[^\w\s]")
|
PUNCT = re.compile(r"[^\w\s]")
|
||||||
|
"""
|
||||||
STYLE = {
|
STYLE = {
|
||||||
"start": "-* ",
|
"start": "-* ",
|
||||||
"repeat": " -*- ",
|
"repeat": " -*- ",
|
||||||
"end": " *-"
|
"end": " *-"
|
||||||
}
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
STYLE = {"start": "", "repeat": "; ", "end": ""}
|
||||||
|
|
||||||
|
|
||||||
ChaloBest = arrest.Client("http://chalobest.in/1.0")
|
ChaloBest = arrest.Client("http://chalobest.in/1.0")
|
||||||
|
@ -23,11 +27,11 @@ class App(AppBase):
|
||||||
if not stops:
|
if not stops:
|
||||||
msg.respond("Sorry, we found no route marked '%s'." % msg.text)
|
msg.respond("Sorry, we found no route marked '%s'." % msg.text)
|
||||||
return
|
return
|
||||||
origin, destination = stops[0]['properties'], stops[-1]['properties']
|
origin, dest = stops[0]['properties'], stops[-1]['properties']
|
||||||
|
origin_name, dest_name = origin['display_name'], dest['display_name']
|
||||||
|
origin_area, dest_area = PUNCT.sub('', origin['area']), PUNCT.sub('', dest['area'])
|
||||||
msg.respond("%s: %s (%s) to %s (%s)" % (
|
msg.respond("%s: %s (%s) to %s (%s)" % (
|
||||||
",".join(routes),
|
",".join(routes), origin_name, origin_area, dest_name, dest_area))
|
||||||
origin['display_name'], origin['area'],
|
|
||||||
destination['display_name'], destination['area']))
|
|
||||||
else:
|
else:
|
||||||
stops = ChaloBest.stops(q=msg.text)['features']
|
stops = ChaloBest.stops(q=msg.text)['features']
|
||||||
if not stops:
|
if not stops:
|
||||||
|
@ -36,8 +40,7 @@ class App(AppBase):
|
||||||
response = STYLE["start"]
|
response = STYLE["start"]
|
||||||
for feature in stops:
|
for feature in stops:
|
||||||
stop = feature['properties']
|
stop = feature['properties']
|
||||||
area = PUNCT.sub('', stop['area'])
|
match = "%s: %s" % (stop['official_name'], stop['routes'])
|
||||||
match = "%s (%s): %s" % (stop['official_name'], area, stop['routes'])
|
|
||||||
if len(response) > len(STYLE["repeat"]): response += STYLE["repeat"]
|
if len(response) > len(STYLE["repeat"]): response += STYLE["repeat"]
|
||||||
response += match
|
response += match
|
||||||
if len(response) > MAX_MSG_LEN: break
|
if len(response) > MAX_MSG_LEN: break
|
||||||
|
|
Loading…
Reference in New Issue
Block a user