bot: clean

This commit is contained in:
dece 2020-11-03 17:28:40 +01:00
parent 1e38901c11
commit ed6c0e47dd

View file

@ -20,7 +20,7 @@ class Bot(irc.client.SimpleIRCClient, Logger):
self.logger = logger self.logger = logger
self.plugins = [] self.plugins = []
self.values = {} self.values = {}
self.storage = self._get_storage() self.storage = self.__get_storage()
@property @property
def nick(self): def nick(self):
@ -41,7 +41,7 @@ class Bot(irc.client.SimpleIRCClient, Logger):
self.values[self.CHANNELS_RUNTIME_KEY] = [] self.values[self.CHANNELS_RUNTIME_KEY] = []
return self.values[self.CHANNELS_RUNTIME_KEY] return self.values[self.CHANNELS_RUNTIME_KEY]
def _get_storage(self): def __get_storage(self):
"""Load data from storage.""" """Load data from storage."""
try: try:
with open(self.config["storage_file"], "rt") as storage_file: with open(self.config["storage_file"], "rt") as storage_file:
@ -54,7 +54,7 @@ class Bot(irc.client.SimpleIRCClient, Logger):
" data when closing the program.") " data when closing the program.")
return {} return {}
def _save_storage(self): def __save_storage(self):
"""Save storage data to disk.""" """Save storage data to disk."""
try: try:
with open(self.config["storage_file"], "wt") as storage_file: with open(self.config["storage_file"], "wt") as storage_file:
@ -114,7 +114,7 @@ class Bot(irc.client.SimpleIRCClient, Logger):
self.start() self.start()
except KeyboardInterrupt: except KeyboardInterrupt:
self.log_i("Stopping Edmond.") self.log_i("Stopping Edmond.")
self._save_storage() self.__save_storage()
def load_plugins(self): def load_plugins(self):
"""Load all installed plugins.""" """Load all installed plugins."""