New module bonneannee
This commit is contained in:
parent
14b9a82a2b
commit
01e12970fb
51
modules/bonneannee.py
Normal file
51
modules/bonneannee.py
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
# coding=utf-8
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
nemubotversion = 3.3
|
||||||
|
|
||||||
|
def load(context):
|
||||||
|
yr = datetime.today().year
|
||||||
|
yrn = datetime.today().year + 1
|
||||||
|
|
||||||
|
d = datetime(yrn, 1, 1, 0, 0, 0) - datetime.now()
|
||||||
|
# d = datetime(yr, 12, 31, 19, 34, 0) - datetime.now()
|
||||||
|
add_event(ModuleEvent(intervalle=0, offset=d.total_seconds(), call=bonneannee))
|
||||||
|
|
||||||
|
from hooks import Hook
|
||||||
|
add_hook("cmd_rgxp", Hook(cmd_timetoyear, data=yrn, regexp="[0-9]{4}"))
|
||||||
|
add_hook("cmd_hook", Hook(cmd_newyear, str(yrn), yrn))
|
||||||
|
add_hook("cmd_hook", Hook(cmd_newyear, "ny", yrn))
|
||||||
|
add_hook("cmd_hook", Hook(cmd_newyear, "newyear", yrn))
|
||||||
|
add_hook("cmd_hook", Hook(cmd_newyear, "new-year", yrn))
|
||||||
|
add_hook("cmd_hook", Hook(cmd_newyear, "new year", yrn))
|
||||||
|
|
||||||
|
def bonneannee():
|
||||||
|
txt = "Bonne année %d !" % datetime.today().year
|
||||||
|
print (txt)
|
||||||
|
send_response("localhost:2771", Response(None, txt, "#epitagueule"))
|
||||||
|
send_response("localhost:2771", Response(None, txt, "#yaka"))
|
||||||
|
send_response("localhost:2771", Response(None, txt, "#epita2014"))
|
||||||
|
send_response("localhost:2771", Response(None, txt, "#ykar"))
|
||||||
|
send_response("localhost:2771", Response(None, txt, "#ordissimo"))
|
||||||
|
send_response("localhost:2771", Response(None, txt, "#42sh"))
|
||||||
|
send_response("localhost:2771", Response(None, txt, "#nemubot"))
|
||||||
|
|
||||||
|
def cmd_newyear(msg, yr):
|
||||||
|
return Response(msg.sender,
|
||||||
|
msg.countdown_format(datetime(yr, 1, 1, 0, 0, 1),
|
||||||
|
"Il reste %s avant la nouvelle année.",
|
||||||
|
"Nous faisons déjà la fête depuis %s !"),
|
||||||
|
channel=msg.channel)
|
||||||
|
|
||||||
|
def cmd_timetoyear(msg, cur):
|
||||||
|
yr = int(msg.cmds[0])
|
||||||
|
|
||||||
|
if yr == cur:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return Response(msg.sender,
|
||||||
|
msg.countdown_format(datetime(yr, 1, 1, 0, 0, 1),
|
||||||
|
"Il reste %s avant %d." % ("%s", yr),
|
||||||
|
"Le premier janvier %d est passé depuis %s !" % (yr, "%s")),
|
||||||
|
channel=msg.channel)
|
@ -11,7 +11,4 @@
|
|||||||
<message type="cmd" name="goûter" call="cmd_gouter" />
|
<message type="cmd" name="goûter" call="cmd_gouter" />
|
||||||
<message type="cmd" name="week-end" call="cmd_we" />
|
<message type="cmd" name="week-end" call="cmd_we" />
|
||||||
<message type="cmd" name="weekend" call="cmd_we" />
|
<message type="cmd" name="weekend" call="cmd_we" />
|
||||||
<message type="cmd" name="new-year" call="cmd_newyear" />
|
|
||||||
<message type="cmd" name="newyear" call="cmd_newyear" />
|
|
||||||
<message type="cmd" name="ny" call="cmd_newyear" />
|
|
||||||
</nemubotmodule>
|
</nemubotmodule>
|
||||||
|
@ -66,13 +66,6 @@ def cmd_we(msg):
|
|||||||
"Youhou, on est en week-end depuis %s."),
|
"Youhou, on est en week-end depuis %s."),
|
||||||
channel=msg.channel)
|
channel=msg.channel)
|
||||||
|
|
||||||
def cmd_newyear(msg):
|
|
||||||
return Response(msg.sender,
|
|
||||||
msg.countdown_format(datetime(datetime.today().year + 1, 1, 1, 0, 0, 1),
|
|
||||||
"Il reste %s avant la nouvelle année.",
|
|
||||||
"Nous faisons déjà la fête depuis %s !"),
|
|
||||||
channel=msg.channel)
|
|
||||||
|
|
||||||
def cmd_vacances(msg):
|
def cmd_vacances(msg):
|
||||||
return Response(msg.sender,
|
return Response(msg.sender,
|
||||||
msg.countdown_format(datetime(2013, 7, 30, 18, 0, 1),
|
msg.countdown_format(datetime(2013, 7, 30, 18, 0, 1),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user