From 45767dada9f241291fa86f6802eb7cd73d71f03b Mon Sep 17 00:00:00 2001 From: Bhasher Date: Sat, 13 May 2023 23:13:33 +0200 Subject: [PATCH] dockerfile --- config.example.py | 1 - dockerfile | 12 ++++++++++++ main.py | 9 ++++----- 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 dockerfile diff --git a/config.example.py b/config.example.py index 17370e7..8105c17 100644 --- a/config.example.py +++ b/config.example.py @@ -1,4 +1,3 @@ - email = '' telegram_token = '' telegram_id = '' \ No newline at end of file diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..eaf903b --- /dev/null +++ b/dockerfile @@ -0,0 +1,12 @@ +FROM python:3 + +WORKDIR /tg2 + +COPY main.py . +COPY config.py . +COPY requirements.txt . + +RUN pip install --no-cache-dir pip && \ + pip install --no-cache-dir -r requirements.txt + +CMD ["python", "main.py"] \ No newline at end of file diff --git a/main.py b/main.py index 3287b01..641e779 100644 --- a/main.py +++ b/main.py @@ -14,14 +14,13 @@ async def main(): client = TgtgClient(email=config.email) credentials = client.get_credentials() with open('token', 'w') as file: - file.write(credentials) + file.write(str(credentials)) else: with open('token', 'r') as file: - credentials = file.read() + credentials = json.loads(file.read().replace('\'', '"')) - data = json.loads(credentials.replace('\'', '"')) - client = TgtgClient(**data) + client = TgtgClient(**credentials) last = [] @@ -45,7 +44,7 @@ async def main(): name = "Panier anti-gaspi" texts.append(f' - {amount} item(s) of "{name}" ({price:.2f}€) available at "{store}"') - elif item["item_id"] in last: + elif item["item"]["item_id"] in last: amount = item["items_available"] name = item["item"]["name"] price = item["item"]["price_including_taxes"]["minor_units"]/(10**item["item"]["price_including_taxes"]["decimals"])