ID are keept when an event is not finished
This commit is contained in:
parent
642c5ef502
commit
af3ec01734
9
bot.py
9
bot.py
@ -59,14 +59,17 @@ class Bot:
|
|||||||
self.msg_thrd_size = -1
|
self.msg_thrd_size = -1
|
||||||
|
|
||||||
|
|
||||||
def add_event(self, evt):
|
def add_event(self, evt, eid=None):
|
||||||
"""Register an event and return its identifiant for futur update"""
|
"""Register an event and return its identifiant for futur update"""
|
||||||
|
if eid is None:
|
||||||
# Find an ID
|
# Find an ID
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
evt.id = "%d%c%d%d%c%d%d%c%d" % (now.year, ID_letters[now.microsecond % 52],
|
evt.id = "%d%c%d%d%c%d%d%c%d" % (now.year, ID_letters[now.microsecond % 52],
|
||||||
now.month, now.day, ID_letters[now.microsecond % 42],
|
now.month, now.day, ID_letters[now.microsecond % 42],
|
||||||
now.hour, now.minute, ID_letters[now.microsecond % 32],
|
now.hour, now.minute, ID_letters[now.microsecond % 32],
|
||||||
now.second)
|
now.second)
|
||||||
|
else:
|
||||||
|
evt.id = eid
|
||||||
|
|
||||||
# Add the event in place
|
# Add the event in place
|
||||||
t = evt.current
|
t = evt.current
|
||||||
@ -78,6 +81,8 @@ class Bot:
|
|||||||
self.events.insert(i + 1, evt)
|
self.events.insert(i + 1, evt)
|
||||||
if i == -1:
|
if i == -1:
|
||||||
self.update_timer()
|
self.update_timer()
|
||||||
|
if len(self.events) <= 0 or self.events[i+1] != evt:
|
||||||
|
return None
|
||||||
|
|
||||||
return evt.id
|
return evt.id
|
||||||
|
|
||||||
@ -119,7 +124,7 @@ class Bot:
|
|||||||
evt = self.events.pop(0)
|
evt = self.events.pop(0)
|
||||||
evt.launch_check()
|
evt.launch_check()
|
||||||
if evt.next is not None:
|
if evt.next is not None:
|
||||||
self.add_event(evt)
|
self.add_event(evt, evt.id)
|
||||||
self.update_timer()
|
self.update_timer()
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,10 +33,12 @@ def load(context):
|
|||||||
if DATAS.index[evt].hasAttribute("end"):
|
if DATAS.index[evt].hasAttribute("end"):
|
||||||
event = ModuleEvent(call=fini, call_data=dict(strend=DATAS.index[evt]))
|
event = ModuleEvent(call=fini, call_data=dict(strend=DATAS.index[evt]))
|
||||||
event.end = DATAS.index[evt].getDate("end")
|
event.end = DATAS.index[evt].getDate("end")
|
||||||
DATAS.index[evt]["id"] = context.add_event(event)
|
idt = context.add_event(event)
|
||||||
|
if idt is not None:
|
||||||
|
DATAS.index[evt]["id"] = idt
|
||||||
|
|
||||||
|
|
||||||
def fini(strend):
|
def fini(d, strend):
|
||||||
for server in CONTEXT.servers.keys():
|
for server in CONTEXT.servers.keys():
|
||||||
if not strend.hasAttribute("server") or server == strend["server"]:
|
if not strend.hasAttribute("server") or server == strend["server"]:
|
||||||
if strend["channel"] == CONTEXT.servers[server].nick:
|
if strend["channel"] == CONTEXT.servers[server].nick:
|
||||||
|
Loading…
Reference in New Issue
Block a user