Commit e362f198 authored by David Marzal's avatar David Marzal 🐧
Browse files

Borrar todos los preavisos

parent c1f5ea0d
#!/bin/bash
set -eEuo pipefail
# chmod 570 /usr/local/bin/vigilantecasero.sh && chown motion:root /usr/local/bin/vigilantecasero.sh
# 2020-10-13
# 2021-02-17
# Script que puede ser lanzado por un evento de motion cada vez que detecte movimiento
# Get helper functions
......@@ -104,7 +104,7 @@ f_t_foto () {
local foto=${1:-$v_argumento}
local caption=${2:-}
f_pinta H "Mandando foto: $foto"
curl -s -F "photo=@$foto" -F "caption=$caption" -F "chat_id=$ID" "$URL/sendphoto" || f_pinta W "Error ($?) mandando la foto: $foto en linea $LINENO"
MESSAGEF_ID=$(curl -s -F "photo=@$foto" -F "caption=$caption" -F "chat_id=$ID" "$URL/sendphoto" | grep -oP '(?<=message_id":)[^,]*')
}
f_t_delete () {
......@@ -175,16 +175,22 @@ f_preaviso () {
if [[ $V_PRESENCIA = "false" ]] ; then
[[ $DEPURA = false ]] || f_pinta W "PREAVISO($evento) de movimiento."
f_t_mensaje "$msg_preaviso" && echo "$MESSAGE_ID" > $PREAVISO
f_fichero_usable $FILESNAP && f_t_foto "$FILESNAP" "$msg_preaviso"
f_fichero_usable $FILESNAP && f_t_foto "$FILESNAP" "$msg_preaviso" && echo "$MESSAGEF_ID" >> $PREAVISO
for _ in $(seq $NUMFOTOEXTRA) ; do
f_take_manualsnap && f_t_foto "$FILESNAP" "$msg_preaviso"
f_take_manualsnap && f_t_foto "$FILESNAP" "$msg_preaviso" && echo "$MESSAGEF_ID" >> $PREAVISO
done
fi
f_borraf "$FILESNAP"
}
f_vigila () {
f_fichero_usable $PREAVISO && f_t_delete "$(cat $PREAVISO)" && f_borraf "$PREAVISO"
#f_fichero_usable $PREAVISO && f_t_delete "$(cat $PREAVISO)" && f_borraf "$PREAVISO"
if f_fichero_usable $PREAVISO; then
while IFS= read -r line; do
f_t_delete "$line"
done < $PREAVISO
f_borraf "$PREAVISO"
fi
f_estamosencasa
if [[ $V_PRESENCIA = "true" ]] ; then
if [[ $(find "$PRESENTE" -cmin +${TIEMPOMIN}) ]] || [[ ! -f $PRESENTE ]] ; then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment