Giter Site home page Giter Site logo

achaak / toogoodtogo-bot Goto Github PK

View Code? Open in Web Editor NEW
56.0 5.0 15.0 288 KB

TooGooToGo-Bot is a tool designed to help you stay informed about the availability of your favorite stores on the Too Good To Go platform. It sends notifications, allowing you to quickly find and purchase food products before they disappear.

License: MIT License

Shell 0.05% TypeScript 94.69% Dockerfile 0.74% JavaScript 4.53%
food-waste notification-tool telegram-bot too-good-to-go windows-notifications api-integration automation docker nodejs discord-bot

toogoodtogo-bot's Introduction

TooGooToGo-Bot

TooGooToGo-Bot is a tool designed to help you stay informed about the availability of your favorite stores on the Too Good To Go platform. It sends notifications, allowing you to quickly find and purchase food products before they disappear.

Table of Contents

Installation

Prerequisites

Clone the Repository

git clone https://github.com/Achaak/toogoodtogo-bot.git
cd toogoodtogo-bot/

Configure Environment Variables

  1. Make a copy of the sample environment file and enter your parameters:
    cp .env .env.local
  2. Open .env.local in a text editor and fill in the required information.

Install Dependencies

pnpm install

Build the Project

pnpm run build

Start the Application

pnpm start

Update

To update the application, follow these steps:

  1. Get the latest files:

    git pull
  2. Install any new dependencies:

    pnpm install
  3. Rebuild the project:

    pnpm run build

Configuration

Discord

Discord

To set up Discord notifications, access the .env.local file in a text editor and provide the necessary value for the NOTIFICATIONS_DISCORD_ENABLED parameter.

Creating a Discord Webhook

  1. Create a new Discord server or use an existing one.

  2. Create a new channel

  3. Create a new webhook in the channel settings and copy the URL provided. See the Discord documentation for more information.

  4. Open the .env.local file in a text editor and fill in the NOTIFICATIONS_DISCORD_WEBHOOK_URL parameter.

Telegram

Telegram

To set up Telegram notifications, access the .env.local file in a text editor and provide the necessary value for the NOTIFICATIONS_TELEGRAM_ENABLED parameter.

To configure the bot, open the .env.local file in a text editor and specify the value for the NOTIFICATIONS_TELEGRAM_BOT_TOKEN parameter.

Creating a Telegram Bot

  1. Open a Telegram chat with BotFather and enter the /start command.

  2. Select the /newbot command and follow the instructions to create a new bot. Take note of the token access provided.

  3. Once your bot is created, multiple users can use it to receive notifications about their favorite stocks.

  4. To start receiving notifications, send the /start command in your bot's conversation.

Commands

  • /start: Starts Telegram notifications
  • /stop: Stops Telegram notifications
  • /help: Provides a list of usable commands
Desktop

Desktop

To set up desktop notifications, access the .env.local file in a text editor and provide the necessary value for the NOTIFICATIONS_DESKTOP_ENABLED parameter.

Console

Console

To set up console notifications, access the .env.local file in a text editor and provide the necessary value for the NOTIFICATIONS_CONSOLE_ENABLED parameter.

For clearing the console before each notification, open the .env.local file in a text editor and specify the value for the NOTIFICATIONS_CONSOLE_CLEAR parameter.

Run with Docker

You can also run the application using Docker. Follow these steps:

  1. Build the Docker image:

    docker build . -t <your desired username>/togoodtogobot
  2. Run the Docker image:

    docker run -p 3000:3000 -d <your desired username>/togoodtogobot

Run with PM2

PM2 allows you to install the bot on a server and receive notifications 24/7. Follow these steps:

  1. Install PM2:

    pnpm install pm2 -g
  2. Start the server:

    pm2 start start.sh
  3. After logging in:

    pm2 ls # to see the process_id
    pm2 attach your_process_id
    # Press Enter to submit your registration

Change Log

See the CHANGELOG.md file for the change log.

License

This project is licensed under the MIT License.

toogoodtogo-bot's People

Contributors

aburenko avatar achaak avatar toczke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

toogoodtogo-bot's Issues

First time login ok, other times errors

Hi,

Have this error, when start again

Error authByEmail

<html><head><title>apptoogoodtogo.com</title><style>#cmsg{animation: A 1.5s;}@keyframes A{0%{opacity:0;}99%{opacity:0;}100%{opacity:1;}}</style></head><body style="margin:0"><p id="cmsg">Please enable JS and disable any ad blocker</p><script data-cfasync="false">var dd={'cid':'JDHUSDHKJFJS-JLHSDUQDHDIEZI==','hsh':'KJDHZIUHDEODNEDNEOI','t':'bv','r':'b','s':387444,'e':'IZYUEZEYIODHEEUZIJDZIDJIDJZIEUZIEJZE','host':'geo.captcha-delivery.com'}</script><script data-cfasync="false" src="https://ct.captcha-delivery.com/c.js"></script></body></html>

I don't have any blocker

Suggest : add location

Hello
In Telegram alert all it says is something like « Business : # of stock »
But I got same business in different town. Is it possible to add the location like in the TGTG app ?
Something like « Business - Location : # »

thanks !

Issue on update/installation

Hello since the 1.1.0 there's a problem while building the project.

first run as readme is saying to run build before install

pi@raspberrypi:~/toogoodtogo-bot $ sudo npm run build
> [email protected] build /home/pi/toogoodtogo-bot
> tsc

sh: 1: tsc: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! [email protected] build: `tsc`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-01-28T10_33_11_724Z-debug.log

So I tried to run install before run build :
pi@raspberrypi:~/toogoodtogo-bot $ sudo npm run build

> [email protected] build /home/pi/toogoodtogo-bot
> tsc

src/core/index.ts:8:20 - error TS2307: Cannot find module './../../config/config' or its corresponding type declarations.

8 import Config from './../../config/config'
                     ~~~~~~~~~~~~~~~~~~~~~~~

src/lib/dataManager/index.ts:2:20 - error TS2307: Cannot find module './../../../config/config' or its corresponding type declarations.

2 import Config from './../../../config/config'
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~

src/lib/telegram/index.ts:1:20 - error TS2307: Cannot find module './../../../config/config' or its corresponding type declarations.

1 import Config from './../../../config/config'
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~

src/services/API/config.ts:2:20 - error TS2307: Cannot find module './../../../config/config' or its corresponding type declarations.

2 import config from "./../../../config/config"
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~

src/services/API/connect.ts:3:20 - error TS2307: Cannot find module './../../../config/config' or its corresponding type declarations.

3 import config from "./../../../config/config"
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 5 errors.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-01-28T10_37_48_388Z-debug.log

Thanks !

Edit : Exact same 5 error codes with Yarn

Docker container fails at run time.

Hey @Achaak, thanks for the project! :)

I commented on #15 but it's probably better to open an issue for this.

I tried building and running with Docker but it's not working for me. Does it work for you guys?
This is my stacktrace:

❯ docker run -p 3000:3000 -it saveriogzz/toogoodtogobot
yarn run v1.22.19
$ ts-node ./dist/src/index.js
node:internal/modules/cjs/loader:959
  throw err;
  ^

Error: Cannot find module './index.js'
Require stack:
- /app/dist/src/imaginaryUncacheableRequireResolveScript
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at requireResolveNonCached (/app/node_modules/ts-node/dist/bin.js:489:16)
    at getProjectSearchDir (/app/node_modules/ts-node/dist/bin.js:459:40)
    at phase3 (/app/node_modules/ts-node/dist/bin.js:263:27)
    at bootstrap (/app/node_modules/ts-node/dist/bin.js:44:30)
    at main (/app/node_modules/ts-node/dist/bin.js:32:12)
    at Object.<anonymous> (/app/node_modules/ts-node/dist/bin.js:519:5)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/app/dist/src/imaginaryUncacheableRequireResolveScript' ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

1.1.0 not working ?

Hello

Im still having issues with 1.1.0.

I put telegram notification (it was working fine in 1.0.0), same Token and credentials.
I just edit the user agent to recognize the station.
I run it :

pi@raspberrypi:~/toogoodtogo-bot $ npm run start

> [email protected] start /home/pi/toogoodtogo-bot
> ts-node ./dist/src/index.js

Your are connected.

But I dont receive any notification on telegram now :/
(Btw "Your are connected." is misspelled > "You are connected")

cant start the program, command giving exit code 1.

Hi, I've followed the instructions on the page but it's not working. Please help.

yarn run v1.22.19P4:~/toogoodtogo-bot$ yarn start
$ node ./dist/src/index.js
node:internal/errors:477
ErrorCaptureStackTrace(err);
^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/waj/toogoodtogo-bot/dist/config/config.js' imported from /home/waj/toogoodtogo-bot/dist/src/core/index.js
at new NodeError (node:internal/errors:387:5)
at finalizeResolution (node:internal/modules/esm/resolve:429:11)
at moduleResolve (node:internal/modules/esm/resolve:1006:10)
at defaultResolve (node:internal/modules/esm/resolve:1214:11)
at nextResolve (node:internal/modules/esm/loader:165:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:844:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:431:18)
at ModuleWrap. (node:internal/modules/esm/module_job:76:40)
at link (node:internal/modules/esm/module_job:75:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
waj@DESKTOP-FL4KEP4:~/toogoodtogo-bot$

Error with pm2 start start.sh

pm2 start start.sh when I try to launch this cmd I've got this error : [PM2][ERROR] Interpreter bash is NOT AVAILABLE in PATH. (type 'which bash' to double check.)
I tried directly npm run start but still not work:
Error authByEmail

<title>apptoogoodtogo.com</title><style>#cmsg{animation: A 1.5s;}@Keyframes A{0%{opacity:0;}99%{opacity:0;}100%{opacity:1;}}</style>

Please enable JS and disable any ad blocker

<script data-cfasync="false">var dd={'rt':'c','cid':'AHrlqAAAAAMAOCRdIcP8edIAbaTMIA==','hsh':'1D42C2CA6131C526E09F294FE96F94','t':'fe','r':'b','s':35588,'e':'e12eaa6ed2dc5f2baa5f990f2c5faab1c570d8992d775ebcbf9719855bb6cb7d','host':'geo.captcha-delivery.com'}</script><script data-cfasync="false" src="https://ct.captcha-delivery.com/c.js"></script>

"Bot was blocked by user"

Started seeing these errors today -- not sure what it means exactly....I seem to be getting these alerts, just never noticed this behaviour before. Is it something on Telegram's end?

TelegramError: 403: Forbidden: bot was blocked by the user
at Telegram.callApi (/Users/xxxxx/xxxx/toogoodtogo-bot/node_modules/.pnpm/[email protected]/node_modules/telegraf/lib/core/network/client.js:302:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
response: {
ok: false,
error_code: 403,
description: 'Forbidden: bot was blocked by the user'
},
on: {
method: 'sendMessage',
payload: {
chat_id: 1297094036,
parse_mode: 'HTML',
text: 'Original Unverpackt\nAvailable: 1\n3,00 €\nToday 19:15 - 19:45'
}
}
}

cannot find the config file I need

yarn start creates:
Error authByEmail
{
errors: [ { code: 'VALIDATION_ERROR', message: 'email must not be blank' } ]
}

im guessing i need to put the info in some config file but I have checken every folder and can't find it

Issue on configuration

Hello everyone,

I'm getting an issue trying to configure my email address. I've installed correctly the chatbot in telegram. I've put the token on the .env.local.

But when I start the application through pycharm (yarn start) :
(venv) PS C:\Users\dcsfdsf\PycharmProjects\TGTG\toogoodtogo-bot> yarn start
yarn run v1.22.19
$ node ./dist/src/index.js
Click on the link in your email.
Click on the link in your email.
Click on the link in your email.

Even if i click on the login page in my email, the message is still looping on the console : "Click on the link in your email." so i don't think my authentification is working.
I've tried to disconnect my account in TGTG iOS application, but it is not working neither.

What can I do now ?

Thanks !

Not working ?

Hello
I’ve set everything including telegram bot but I got no notifications.

I know it works because I got that email from TGTG that says a new device has connected but no notifications...

any ideas ?
Thanks

no notifications

Could you please help, i followed every step, but it doesn't work, i have no notifications in telegram. Thanks

Docker container build error

Sending build context to Docker daemon 385kB
Step 1/8 : FROM node:16-alpine
---> 0e1140518c5f
Step 2/8 : WORKDIR /app
---> Using cache
---> 13425d754208
Step 3/8 : COPY package.json yarn.lock ./
---> Using cache
---> 696b55c2888c
Step 4/8 : RUN yarn --frozen-lockfile
---> Using cache
---> b29a22dc8607
Step 5/8 : COPY . .
---> Using cache
---> 40e143f4e261
Step 6/8 : EXPOSE 3000
---> Using cache
---> eacf49cf89e1
Step 7/8 : RUN yarn build
---> Running in b102571378e0
yarn run v1.22.19
$ tsc
src/core/index.ts(6,20): error TS2307: Cannot find module '../../config/config.js' or its corresponding type declarations.
src/lib/console/index.ts(3,20): error TS2307: Cannot find module '../../../config/config.js' or its corresponding type declarations.
src/lib/dataManager/index.ts(7,20): error TS2307: Cannot find module '../../../config/config.js' or its corresponding type declarations.
src/lib/telegram/index.ts(1,20): error TS2307: Cannot find module '../../../config/config.js' or its corresponding type declarations.
src/services/API/config.ts(2,20): error TS2307: Cannot find module '../../../config/config.js' or its corresponding type declarations.
src/services/API/connect.ts(2,20): error TS2307: Cannot find module '../../../config/config.js' or its corresponding type declarations.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The command '/bin/sh -c yarn build' returned a non-zero code: 2

After Login Error authByRequestPollingID

After the login I got this error:

Error authByRequestPollingId
Error: ENOENT: no such file or directory, open './.storage/data.json'
at Object.openSync (node:fs:585:3)
at Object.writeFileSync (node:fs:2170:35)

What do I wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.