This command is used to check the status of multiple DynaDNS domains simultaneously, sending a message on each domain if the update is successful.
Here's how you can use this command with Python:
``
python
import subprocess
from datetime import datetime
# Define domains and credentials for each domain
domains = {
"test1": {"url": "http://example.com", "token": "***"},
"test2": {"url": "example.net", "token": "***"}
}
# Function to check DynaDNS status of a single domain
def get_dyndns_status(domain):
# Define credentials for the current domain
cred = domains[domain]
# Execute the command to get the current DynaDNS status (e.g., change, update)
status_command = f"status {cred['url']}"
output = subprocess.check_output(status_command, shell=True).decode('utf-8')
# Check if the output shows "CHANGE:NO_CHANGE" or "ERROR"
if "CHANGE:NO_CHANGED" in output:
return False
elif "ERROR" in output:
# Send a notification to all targets if there's an error
notifications = {
"telegram": {"chan_id": 123456789},
"discord": {"channel_id": 345678901},
"this_dms": ["this DM"]
}
for target, recipients in notifications.items():
message = f"โ ๏ธ DynDNS Error: {output}"
if not self.send_message(target, message):
return False
elif output.strip() == "":
# If there's no change or error, send a notification to all targets
notifications = {
"telegram": {"chan_id": 123456789},
"discord": {"channel_id": 345678901},
"this_dms": ["this DM"]
}
for target, recipients in notifications.items():
message = f"๐ DynDNS Updated: {output}"
if not self.send_message(target, message):
return False
# If there's no change or error, send a notification to all targets
notifications = {
"telegram": {"chan_id": 123456789},
"discord": {"channel_id": 345678901},
"this_dms": ["this DM"]
}
for target, recipients in notifications.items():
message = f"โ ๏ธ DynDNS Updated: {output}"
if not self.send_message(target, message):
return False
return True
# Check all domains and send notifications accordingly
all_domains_status = []
for domain in domains:
current_status = get_dyndns_status(domain)
all_domains_status.append(current_status)
# Print results (only if at least one domain shows a successful update)
if any(all_domains_status):
print("At least one DynaDNS domain was successfully updated:")
# Remove this line if you don't want to see the details of each domain's status
print(all_domains_status)
else:
print("\nNo DynaDNS domains were found.")
`
Replace domains
with your actual set of DynaDNS domains and their respective credentials in the script. The get_dyndns_status` function checks the current state of a single DynaDNS domain by calling the command to get its status (e.g., change, update). If any destination has a status that shows "CHANGE:NO_CHANGED" or an error message other than no change at all, notifications are sent accordingly.
The script will then check all domains for successful updates.