nemubot/modules/soutenance/__init__.py

50 lines
1.3 KiB
Python
Raw Normal View History

2012-04-12 01:06:17 +00:00
# coding=utf-8
import time
import re
import threading
2012-04-12 01:06:17 +00:00
from datetime import date
from datetime import datetime
2012-10-14 23:52:32 +00:00
from . import SiteSoutenances
from .Delayed import Delayed
2012-04-12 01:06:17 +00:00
2012-10-14 23:52:32 +00:00
nemubotversion = 3.2
def help_tiny():
2012-04-12 01:06:17 +00:00
"""Line inserted in the response to the command !help"""
return "EPITA ING1 defenses module"
2012-04-12 01:06:17 +00:00
def help_full():
return "!soutenance: gives information about current defenses state\n!soutenance <who>: gives the date of the next defense of /who/.\n!soutenances <who>: gives all defense dates of /who/"
2012-04-12 01:06:17 +00:00
2012-10-14 23:52:32 +00:00
def load(context):
global CONF
SiteSoutenances.CONF = CONF
2012-04-12 01:06:17 +00:00
2012-10-14 23:52:32 +00:00
def ask_soutenance(msg):
req = ModuleState("request")
if len(msg.cmd) > 1:
req.setAttribute("user", msg.cmd[1])
2012-04-12 01:06:17 +00:00
else:
2012-10-14 23:52:32 +00:00
req.setAttribute("user", "next")
req.setAttribute("server", msg.srv.id)
req.setAttribute("channel", msg.channel)
req.setAttribute("sender", msg.sender)
2012-10-14 23:52:32 +00:00
#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)
2012-10-14 23:52:32 +00:00
res = site.run()
2012-05-03 14:16:38 +00:00
2012-10-14 23:52:32 +00:00
for n in DATAS.getNodes("request"):
DATAS.delChild(n)
2012-05-03 14:16:38 +00:00
2012-10-14 23:52:32 +00:00
return res
2012-05-03 14:16:38 +00:00
else:
2012-10-14 23:52:32 +00:00
site = DATAS["_running"]
return site.res_soutenance(req)