Skip to content

Commit

Permalink
Update telegram-bot-daemon.sh
Browse files Browse the repository at this point in the history
Fixxes EliasKotlyar#1470.
Its an assignement issue:
on Line 96, the variable messageVal is checked if empty, and if yes, messageAttr is set to "edited_message".
Now on line 97, messageVal is always set to a json value, which may not be there. This line should actually be added to line 96 after it has been checked, it the messageVal is empty.
This fix ensures that messageVal is only set to the json value of '.result[0].edited_message' if messageVal was empty before.
  • Loading branch information
cactushydrocodone authored Jun 8, 2020
1 parent 4a3ab3e commit 3061d9c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions firmware_mod/scripts/telegram-bot-daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ main() {

messageAttr="message"
messageVal=$(echo "$json" | $JQ -r '.result[0].message // ""')
[ -z "$messageVal" ] && messageAttr="edited_message"
messageVal=$(echo "$json" | $JQ -r '.result[0].edited_message // ""')
[ -z "$messageVal" ] && messageAttr="edited_message" && messageVal=$(echo "$json" | $JQ -r '.result[0].edited_message // ""')
[ -z "$messageVal" ] && messageAttr="channel_post"
chatId=$(echo "$json" | $JQ -r ".result[0].$messageAttr.chat.id // \"\"")
updateId=$(echo "$json" | $JQ -r '.result[0].update_id // ""')
Expand Down

0 comments on commit 3061d9c

Please sign in to comment.