diff --git a/nemubot/bot.py b/nemubot/bot.py index c9c0e66..28df8ce 100644 --- a/nemubot/bot.py +++ b/nemubot/bot.py @@ -296,7 +296,7 @@ class Bot(threading.Thread): # Register the event in the source module if module_src is not None: - module_src.__nemubot_context__.events.append(evt.id) + module_src.__nemubot_context__.events.append((evt, evt.id)) evt.module_src = module_src logger.info("New event registered in %d position: %s", i, t) @@ -326,10 +326,10 @@ class Bot(threading.Thread): id = evt if len(self.events) > 0 and id == self.events[0].id: + if module_src is not None: + module_src.__nemubot_context__.events.remove((self.events[0], id)) self.events.remove(self.events[0]) self._update_event_timer() - if module_src is not None: - module_src.__nemubot_context__.events.remove(id) return True for evt in self.events: @@ -337,7 +337,7 @@ class Bot(threading.Thread): self.events.remove(evt) if module_src is not None: - module_src.__nemubot_context__.events.remove(evt.id) + module_src.__nemubot_context__.events.remove((evt, evt.id)) return True return False diff --git a/nemubot/consumer.py b/nemubot/consumer.py index 2765aff..3a58219 100644 --- a/nemubot/consumer.py +++ b/nemubot/consumer.py @@ -94,7 +94,7 @@ class EventConsumer: # Or remove reference of this event elif (hasattr(self.evt, "module_src") and self.evt.module_src is not None): - self.evt.module_src.__nemubot_context__.events.remove(self.evt.id) + self.evt.module_src.__nemubot_context__.events.remove((self.evt, self.evt.id)) diff --git a/nemubot/modulecontext.py b/nemubot/modulecontext.py index d6291c4..f39934c 100644 --- a/nemubot/modulecontext.py +++ b/nemubot/modulecontext.py @@ -85,7 +85,7 @@ class _ModuleContext: self.del_hook(h, *s) # Remove registered events - for evt, eid, module_src in self.events: + for evt, eid in self.events: self.del_event(evt) self.save()