http://telegram.me/ComedoresUGRbot
Telegram bot to check the menu of Universidad de Granada dining hall. It works thanks to pyTelegramBotAPI and puppeteer.
Puppeteer is used to launch a headless Chrome browser, find menu tables and save them as png images. This implementation can be maintained more easily, because scu.ugr.es DOM has been changing a lot and parse the data in the tables seems to be more problematic. I made a request to them in order to get a simple JSON API for developers and they answered that they would consider it, but for the moment it's necessary to parse scu.ugr.es DOM one way or another.
The easiest way to run the bot is using Docker. This handles all dependencies automatically:
-
Create a
.envfile from the example:cp .env.example .env
-
Edit
.envand add your bot token and the UGR dining hall URL:BOT_TOKEN=your_bot_token_here COMEDORES_URL=https://scu.ugr.es/pages/menu/comedor
-
Create the data directory:
mkdir -p data
-
Start the bot:
docker-compose up -d
Useful commands:
- View logs:
docker-compose logs -f - Stop bot:
docker-compose down - Restart bot:
docker-compose restart - Rebuild after changes:
docker-compose up -d --build
First of all, you need Python 3 correctly installed on your machine.
-
Create and activate a virtual environment:
# Create virtual environment python3 -m venv venv # Activate it (Linux/macOS) source venv/bin/activate
-
Install Python dependencies:
pip install -r requirements.txt
-
Install Node.js dependencies:
npm install
-
Test the renderer (optional):
node renderer.js
Verify that menu tables are being saved in
./images-newfolder. -
Configure environment variables:
Create a
.envfile:cp .env.example .env
Edit it with your configuration:
BOT_TOKEN=your_bot_token_here COMEDORES_URL=https://scu.ugr.es/
-
Run the bot:
python3 bot.py
All should work okay. Menu images are updated every hour.
Code licensed under GPLv3. See LICENSE file for more information.