27 lines
742 B
Makefile
27 lines
742 B
Makefile
include .env
|
|
export
|
|
SHELL=/bin/bash
|
|
|
|
|
|
ALL_UPDATE_IDS_SRC=$(shell ls data/*.update_id.json)
|
|
ALL_UPDATE_IDS=$(subst .update_id,.processed_id,$(ALL_UPDATE_IDS_SRC))
|
|
|
|
|
|
|
|
process_updates: $(ALL_UPDATE_IDS)
|
|
|
|
%.processed_id.json: %.update_id.json process_message.php
|
|
@echo "<?php require __DIR__.'/lib/main.php'; require 'process_message.php'; extract(json_decode(file_get_contents('$<'),1)[\"message\"]); process_message(\$$from, \$$chat, \$$date, \$$text);" | php > $@
|
|
|
|
|
|
fetch_updates:
|
|
curl -s "https://api.telegram.org/bot$(TELEGRAM_BOT_TOKEN)/getUpdates" \
|
|
| jq -c '.result[]' \
|
|
| while read -r update_msg; \
|
|
do \
|
|
echo $$update_msg > data/$$(echo $$update_msg | jq -c '.update_id').update_id.json; \
|
|
done
|
|
|
|
clean:
|
|
rm data/*.json
|