diff --git a/modules/cristal.py b/modules/cristal.py new file mode 100644 index 0000000..fb674ea --- /dev/null +++ b/modules/cristal.py @@ -0,0 +1,64 @@ +# coding=utf-8 + +from tools import web + +nemubotversion = 3.3 + +def help_tiny (): + """Line inserted in the response to the command !help""" + return "Gets information about Cristal missions" + +def help_full (): + return "!cristal [id|name] : gives information about id Cristal mission." + + +def get_all_missions(): + print (web.getContent(CONF.getNode("server")["url"])) + response = web.getXML(CONF.getNode("server")["url"]) + print (CONF.getNode("server")["url"]) + if response is not None: + return response.getNodes("mission") + else: + return None + +def get_mission(id=None, name=None, people=None): + missions = get_all_missions() + if missions is not None: + for m in missions.childs: + if id is not None and m.getFirstNode("id").getContent() == id: + return m + elif (name is not None or name in m.getFirstNode("title").getContent()) and (people is not None or people in m.getFirstNode("contact").getContent()): + return m + return None + +def cmd_cristal(msg): + if len(msg.cmds) > 1: + srch = msg.cmds[1] + else: + srch = "" + + res = Response(msg.sender, channel=msg.channel, nomore="Je n'ai pas d'autre mission à afficher") + + try: + id=int(srch) + name="" + except: + id=None + name=srch + + missions = get_all_missions() + if missions is not None: + print (missions) + for m in missions: + print (m) + idm = m.getFirstNode("id").getContent() + crs = m.getFirstNode("title").getContent() + contact = m.getFirstNode("contact").getDate() + updated = m.getFirstNode("updated").getDate() + content = m.getFirstNode("content").getContent() + + res.append_message(msg, crs + " ; contacter : " + contact + " : " + content) + else: + res.append_message("Aucune mission n'a été trouvée") + + return res diff --git a/modules/cristal.xml b/modules/cristal.xml new file mode 100644 index 0000000..3e83d90 --- /dev/null +++ b/modules/cristal.xml @@ -0,0 +1,5 @@ + + + + +