To respond to the Telegram messages from dyn.discovery for updates, you can use Python and the
async2task library in combination with the Discord Bot Token obtained through settings like the Webhook token. Here's how your python script might look:
``
python
import asyncio
from async2task import task
# Get the dynamic DNS discovery information
dyn Discovery_info = dynamediscovery.DynDiscovery(
'dyndiscovery:static/dnnpc.json'
)
async def main():
def dyn_discovery(message):
# Here you're actually fetching from Dyn but this call doesn't make sense at first glance,
# since it is a POST, and we need its response instead,
return await asyncio.to_thread(
requests.post('https://dyn.discovery.service.dynDNS.com/discovery/update',
json={'ip_addresses': ['-i 192.0.2.1']},
timeout=2)
)
async def update_dns(name, zone):
try:
dyndiscovery_info = await dynamediscovery.DynDiscovery(
'dyndiscovery:static/dnnpc.json'
)
taskDynUpdate = dyndiscovery_info.start_update(name, zone)
await asyncio.to_thread(taskDynUpdate.run(), timeout=5)
except Exception as e:
print(f"Error during update: {e}")
tasks = []
for zone in ["-n root", "-t root"] :
try:
updates_needed = taskDynUpdate.update_dns(name, zone)
if ( updates_needed > 0 ):
tasks.append(update_dns(name, zone))
except Exception as e:
print(f"Error at zone {zone}: {e}")
try:
all_done = await asyncio.gather(*tasks)
for status in all_done:
if ("STATUS:YES" not in str(status)).upper():
print("DynDNS Error: [error message], Send a warning message to all three targets")
else:
print(' DynDNS Updated: [relevant output lines]')
except Exception as e:
print(f"An error occurred during the tasking: {e}")
`
Remember that you need the appropriate token to run this script, which can be obtained through webhooks with a specific service.
Please take note of this:
* requests.post
is an old request, so you should switch it into async context (asyncio.to_thread`) for better error handling.
* You should check out more information about updating your Hermes DynDNS and the necessary packages for the task above as there are specific things to have when running this.
Also note that please refer to the full python code attached with a tutorial on how to integrate dyn DNS discovery via webhook in Telegram in order to get all the details required for your specific setup.