Given you want to communicate thru FIFOs, here's simple example implementation of recvUpdate()
plus initialization code.
recvUpdate() {
local text=$(msg .text)
[[ $text != null ]] || return
echo "$text" > "$outputPipe"
local chatId=$(msg .chat.id)
telegramApi sendChatAction chat_id=$chatId action=typing
telegramApi sendMessage chat_id=$chatId text="$(< "$inputPipe")"
}
inputPipe=$BOT_DIR/in.pipe
outputPipe=$BOT_DIR/out.pipe
[[ -p $inputPipe ]] || mkfifo "$inputPipe"
[[ -p $outputPipe ]] || mkfifo "$outputPipe"
Then, to read the top message: cat "$BOT_DIR/out.pipe"
, and to answer: echo "Hello" > "$BOT_DIR/in.pipe"
.
Here's example code :
while true; do
message=$(cat out.pipe)
echo "roger that" > in.pipe
done