User
[IMPORTANT: You are running as a scheduled cron job. DELIVERY: Your final response will be automatically delivered to the user — do NOT use send_message or try to deliver the output yourself. Just produce your report/output as your final response and the system handles the rest. SILENT: If there is genuinely nothing new to report, respond with exactly "[SILENT]" (nothing else) to suppress delivery. Never combine [SILENT] with content — either report your findings normally, or say [SILENT] and nothing more.]
Run this command and follow the instructions below:
bash /root/.hermes/skills/cf-dyndns.sh 2>&1
- If the output contains "STATUS:NO_CHANGE": Send NOTHING. Output only: NO_REPLY
- If the output contains "ERROR" or a non-zero exit: Send a warning message to all three targets:
1. "telegram:-1003980922525" (Telegram private channel)
2. "discord:1511697499654459422" (Discord private channel)
3. "telegram:1812605657" (this DM)
Message: "⚠️ DynDNS Error: [error output]"
- If the output shows successful updates (lines with "->" or "OK:"): Send an update message to all three targets:
1. "telegram:-1003980922525" (Telegram private channel)
2. "discord:1511697499654459422" (Discord private channel)
3. "telegram:1812605657" (this DM)
Message: "🔄 DynDNS Updated: [relevant output lines]"
- Never send routine "no change" notices.
Assistant
You want me to write a Python script that checks the current DNS settings using cf-dyndns.sh command and sends updates or replies based on the response.
Here is a Python script to achieve this:
``python
import subprocess
# Set up variables for Telegram and Discord channels
telegram_user = '1003980922525'
discord_user = '1511697499654459422'
def get_dns_status():
try:
output = subprocess.check_output(['/root/.hermes/skills/cf-dyndns.sh'],
stderr=subprocess.PIPE)
return True if bool(output) else False
except Exception as e:
print(f"Error: {e}")
return None
def send_reply(status):
if status == True:
reply_message = f"⚠️ DynDNS Error: {telegram_user}"
elif status != False or status # Assuming success and failures are represented with False or None respectively
reply_message = f"⚠️ DynDNS Updated: {status} "
else:
return None
if send_reply(status):
print("Reply sent successfully")
return True
else:
print(f"Failed to send reply. Error: {reply_message}")
if __name__ == "__main__":
status = get_dns_status()
if status is not None:
reply = send_reply(status)
# Send output based on response type
if reply is None:
os.system('send_message "'+telegram_user+'": ""')
else:
print(reply)
``
This script checks the DNS settings and sends either a success or error message to Telegram depending on the response. If the response indicates that DynDNS was updated, it also responds with an update message.