From 50974eeefe550a1b5697fe1577aeda944a364653 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Sat, 25 Aug 2018 12:30:53 -0500 Subject: [PATCH] Tunnel names can now be configured in the .ini file --- geoffrey/BotConfig.py | 20 ++++++++++++++++---- geoffrey/DatabaseModels.py | 10 +++++----- geoffrey/Geoffrey.py | 2 +- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/geoffrey/BotConfig.py b/geoffrey/BotConfig.py index eb53bfa..307da4f 100644 --- a/geoffrey/BotConfig.py +++ b/geoffrey/BotConfig.py @@ -18,10 +18,14 @@ def create_config(config): 'Database': '' } config['Minecraft'] = {'Dynmap_Url': '', - 'World_Name': '' + 'World_Name': '', + 'North_Tunnel': 'North', + "East_Tunnel": 'South', + "South_Tunnel": 'East', + "West_Tunnel": 'West' } - config['Logging'] = {'Count': '', - 'Rotation_Duration': '' + config['Logging'] = {'Count': '7', + 'Rotation_Duration': '1' } config['Special Names'] = {} @@ -48,13 +52,21 @@ class Config: try: self.config = read_config() self.engine_args = self.read_engine_arg() + self.token = self.config['Discord']['Token'] self.world_name = self.config['Minecraft']['World_Name'] self.status = self.config['Discord']['Status'] self.prefix = self.config['Discord']['Prefix'] - self.dynmap_url = self.config['Minecraft']['Dynmap_Url'] self.bot_mod = self.config['Discord']['Bot_Mod'].split(',') self.error_users = self.config['Discord']['Error_Users'].split(',') + + self.dynmap_url = self.config['Minecraft']['Dynmap_Url'] + self.north_tunnel = self.config['Minecraft']['North_Tunnel'] + self.east_tunnel = self.config['Minecraft']['East_Tunnel'] + self.south_tunnel = self.config['Minecraft']['South_Tunnel'] + self.west_tunnel = self.config['Minecraft']['West_Tunnel'] + + self.count = int(self.config['Logging']['Count']) self.rotation_duration = int(self.config['Logging']['Rotation_Duration']) self.special_name_list = dict(self.config.items('Special Names')) diff --git a/geoffrey/DatabaseModels.py b/geoffrey/DatabaseModels.py index 3ff660b..e01bcec 100644 --- a/geoffrey/DatabaseModels.py +++ b/geoffrey/DatabaseModels.py @@ -83,10 +83,10 @@ class GeoffreyDatabase: class TunnelDirection(enum.Enum): - North = 'green' - East = 'blue' - South = 'red' - West = 'yellow' + North = bot_config.north_tunnel + East = bot_config.east_tunnel + South = bot_config.south_tunnel + West = bot_config.west_tunnel def str_to_tunnel_dir(arg): arg = arg.lower() @@ -210,7 +210,7 @@ class Location(SQL_Base): format(bot_config.dynmap_url, bot_config.world_name, self.x, self.z) def pos_to_str(self): - pos_str = '**(x= {}, z= {})** **{}**'.format(self.x, self.z, self.dimension.value.title()) + pos_str = '**(x= {}, z= {})** {}'.format(self.x, self.z, self.dimension.value.title()) if self.tunnel is not None: return pos_str + ', **{}**'.format(self.tunnel) else: diff --git a/geoffrey/Geoffrey.py b/geoffrey/Geoffrey.py index e125d98..7a2d610 100644 --- a/geoffrey/Geoffrey.py +++ b/geoffrey/Geoffrey.py @@ -18,7 +18,7 @@ def setup_logging(): discord_logger.setLevel(logging.INFO) sql_logger = logging.getLogger('sqlalchemy.engine') sql_logger.setLevel(logging.INFO) - bot_info_logger = logging.getLogger('bot') + bot_info_logger = logging.getLogger('geoffrey.bot') bot_info_logger.setLevel(logging.INFO) handler = handlers.TimedRotatingFileHandler(filename='Geoffrey.log', when='D',