Working copy of v3.1

This commit is contained in:
Némunaire 2012-11-04 17:09:54 +01:00
commit e2fbdecc59
7 changed files with 95 additions and 495 deletions

View file

@ -6,13 +6,12 @@ from xml.dom.minidom import parseString
from module_state import ModuleState
nemubotversion = 3.0
nemubotversion = 3.1
def load():
global DATAS
DATAS.setIndex("name", "station")
def help_tiny ():
"""Line inserted in the response to the command !help"""
return "Gets information about velib stations"
@ -54,21 +53,20 @@ def station_status(msg, station):
else:
msg.send_chn("%s: station %s inconnue." % (msg.nick, station))
def parseanswer(msg):
def checkStation(msg):
global DATAS
if msg.cmd[0] == "velib":
if len(msg.cmd) > 5:
msg.send_chn("%s: Demande-moi moins de stations à la fois." % msg.nick)
elif len(msg.cmd) > 1:
for station in msg.cmd[1:]:
if re.match("^[0-9]{4,5}$", station):
station_status(msg, station)
elif station in DATAS.index:
station_status(msg, DATAS.index[station]["number"])
else:
msg.send_chn("%s: numéro de station invalide." % (msg.nick))
else:
msg.send_chn("%s: Pour quelle station ?" % msg.nick)
return True
else:
if len(msg.cmd) > 5:
msg.send_chn("%s: Demande-moi moins de stations à la fois." % msg.nick)
return False
elif len(msg.cmd) > 1:
for station in msg.cmd[1:]:
if re.match("^[0-9]{4,5}$", station):
station_status(msg, station)
elif station in DATAS.index:
station_status(msg, DATAS.index[station]["number"])
else:
msg.send_chn("%s: numéro de station invalide." % (msg.nick))
else:
msg.send_chn("%s: Pour quelle station ?" % msg.nick)
return False
return True

View file

@ -1,4 +1,14 @@
<?xml version="1.0" ?>
<nemubotmodule name="velib">
<help>Gets information about velib stations</help>
<command name="velib" call="checkStation">
<usage>!velib /number/ ...</usage>
<help>gives available bikes and slots at the station /number/.</help>
</command>
<event name="velib" call="nothing">
</event>
<server ip="www.velib.paris.fr" url="/service/stationdetails/paris/" />
</nemubotmodule>
</nemubotmodule>