# caFICtería-aaS (bot)

This is the bot that actually scrapes the menus from Telegram and puts them in a JSON file.

## ⚙️ Usage

- `get_history.py` will download all messages on the channel and parse them (2018-now). Should be run when you install everything (I guess you can skip this if you don't love data 😔).
    - This will also include the menus sent in photos during a few days in July 2022 (manually parsed in `menu_photos_history.json`).
- `bot_listen.py` will listen for new messages on the channel, and parse them when received. This is what should be running to fetch the messages received after the initial run of `get_history.py`.

## 🔧 Environment Variables

| Name                     | Required | Description |
|--------------------------|----------|-------------|
| `TG_API_ID`              |    YES   | Your telegram API Id |
| `TG_API_HASH`            |    YES   | Your telegram API Hash |
| `TG_SESSION_NAME`        |    NO    | The telethon session name/path _(Default: "default")_ |
| `TG_CHANNEL_NAME`        |    NO    | The channel where the menu info is stored _(Default: "CafeteriaFIC")_ |
| `MENU_HISTORY_FILE_PATH` |    NO    | The place where the JSON file with the menu history will be stored. _(Default: "/tmp/menu_history.json")_ |

_**Tip💡:**_ Look at [Telethon documentation](https://docs.telethon.dev/en/stable/basic/signing-in.html#signing-in) for info about the telegram authentication process

## 🐳 Building the Docker image

```bash
git clone https://git.peprolinbot.com/peprolinbot/caFICteria-aaS.git
cd caFICteria-aaS/bot
docker build -t caficteria-bot .
```