28 lines
1022 B
Markdown
28 lines
1022 B
Markdown
# Telegram Bot Message Processor
|
||
|
||
This repository provides a simple PHP + Makefile setup to **fetch Telegram updates** and **process incoming messages**.
|
||
|
||
## Overview
|
||
- `process_message.php` – defines the function `process_message()` where you can add your own logic for handling incoming messages (sending replies, saving data, etc.).
|
||
- `Makefile` – automates fetching updates, processing them, and cleaning data files.
|
||
- `lib/main.php` – expected to contain helper functions like `telegram_send_text()` and `telegram_send_file()`.
|
||
|
||
## How It Works
|
||
1. **Fetch updates** : calls the Telegram Bot API (getUpdates) and stores raw JSON messages in data/*.update_id.json.
|
||
```bash
|
||
make fetch_updates
|
||
```
|
||
2. **Process updates** : each update is passed to process_message.php, where you can customize your bot’s behavior.
|
||
```bash
|
||
make process_updates
|
||
````
|
||
3. **Clean data** : removes all program generated files
|
||
```bash
|
||
make clean
|
||
````
|
||
|
||
|
||
## Requirements:
|
||
- PHP CLI
|
||
- jq (for parsing JSON in make fetch_updates)
|
||
- curl |