From f78d5e414d6a6866a4939e65fb35c5e2f1001abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Sat, 27 Feb 2021 10:44:15 +0100 Subject: [PATCH] STATE_PATH env variable --- bot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index ebb3b80..94cd261 100644 --- a/bot.py +++ b/bot.py @@ -15,6 +15,8 @@ from config import Config config = Config() config.WEBHOOK_URL = os.getenv("WEBHOOK_URL", config.WEBHOOK_URL) +STATE_PATH = os.getenv("STATE_PATH", "state.pickle") + class State: notified = [] @@ -74,7 +76,7 @@ async def send_message(text): async def main(): try: - with open('state.pickle', 'rb') as state_fp: + with open(STATE_PATH, 'rb') as state_fp: state = pickle.load(state_fp) except FileNotFoundError: state = State() @@ -101,7 +103,7 @@ async def main(): await send_message(process_event(event, config.SOON_TEMPLATE)) state.notified_soon.append(event.name) - with open('state.pickle', 'wb') as state_fp: + with open(STATE_PATH, 'wb') as state_fp: pickle.dump(state, state_fp) logging.debug("Sleeping for 60s...")