From 41f71e20864a9c109cdad1ac4c7c45b4fcde6146 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Sun, 29 Mar 2015 23:16:17 +0100 Subject: [PATCH] Switch Market Systems to a config item. --- README.md | 1 + dropbot/bot.py | 14 +++++--------- dropbot/cli.py | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ae7ac25..5c5728e 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ The configuration is passed by using environment variables. * ```DROPBOT_REDIS_URL``` - 12 factor style URL of the Redis server to use (defaults to redis://localhost:6379/0) * ```DROPBOT_CMD_PREFIX``` - Prefix of MUC channel commands (defaults to !) * ```DROPBOT_KOS_URL``` - URL of the CVA KOS API service (defaults to http://kos.cva-eve.org/api/) +* ```DROPBOT_MARKET_SYSTEMS``` - A comma seperated list of systems to be used for the best price checker (defaults to Jita, Amarr, Rens, Dodixie) * ```DROPBOT_KILL_CORPS``` - List of Corp IDs to track for kills * ```DROPBOT_KILLS_DISABLED``` - Disables the streaming of zKillboard kills to the channels (default to 0) * ```DROPBOT_OFFICE_API_KEYID``` - API KeyID to use for the nearest office finder. diff --git a/dropbot/bot.py b/dropbot/bot.py index 0b3576c..6204e26 100644 --- a/dropbot/bot.py +++ b/dropbot/bot.py @@ -20,14 +20,6 @@ from dropbot.stomp_listener import ZKillboardStompListener urlparse.uses_netloc.append("redis") -market_systems = [ - ('Jita', 30000142), - ('Amarr', 30002187), - ('Rens', 30002510), - ('Dodixie', 30002659), - ('U-HVIX', 30000575), -] - zkillboard_regex = re.compile(r'http(s|):\/\/(?P.*)\/kill\/(?P\d+)\/') @@ -48,6 +40,7 @@ class DropBot(ClientXMPP): self.kills_muted = False self.office_api_key_keyid = kwargs.pop('office_api_keyid', None) self.office_api_key_vcode = kwargs.pop('office_api_vcode', None) + self.market_systems = kwargs.pop('market_systems', ['Jita', 'Amarr', 'Rens', 'Dodixie']) if 'redis_url' in kwargs: self.redis_pool = ConnectionPool.from_url(kwargs.pop('redis_url', 'redis://localhost:6379/0')) @@ -303,7 +296,10 @@ class DropBot(ClientXMPP): sell_sys = None buy_sys = None - for name, sys_id in market_systems: + for name in self.market_systems: + sys_id = self.map.get_system_id(name) + if not sys_id: + continue sell, buy = self._get_evecentral_price(type_id, sys_id) if (sell < min_sell or min_sell == 0) and sell > 0: min_sell = sell diff --git a/dropbot/cli.py b/dropbot/cli.py index d0a5a6d..14209d6 100644 --- a/dropbot/cli.py +++ b/dropbot/cli.py @@ -33,7 +33,7 @@ def main(): # Parse the environment for config config = dict([(k[8:].lower(), v) for k, v in os.environ.items() if 'DROPBOT_' in k]) # Split out array type configs - for key in ['rooms', 'admins', 'kill_corps']: + for key in ['rooms', 'admins', 'kill_corps', 'market_systems']: if key in config: config[key] = [x.strip() for x in config[key].split(',')] elif opts.config.lower().startswith('http'):