Don't add new event after main thread stop

This commit is contained in:
nemunaire 2015-06-24 19:50:23 +02:00
parent 92895a7b1d
commit 26515677b8

View file

@ -187,6 +187,10 @@ class Bot(threading.Thread):
module_src -- The module to which the event is attached to
"""
if hasattr(self, "stop") and self.stop:
logger.warn("The bot is stopped, can't register new events")
return
import uuid
# Generate the event id if no given
@ -357,6 +361,10 @@ class Bot(threading.Thread):
old one before"""
module_name = module.__spec__.name if hasattr(module, "__spec__") else module.__name__
if hasattr(self, "stop") and self.stop:
logger.warn("The bot is stopped, can't register new modules")
return
# Check if the module already exists
if module_name in self.modules:
self.unload_module(module_name)