This commit is contained in:
Brieuc Dubois 2023-05-19 21:36:12 +02:00
parent 45767dada9
commit 9f0bf8cf16
2 changed files with 10 additions and 6 deletions

View File

@ -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"]
COPY main.py .
COPY config.py .
CMD ["python", "main.py"]

View File

@ -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())
asyncio.run(main())