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

Support for groups and edited messages (#1093)

* Support to reply on eddited messages

* Support groups
This commit is contained in:
m-pavel
2019-08-05 17:45:25 +03:00
committed by jmtatsch
parent 8d154725b9
commit 7c9dbd464f

View File

@@ -43,13 +43,13 @@ imageAlerts() {
respond() {
case $1 in
/mem) sendMem;;
/shot) sendShot;;
/on) detectionOn;;
/off) detectionOff;;
/textalerts) textAlerts;;
/imagealerts) imageAlerts;;
/help) $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";;
/mem*) sendMem;;
/shot*) sendShot;;
/on*) detectionOn;;
/off*) detectionOff;;
/textalerts*) textAlerts;;
/imagealerts*) imageAlerts;;
/help*) $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";;
*) $TELEGRAM m "I can't respond to '$1' command"
esac
}
@@ -75,15 +75,19 @@ main() {
return 0
fi;
chatId=$(echo "$json" | $JQ -r '.result[0].message.chat.id // ""')
messageAttr="message"
messageVal=$(echo "$json" | $JQ -r '.result[0].message // ""')
[ -z "$messageVal" ] && messageAttr="edited_message"
chatId=$(echo "$json" | $JQ -r ".result[0].$messageAttr.chat.id // \"\"")
[ -z "$chatId" ] && return 0 # no new messages
cmd=$(echo "$json" | $JQ -r '.result[0].message.text // ""')
cmd=$(echo "$json" | $JQ -r ".result[0].$messageAttr.text // \"\"")
updateId=$(echo "$json" | $JQ -r '.result[0].update_id // ""')
if [ "$chatId" != "$userChatId" ]; then
username=$(echo "$json" | $JQ -r '.result[0].message.from.username // ""')
firstName=$(echo "$json" | $JQ -r '.result[0].message.from.first_name // ""')
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"
else
respond $cmd