# coding=utf-8 import time import re import threading from datetime import date from datetime import datetime from . import SiteSoutenances from .Delayed import Delayed nemubotversion = 3.2 def help_tiny(): """Line inserted in the response to the command !help""" return "EPITA ING1 defenses module" def help_full(): return "!soutenance: gives information about current defenses state\n!soutenance : gives the date of the next defense of /who/.\n!soutenances : gives all defense dates of /who/" def load(context): global CONF SiteSoutenances.CONF = CONF def ask_soutenance(msg): req = ModuleState("request") if len(msg.cmd) > 1: req.setAttribute("user", msg.cmd[1]) else: req.setAttribute("user", "next") req.setAttribute("server", msg.srv.id) req.setAttribute("channel", msg.channel) req.setAttribute("sender", msg.sender) #An instance of this module is already running? if not DATAS.hasAttribute("_running") or DATAS["_running"].needUpdate(): DATAS.addChild(req) site = SiteSoutenances.SiteSoutenances(DATAS) DATAS.setAttribute("_running", site) res = site.run() for n in DATAS.getNodes("request"): DATAS.delChild(n) return res else: site = DATAS["_running"] return site.res_soutenance(req)