Merge pull request 'Don't load config twice.' (#3) from Yuuki/EliteBot:master into master
Reviewed-on: #3
This commit is contained in:
commit
fb8e623a84
1 changed files with 4 additions and 4 deletions
|
@ -20,6 +20,7 @@ from src.sasl import handle_sasl, handle_authenticate, handle_903
|
||||||
class Bot:
|
class Bot:
|
||||||
def __init__(self, config_file):
|
def __init__(self, config_file):
|
||||||
self.config = self.load_config(config_file)
|
self.config = self.load_config(config_file)
|
||||||
|
self.validate_config(self.config)
|
||||||
self.channel_manager = ChannelManager()
|
self.channel_manager = ChannelManager()
|
||||||
self.logger = Logger('logs/elitebot.log')
|
self.logger = Logger('logs/elitebot.log')
|
||||||
self.connected = False
|
self.connected = False
|
||||||
|
@ -27,8 +28,6 @@ class Bot:
|
||||||
self.running = True
|
self.running = True
|
||||||
self.plugins = []
|
self.plugins = []
|
||||||
self.load_plugins()
|
self.load_plugins()
|
||||||
self.config = self.load_config(config_file)
|
|
||||||
self.validate_config(self.config)
|
|
||||||
|
|
||||||
def validate_config(self, config):
|
def validate_config(self, config):
|
||||||
required_fields = [
|
required_fields = [
|
||||||
|
@ -97,7 +96,7 @@ class Bot:
|
||||||
try:
|
try:
|
||||||
if msg != '':
|
if msg != '':
|
||||||
self.logger.info(f'Sending command: {msg}')
|
self.logger.info(f'Sending command: {msg}')
|
||||||
self.ircsock.send(bytes(f'{msg}\r\n','UTF-8'))
|
self.ircsock.send(bytes(f'{msg}\r\n', 'UTF-8'))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.error(f'Error sending IRC message: {e}')
|
self.logger.error(f'Error sending IRC message: {e}')
|
||||||
raise
|
raise
|
||||||
|
@ -212,6 +211,7 @@ class Bot:
|
||||||
self.logger.error(f'General error: {e}')
|
self.logger.error(f'General error: {e}')
|
||||||
self.connected = False
|
self.connected = False
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
bot = Bot(sys.argv[1])
|
bot = Bot(sys.argv[1])
|
||||||
|
|
Loading…
Add table
Reference in a new issue