updated to check for env var USER_ID
This commit is contained in:
@@ -20,13 +20,15 @@ def initialise_app(
|
||||
discord_service_name: str = DISCORD_SERVICE_NAME,
|
||||
discord_webhook_url: str = DISCORD_WEBHOOK_URL,
|
||||
discord_logger_level: str = DISCORD_LOGGER_LEVEL
|
||||
):
|
||||
) -> int:
|
||||
"""
|
||||
Convienience function that ensures eveything is ready
|
||||
before running the main loop.
|
||||
"""
|
||||
# load environment variables
|
||||
load_dotenv()
|
||||
user_id = int(os.getenv('USER_ID', default=None))
|
||||
assert user_id is not None, 'environment variable USER_ID must be specified'
|
||||
logger_level = os.getenv(
|
||||
'LOGGER_LEVEL',
|
||||
default=LOGGER_LEVEL
|
||||
@@ -58,8 +60,10 @@ def initialise_app(
|
||||
level = getattr(logging, discord_logger_level.upper())
|
||||
discord_handler.setLevel(level=level)
|
||||
logger.addHandler(discord_handler)
|
||||
logging.debug('finished')
|
||||
return user_id
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
initialise_app()
|
||||
user_id = initialise_app()
|
||||
logging.warning('test message')
|
||||
|
||||
Reference in New Issue
Block a user