Don't add new event after main thread stop
This commit is contained in:
parent
92895a7b1d
commit
26515677b8
1 changed files with 8 additions and 0 deletions
|
@ -187,6 +187,10 @@ class Bot(threading.Thread):
|
||||||
module_src -- The module to which the event is attached to
|
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
|
import uuid
|
||||||
|
|
||||||
# Generate the event id if no given
|
# Generate the event id if no given
|
||||||
|
@ -357,6 +361,10 @@ class Bot(threading.Thread):
|
||||||
old one before"""
|
old one before"""
|
||||||
module_name = module.__spec__.name if hasattr(module, "__spec__") else module.__name__
|
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
|
# Check if the module already exists
|
||||||
if module_name in self.modules:
|
if module_name in self.modules:
|
||||||
self.unload_module(module_name)
|
self.unload_module(module_name)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue