Skip to content

Latest commit

Β 

History

54 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TooGoodToMiss

TooGoodToMiss

Never miss a TooGoodToGo magic bag again

A self-hosted Telegram bot that watches your TooGoodToGo favourites and pings you the moment a bag drops.
Single process, no cloud lock-in β€” deploy it on any VPS with one command.


License: MIT Tests Python Telegram


Quick Start

# Clone & install
git clone https://github.com/jordantete/TooGoodToMiss.git && cd TooGoodToMiss
python3 -m venv .venv
./.venv/bin/pip install -r requirements.txt

# Configure
cp .env.example .env   # then fill in USER_EMAIL, TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID

# Run
./.venv/bin/python -m app.main

How It Works

The bot runs as a single long-lived process. run_polling() handles your Telegram commands, while monitoring runs as a job that reschedules itself after every pass.

  1. Watch β€” every few minutes, the bot fetches your TooGoodToGo favourites
  2. Notify β€” when a bag becomes available, you get a Telegram message
  3. Deduplicate β€” one notification per store per day, no spam
  4. Back off β€” if TooGoodToGo throws a CAPTCHA, the bot pauses itself and retries later

Polling intervals are deliberately randomized β€” 10–20 minutes in the morning window, 2–5 minutes in the afternoon, nothing on Sundays. This is anti-fingerprinting, not a config knob.

Features

  • Automated monitoring β€” randomized schedule that stays under TooGoodToGo's radar
  • Telegram control β€” /status, /pause, /wakeup, /settings and inline buttons
  • Multi-language β€” English and French
  • Self-hosted β€” one process, one file of state, no managed services
  • One-command deploy β€” ./scripts/deploy.sh syncs, installs and restarts over SSH
  • Crash-safe state β€” atomic writes, so a power cut never leaves an unbootable bot

Telegram Setup

You need a bot token and your chat ID:

  1. Create the bot β€” open Telegram, talk to @BotFather, send /newbot and follow the prompts. You get a bot token.
  2. Find your chat ID β€” send any message to your new bot, then open:
    https://api.telegram.org/bot<YourBotToken>/getUpdates
    
    The JSON response contains your chat_id.

Put both in .env, alongside the USER_EMAIL of your TooGoodToGo account.

Deploying to a VPS

Fill in VPS_USER, VPS_HOST, VPS_BOT_PATH and SSH_KEY in .env, then:

./scripts/deploy.sh

The script rsyncs the code, pushes the .env, installs dependencies in a remote virtualenv and restarts the toogoodtomiss tmux session.

ssh $VPS_USER@$VPS_HOST 'tail -f /root/toogoodtomiss/logs/app.log'   # logs
ssh $VPS_USER@$VPS_HOST 'tmux attach -t toogoodtomiss'               # attach

Running the Tests

./.venv/bin/pip install -r requirements.txt -r requirements-dev.txt
./.venv/bin/python -m pytest tests/ -q

Troubleshooting

The bot still uses old TooGoodToGo tokens after a deploy

This is expected. ACCESS_TOKEN, REFRESH_TOKEN, TGTG_COOKIE and USER_LANGUAGE are read from .env only once, when state.json is first created. After that state.json is the source of truth, and deploy.sh never pushes it β€” otherwise every deploy would overwrite the live session with a stale local copy, forcing a re-login and a CAPTCHA.

To force new tokens:

ssh $VPS_USER@$VPS_HOST "rm /root/toogoodtomiss/state.json"
./scripts/deploy.sh

Monitoring never runs

Check that the [job-queue] extra is installed. Without APScheduler, application.job_queue is None; app.main.build_application() raises an explicit RuntimeError in that case.

Contributing

Contributions are welcome. See the contributing guide for the development workflow and the project invariants worth knowing before you touch the scheduler or the state layer. By participating you agree to the Code of Conduct.

Support

If this bot saved you a few magic bags, you can buy me a coffee β˜•

License

MIT β€” see LICENSE.txt.

Disclaimer

TooGoodToMiss is an independent project and is not affiliated with, endorsed by, or officially connected to TooGoodToGo (TGTG) or any of its subsidiaries or affiliates. All product names, logos, and brands are property of their respective owners.

About

A self-hosted Telegram bot to spot TooGoodToGo magic bags before everyone else, ensuring you never miss a deal! πŸš€

Topics

Resources

Code of conduct

Contributing

Stars

2 stars

Watchers

1 watching

Forks

Sponsor this project

Contributors

Languages