Persist settings cache connection in bot object

This commit is contained in:
Dustin Pianalto 2019-12-25 16:44:01 -09:00
parent fe23620fe4
commit c82a404263

View File

@ -26,9 +26,9 @@ class Geeksbot(commands.Bot):
self.config_file = 'bot_config.json' self.config_file = 'bot_config.json'
self.extension_dir = 'exts' self.extension_dir = 'exts'
self.cache = redis.Redis(host=os.environ['REDIS_HOST'], password=os.environ['REDIS_PASSWORD'], port=os.environ['REDIS_PORT'], db=os.environ['REDIS_DB'], charset="utf-8", decode_responses=True) self.cache = redis.Redis(host=os.environ['REDIS_HOST'], password=os.environ['REDIS_PASSWORD'], port=os.environ['REDIS_PORT'], db=os.environ['REDIS_DB'], charset="utf-8", decode_responses=True)
settings_cache = redis.Redis(host=os.environ['REDIS_HOST'], password=os.environ['REDIS_PASSWORD'], port=os.environ['REDIS_PORT'], db=1, charset="utf-8", decode_responses=True) self.settings_cache = redis.Redis(host=os.environ['REDIS_HOST'], password=os.environ['REDIS_PASSWORD'], port=os.environ['REDIS_PORT'], db=1, charset="utf-8", decode_responses=True)
self.token = settings_cache.get('DISCORD_TOKEN') self.token = self.settings_cache.get('DISCORD_TOKEN')
self.api_token = settings_cache.get('API_TOKEN') self.api_token = self.settings_cache.get('API_TOKEN')
self.aio_session = aiohttp.ClientSession(loop=self.loop) self.aio_session = aiohttp.ClientSession(loop=self.loop)
self.auth_header = {'Authorization': f'Token {self.api_token}'} self.auth_header = {'Authorization': f'Token {self.api_token}'}
self.api_base = 'https://geeksbot.app/api' self.api_base = 'https://geeksbot.app/api'