Now the public transportation module uses Response

This commit is contained in:
Number 23 2012-09-01 00:07:58 +02:00
parent aef010e466
commit 3d9fa8a565

View File

@ -35,31 +35,30 @@ def extractInformation(msg,
station = stationname station = stationname
stops += time+" direction "+direction+"; " stops += time+" direction "+direction+"; "
if len(stops) > 0: if len(stops) > 0:
msg.send_chn("%s: Prochains passages du %s ligne %s à l'arrêt %s: %s" % return Response(msg.sender, "Prochains passages du %s ligne %s à l'arrêt %s: %s" %
(msg.nick, transport, line, stationname, stops)) (transport, line, stationname, stops), msg.channel, msg.nick)
else: else:
msg.send_chn("%s: La station `%s' ne semble pas exister sur le %s ligne %s." return Response(msg.sender, "La station `%s' ne semble pas exister sur le %s ligne %s."
% (msg.nick, station, transport, line)) % (station, transport, line), msg.channel, msg.nick)
else: else:
stations = ratp.getAllStations(transport, line) stations = ratp.getAllStations(transport, line)
if len(stations) > 0: if len(stations) > 0:
s = "" s = ""
for name in stations: for name in stations:
s += name + "; " s += name + "; "
msg.send_chn("%s: Stations: %s." % (msg.nick, s)) return Response(msg.sender, "Stations: %s." % s, msg.channel, msg.nick)
return 0 return 0
else: else:
msg.send_chn("%s: Aucune station trouvée." % msg.nick) return Response(msg.sender, "Aucune station trouvée.", msg.channel, msg.nick)
def ask_ratp(msg): def ask_ratp(msg):
"""Hook entry from !ratp""" """Hook entry from !ratp"""
global DATAS global DATAS
if len(msg.cmd) == 4: if len(msg.cmd) == 4:
extractInformation(msg, msg.cmd[1], msg.cmd[2], msg.cmd[3]) return extractInformation(msg, msg.cmd[1], msg.cmd[2], msg.cmd[3])
return True
elif len(msg.cmd) == 3: elif len(msg.cmd) == 3:
extractInformation(msg, msg.cmd[1], msg.cmd[2], None) return extractInformation(msg, msg.cmd[1], msg.cmd[2], None)
else: else:
msg.send_chn("%s: Mauvais usage, merci de spécifier un type de transport et une ligne, ou de consulter l'aide du module." % msg.nick) return Response(msg.sender, "Mauvais usage, merci de spécifier un type de transport et une ligne, ou de consulter l'aide du module.", msg.channel, msg.nick)
return False return False