To handle the delivery of the report and respond in a timely manner, you should combine any non-delivery notifications with an additional message. For example:
* If the output contains "STATUS:NO_CHANGE": Send NOTHING.
* If the output contains "ERROR" or a non-zero exit:
* Add a warning message to all three targets:
- Telegram private channel: "โ ๏ธ DynDNS Error: [error output]"
- Discord private channel: "[warning text]"
- This DM (DM): "Please test the dynamic IP changes"
* If the output shows successful updates (lines with "->" or "OK:"):
* Send an update message to all three targets:
- Telegram private channel: "[update text]"
- Discord private channel: "[update text]"
- This DM: "[action taken details]"
Here's how you can modify your function
cf-dyndns.sh to handle these different types of output:
``
bash
#!/bin/bash
while IFS= read -r line; do
if [[ $line =~ "ERROR" ]]; then
send_replies "$line"
else
case $line in
"->"* ) send_dynnamss "$line";;
"- OK *" ) send_supdates "$line";;
*) send_no_change "$line";;
esac
done < <(web_extract "http://dyn.adsl.tivatm.is" "$2")
`
`
bash
#!/bin/bash
declare -A reply
while IFS= read -r line; do
if [[ $line =~ "ERROR" ]]; then
send_replies "${reply["error_message"]}" || reply="unknown error"
else
case $line in
"->"* ) send_dynnamss "$line";;
"- OK *" ) send_supdates "${reply["success_message"]}" || reply="success message";;
*) send_no_change "$line";;
esac
done
done < <(web_extract "http://dyn.adsl.tivatm.is" "$2")
`
**To make it more readable:**
`
bash
#!/bin/bash
declare -A reply
while IFS= read -r line; do
if [[ $line =~ "ERROR" ]]; then
# Send a notification to all three targets as an error message.
! echo "$(send_replies "$line")" > /dev/null;
else
case $line in
"->"* ) # Send only the updates message
send_dynnamss "$line" || reply=success;;
"- OK *" ) # Send only the success message
send_supdates "${reply['success_message']}" || reply="unknown";;
*) # For unknown inputs, just return an error
! echo "$(send_replies "$line") > /dev/null" ;;
esac
done
done < <(web_extract "http://dyn.adsl.tivatm.is" "$2")
`
Also please ensure that you have the necessary packages installed to run this script. You might need to add some apt-get
or other package manager commands depending on your Linux distribution.
**Always consider running such scripts inside a production environment and never execute them via cron job without proper validation:** Never combine [SILENT]` with additional output messages unless you have good reason not to send the message. If there's only one possible way for people to report issues, it is more helpful if they include any relevant information in their message about what changed so they can look through the history or investigate further.
Also remember that you should test your scripts thoroughly before releasing them as production code because of the simple fact that some errors will be silently lost to time and cannot easily be detected.