IMPROVEMENT: updated the connector to process-telegram-updates. new version allows telegram to know available commands
This commit is contained in:
parent
cc2af6c1ca
commit
bf1566e6a0
23
src/Makefile
23
src/Makefile
@ -1,7 +1,7 @@
|
||||
.SECONDARY:
|
||||
|
||||
|
||||
SHELL=/bin/bash -x
|
||||
SHELL=/bin/bash
|
||||
ROOT_DIR=/mnt/servers/aws.fredericofalcao.com/api.fredericofalcao.com/data/emails
|
||||
#SRC_EML_FILES=$(notdir $(shell find "$(ROOT_DIR)" -type f -name "*.eml" | head -n 2))
|
||||
LATEST_FILE:=$(shell find "$(ROOT_DIR)" -name "*.eml" -printf '%T@ %p\n' | sort -n | tail -1)
|
||||
@ -16,17 +16,20 @@ SRC_FILES=$(subst .score.txt,.notification.txt,$(SRC_SCORE_FILES))
|
||||
|
||||
all: $(SRC_FILES)
|
||||
|
||||
# 8. Upload telegram available bot commands
|
||||
upload-available-bot-commands: ../process-telegram-updates/commands/01_learn.inc.php ../process-telegram-updates/commands/02_memory.inc.php
|
||||
cd ../process-telegram-updates && make upload-available-commands
|
||||
|
||||
# 7. Processed received messages
|
||||
process-telegram-updates: ../process-telegram-updates/process_message.php
|
||||
cd ../process-telegram-updates && make
|
||||
process-telegram-updates: ../process-telegram-updates/commands/01_learn.inc.php ../process-telegram-updates/commands/02_memory.inc.php
|
||||
cd ../process-telegram-updates && make
|
||||
|
||||
|
||||
../process-telegram-updates/process_message.php:
|
||||
printf '%s\n' \
|
||||
'<?php function process_message(array $$from,array $$chat,string $$date,string $$text) { '\
|
||||
' if (substr($$text,0,7) == "/learn ") file_put_contents(__DIR__."/data/learnings.txt", substr($$text,7)."\n",FILE_APPEND); '\
|
||||
' if (substr($$text,0,7) == "/memory") telegram_send_text($$chat["id"],file_get_contents(__DIR__."/data/learnings.txt"));'\
|
||||
' }' > $@
|
||||
../process-telegram-updates/commands/02_memory.inc.php: .dummy
|
||||
echo '<?php return ["command"=>"/memories","description"=>"list all the memories","callback"=>function($$from,$$chat,$$date,$$text){telegram_send_text($$chat["id"],file_get_contents(__DIR__."/../data/learnings.txt"));}];' > $@
|
||||
|
||||
../process-telegram-updates/commands/01_learn.inc.php: .dummy
|
||||
echo '<?php return ["command"=>"/learn","description"=>"learn a new instruction","callback"=>function($$from,$$chat,$$date,$$text){file_put_contents(__DIR__."/../data/learnings.txt", substr($$text,7)."\n",FILE_APPEND);}];' > $@
|
||||
|
||||
|
||||
# 6. Run the MAIL-ROUTE script to either notify the user of a new message, or ignore
|
||||
@ -78,7 +81,7 @@ telegram_notification.log: email_message.eml
|
||||
-F caption="Here is your file 📎" \
|
||||
-F document="@$<" > $@
|
||||
|
||||
|
||||
.dummy:
|
||||
|
||||
clean:
|
||||
rm *.sys *.txt *.log *.eml
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user