Skip to content

(TG)³ is a TooGoodToGo Telegram bot, running entirely out of Github Actions workflows, or self-hosted

Notifications You must be signed in to change notification settings

LucasPlacentino/TG3

 
 

Repository files navigation

(TG)³ - TooGoodToGo Telegram Notifications

A fork of LauPaSat-pl/TGTG notifications, and inspired by Der-Henning/tgtg and kacpi2442/am_bot

GitHub Repo stars tgtg notifications tgtg notifications tgtg notifications

There are 2 versions:

1. Github Actions 2. Self-hosted
Status 🟩 Fully working 🟨 WIP
Runs on Github servers Your server
- Features: ---------- ----------
Easy setup 🟨1
Notifies available items
Shows price of items
Shows quantity available
Shows store location
Shows description
Link to open app
Prevents repetition2
...3

Setup:

  1. Create a new Telegram bot using BotFather tutorial -> get your TG_BOT_ID,
  2. Check your Telegram ID tutorial -> this will be your TG_CHAT_ID,
  3. Install the tgtg Python library
pip install tgtg
  1. Run with python
from tgtg import TgtgClient

client = TgtgClient(email="[email protected]")
credentials = client.get_credentials()

You should receive an email from TooGoodToGo. The client will wait until you validate the login by clicking the link inside the email.

Once you clicked the link, you will get credentials and be able to see them with:

print(credentials)

They will look like this:

{
    'access_token': '<your_access_token>',
    'refresh_token': '<your_refresh_token>',
    'user_id': '<your_user_id>',
    'cookie': '<cookie>',
}

These will be your TGTG ACCESS_TOKEN, REFRESH_TOKEN, TGTG_USER_ID, and COOKIE.

1. Github Actions workflows

This runs 100% automatically on Github Actions (not counting the set up), to check for your favourite available TooGoodToGo items and send you a Telegram message about it. You can make it run periodically, for example every 15 minutes.

Steps:

  1. Fork this repo,
  2. In your repo add secrets (tutorial) you got from earlier steps (TooGoodToGo and Telegram), you can check how to name them in notitications.yml file,
    [DO NOT PUT THEM VISIBLE IN .py or .yml FILES DIRECTLY OR ELSE YOU WILL HAVE TO REVOKE YOUR CREDENTIALS AND DELETE YOUR FORK]
  3. [Optional] Change the schedule in the .github/workflows/notifications.yml file,
  4. Make sure it's up and running. Done!

2. Self-hosted app

[WIP]

TODO

Steps:

TODO
clone
.env.template -> .env
docker?
...

403 error

Getting a tgtg.exceptions.TgtgAPIError: (403, b'{"url"... error ? You are getting blocked by the TooGoodToGo API by their bot prevention, try sending requests less frequently or wait a couple hours. (More info or solutions at the tgtg-python repo)

Footnotes

  1. Not difficult if you know how to run a simple linux server.

  2. Prevents sending notifications for available items that were already sent.

  3. TODO._

About

(TG)³ is a TooGoodToGo Telegram bot, running entirely out of Github Actions workflows, or self-hosted

Topics

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Languages

  • Python 100.0%