diff --git a/README.md b/README.md index 1839efc..0545a97 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,11 @@ License This repository is licensed under the MIT license. +Requirements +------------ + +Python requirements are covered in ```requirements.txt```, in addition a working Redis server is needed to enable API caching from the EVE Online API server. Redis is not essential to the operation of Dropbot but without caching you may get into hot water with CCP. + Setup ----- @@ -31,5 +36,6 @@ The configuration is passed by using environment variables. * ```DROPBOT_PASSWORD``` - Password of the account * ```DROPBOT_NICKNAME``` - MUC nickname (defaults to Dropbot) * ```DROPBOT_ROOMS``` - List of MUC rooms to join, seperated by commas +* ```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/) diff --git a/dropbot/bot.py b/dropbot/bot.py index b80638f..6f4fb34 100644 --- a/dropbot/bot.py +++ b/dropbot/bot.py @@ -49,9 +49,13 @@ 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.redis_pool = ConnectionPool.from_url(kwargs.pop('redis_url', 'redis://localhost:6379/0')) - self.redis = Redis(connection_pool=self.redis_pool) + + if 'redis_url' in kwargs: + self.redis_pool = ConnectionPool.from_url(kwargs.pop('redis_url', 'redis://localhost:6379/0')) + self.redis = Redis(connection_pool=self.redis_pool) + else: + logging.warning('No DROPBOT_REDIS_URL defined, EVE API calls will not be cached!') + self.redis = None self.map = Map.from_json(pkgutil.get_data('dropbot', 'data/map.json')) jid = kwargs.pop('jid', None) @@ -245,7 +249,9 @@ class DropBot(ClientXMPP): return [self.stations[unicode(location_to_station(x.locationID))] for x in assets.assets if x.typeID == 27] def get_eveapi(self): - return EVEAPIConnection(cacheHandler=EVEAPIRedisCache(self.redis)) + if self.redis: + return EVEAPIConnection(cacheHandler=EVEAPIRedisCache(self.redis)) + return EVEAPIConnection() def get_eveapi_auth(self, keyid, vcode): return self.get_eveapi().auth(keyID=keyid, vCode=vcode) @@ -734,4 +740,4 @@ class DropBot(ClientXMPP): return 'This only works in MUC rooms' names = self.plugin['xep_0045'].getRoster(msg['from'].bare) - return 'RAGE PING: {} :frogsiren:'.format(', '.join(names)) \ No newline at end of file + return 'RAGE PING: {} :frogsiren:'.format(', '.join(names))