Clean up repeated names in name queries.
This commit is contained in:
parent
6b847ae566
commit
f43fdf5004
|
@ -33,14 +33,20 @@ class App(AppBase):
|
||||||
msg.respond("%s: %s (%s) to %s (%s)" % (
|
msg.respond("%s: %s (%s) to %s (%s)" % (
|
||||||
",".join(routes), origin_name, origin_area, dest_name, dest_area))
|
",".join(routes), origin_name, origin_area, dest_name, dest_area))
|
||||||
else:
|
else:
|
||||||
stops = ChaloBest.stops(q=msg.text)['features']
|
features = ChaloBest.stops(q=msg.text)['features']
|
||||||
if not stops:
|
if not features:
|
||||||
msg.respond("Sorry, we found no stops like '%s'." % msg.text)
|
msg.respond("Sorry, we found no stops like '%s'." % msg.text)
|
||||||
return
|
return
|
||||||
|
stops = []
|
||||||
|
for feat in features:
|
||||||
|
stop = feat['properties']
|
||||||
|
if stops and stop["official_name"] == stops[-1]["official_name"]:
|
||||||
|
stops[-1]["routes"] += ", " + stop["routes"]
|
||||||
|
else:
|
||||||
|
stops.append(stop)
|
||||||
response = STYLE["start"]
|
response = STYLE["start"]
|
||||||
for feature in stops:
|
for stop in stops:
|
||||||
stop = feature['properties']
|
match = stop["official_name"] + ": " + stop["routes"]
|
||||||
match = "%s: %s" % (stop['official_name'], 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