1
0
mirror of https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks.git synced 2025-09-09 07:30:57 +02:00

Update telegram-bot-daemon.sh

telegram_alert_type belongs to the motion configuration, make video alert mode configurable
This commit is contained in:
jmtatsch
2019-10-22 07:26:40 +02:00
committed by GitHub
parent 159ccef004
commit 87ab795331

View File

@@ -1,5 +1,7 @@
#!/bin/sh
. /system/sdcard/scripts/common_functions.sh
CURL="/system/sdcard/bin/curl"
LASTUPDATEFILE="/tmp/last_update_id"
TELEGRAM="/system/sdcard/bin/telegram"
@@ -20,25 +22,26 @@ sendMem() {
}
detectionOn() {
. /system/sdcard/scripts/common_functions.sh
motion_detection on && $TELEGRAM m "Motion detection started"
}
detectionOff() {
. /system/sdcard/scripts/common_functions.sh
motion_detection off && $TELEGRAM m "Motion detection stopped"
}
textAlerts() {
. /system/sdcard/scripts/common_functions.sh
rewrite_config /system/sdcard/config/telegram.conf telegram_alert_type "text"
$TELEGRAM m "Text alerts on motion detection"
rewrite_config /system/sdcard/config/motion.conf telegram_alert_type "text"
$TELEGRAM m "Text alerts on motion detection enabled"
}
imageAlerts() {
. /system/sdcard/scripts/common_functions.sh
rewrite_config /system/sdcard/config/telegram.conf telegram_alert_type "image"
$TELEGRAM m "Image alerts on motion detection"
rewrite_config /system/sdcard/config/motion.conf telegram_alert_type "image"
$TELEGRAM m "Image alerts on motion detection enabled"
}
videoAlerts() {
rewrite_config /system/sdcard/config/motion.conf telegram_alert_type "video"
$TELEGRAM m "Video alerts on motion detection enabled"
}
respond() {
@@ -51,7 +54,8 @@ respond() {
/off) detectionOff;;
/textalerts) textAlerts;;
/imagealerts) imageAlerts;;
/help | /start) $TELEGRAM m "######### Bot commands #########\n# /mem - show memory information\n# /shot - take a shot\n# /on - motion detect on\n# /off - motion detect off\n# /textalerts - Text alerts on motion detection\n# /imagealerts - Image alerts on motion detection";;
/videoalerts) videoAlerts;;
/help | /start) $TELEGRAM m "######### Bot commands #########\n# /mem - show memory information\n# /shot - take a snapshot\n# /on - motion detect on\n# /off - motion detect off\n# /textalerts - Text alerts on motion detection\n# /imagealerts - Image alerts on motion detection"\n# /videoalerts - Video alerts on motion detection;;
*) $TELEGRAM m "I can't respond to '$cmd' command"
esac
}
@@ -90,7 +94,7 @@ main() {
if [ "$chatId" != "$userChatId" ]; then
username=$(echo "$json" | $JQ -r ".result[0].$messageAttr.from.username // \"\"")
firstName=$(echo "$json" | $JQ -r ".result[0].$messageAttr.from.first_name // \"\"")
$TELEGRAM m "Received message from not authrized chat: $chatId\nUser: $username($firstName)\nMessage: $cmd"
$TELEGRAM m "Received message from unauthorized chat: $chatId\nUser: $username($firstName)\nMessage: $cmd"
else
respond $cmd
fi;