You can replace the problematic
web_search functions with a new function that delivers information to the targets specified in the
cf-dyndns.sh script without actually fetching the data from the web due to performance issues.
Here's how you could write this new function:
``
python
import logging
def deliver_data(target_id, target_name):
logger = logging.getLogger()
logger.setLevel(logging.INFO)
if target_user_id := input(f"Enter your Telegram or Discord username:{target_name} (e.g. 1234567890):"):
user = eval(f"https://api.telegram.org/bot{target_user_id}")
chat = await user.getChat(chat_id=target_id)
logger.info(f"{'OK' if message else 'Error'}: {message}")
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
def deliver_to_targets(message, target_ids, target_names):
for (user, id), name in zip(target_ids, target_names):
await client.send_message(
chat_id=target_user_id,
message=name,
reply_to=None # Use this chat ID to ignore replies
)
# Set up the Hermes client instance:
HERMES_CLIENT = Client()
def cf_dyndns_sh():
logger.info("Starting DynDNS checker...")
# Run the /root/.hermes/skills/cf-dyndns.sh script as a new process...
result = subprocess.run(
"/root/.hermes/skills/cf.dynnds.sh",
stdout=subprocess.PIPE
)
if 'STATUS:NO_CHANGE' in str(result.stdout):
logger.info("DynDNS Checker: sent NO_REPLY to all targets")
return
for target_id, target_name in ([" telegram:-1003980922525", "discord:1511697499654459422", f"telegram:{target_user_id}"])[:]:
message = "-> DynDNS Updated:" + result.stdout
deliver_to_targets(message, [target_id], [target_name])
logger.info("DynDNS Checker: sent updates for all targets")
cf_dyndns_sh()
``