Merge pull request #9 from nikdoof/redis-documentation

Document Redis requirements
This commit is contained in:
Rob Haswell
2015-03-24 16:02:38 +00:00
2 changed files with 17 additions and 5 deletions

View File

@@ -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/)

View File

@@ -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))
return 'RAGE PING: {} :frogsiren:'.format(', '.join(names))