Fill up the response buffer on name queries.
This commit is contained in:
parent
d04f61ab78
commit
357600e1a8
|
@ -2,6 +2,7 @@ from rapidsms.apps.base import AppBase
|
||||||
import re
|
import re
|
||||||
import arrest
|
import arrest
|
||||||
|
|
||||||
|
MAX_MSG_LEN = 160
|
||||||
DIGIT = re.compile(r"\d{1,3}")
|
DIGIT = re.compile(r"\d{1,3}")
|
||||||
chalobest = arrest.Client("http://chalobest.in/1.0")
|
chalobest = arrest.Client("http://chalobest.in/1.0")
|
||||||
|
|
||||||
|
@ -16,6 +17,14 @@ class App(AppBase):
|
||||||
origin['display_name'], origin['area'],
|
origin['display_name'], origin['area'],
|
||||||
destination['display_name'], destination['area']))
|
destination['display_name'], destination['area']))
|
||||||
else:
|
else:
|
||||||
stops = chalobest.stops(q=msg.text)
|
stops = chalobest.stops(q=msg.text)['features']
|
||||||
stop = stops['features'][0]['properties']
|
response = ""
|
||||||
msg.respond("%s (%s): %s" % (stop['official_name'], stop['area'], stop['routes']))
|
for feature in stops:
|
||||||
|
stop = feature['properties']
|
||||||
|
match = "%s (%s): %s" % (stop['official_name'], stop['area'], stop['routes'])
|
||||||
|
if len(response) + len(match) + 1 < MAX_MSG_LEN:
|
||||||
|
if response: response += ";"
|
||||||
|
response += match
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
msg.respond(response)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user