Improve reloading on config change
This commit is contained in:
parent
e6d13afcca
commit
cceb0e3ea3
@ -40,13 +40,15 @@ class FjerkroaBot(commands.Bot):
|
||||
|
||||
@classmethod
|
||||
def load_config(self, config_file: str = "config.toml"):
|
||||
logging.info(f"config file {config_file} changed, reloading.")
|
||||
with open(config_file, encoding='utf-8') as file:
|
||||
return toml.load(file)
|
||||
|
||||
def on_config_file_modified(self, event):
|
||||
if event.src_path == self.config_file:
|
||||
self.config = self.load_config(self.config_file)
|
||||
new_config = self.load_config(self.config_file)
|
||||
if repr(new_config) != repr(self.config):
|
||||
logging.info(f"config file {self.config_file} changed, reloading.")
|
||||
self.config = new_config
|
||||
self.airesponder.config = self.config
|
||||
for responder in self.aichannels.values():
|
||||
responder.config = self.config
|
||||
|
||||
Loading…
Reference in New Issue
Block a user