diff --git a/dockerfile b/dockerfile index eaf903b..d928f3f 100644 --- a/dockerfile +++ b/dockerfile @@ -2,11 +2,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 +COPY main.py . +COPY config.py . + +CMD ["python", "main.py"] diff --git a/main.py b/main.py index 641e779..d8a3474 100644 --- a/main.py +++ b/main.py @@ -21,6 +21,10 @@ async def main(): client = TgtgClient(**credentials) + bot = telegram.Bot(config.telegram_token) + + async with bot: + await bot.send_message(chat_id=config.telegram_id, text='tgĀ² bot is watching!') last = [] @@ -38,7 +42,7 @@ async def main(): amount = item["items_available"] name = item["item"]["name"] price = item["item"]["price_including_taxes"]["minor_units"]/(10**item["item"]["price_including_taxes"]["decimals"]) - store = item["store"]["store_name"] + store = item["store"]["store_name"] + ' (' + item["store"]["branch"] + ')' if not name: name = "Panier anti-gaspi" @@ -57,7 +61,6 @@ async def main(): if len(texts) > 1: - bot = telegram.Bot(config.telegram_token) print(f'\n{datetime.datetime.now()}: {len(texts)-1} new items available') @@ -70,4 +73,4 @@ async def main(): time.sleep(60) if __name__ == '__main__': - asyncio.run(main()) \ No newline at end of file + asyncio.run(main())