From e5a1ac6897311e586b6ea240a084b8543f1803ab Mon Sep 17 00:00:00 2001 From: Firepup Sixfifty Date: Thu, 14 Nov 2024 10:39:10 -0600 Subject: [PATCH] Add a ping monitor, to prevent/recover from servers silently disconnecting --- config.py | 1 + threads.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index 25c796b..34229c2 100644 --- a/config.py +++ b/config.py @@ -52,6 +52,7 @@ servers: dict[str, dict[str, Any]] = { "address": "irc.underworld.no", "channels": {"#random": 0, "#dice": 0}, "hosts": ["154.sub-174-251-241.myvzw.com"], + "threads": ["pingMon"], "dnsblMode": "kickban", }, "replirc": { diff --git a/threads.py b/threads.py index c77a229..dca0c79 100644 --- a/threads.py +++ b/threads.py @@ -148,7 +148,12 @@ def radio(instance: bare.bot) -> NoReturn: instance.log("Thread while loop broken", "FATAL") exit(1) +def ping(instance: bare.bot) -> NoReturn: + while 1: + instance.sendraw("PING :keepalive") + sleep(30) data: dict[str, dict[str, Any]] = { - "radio": {"noWrap": True, "func": radio, "passInstance": True} + "radio": {"noWrap": True, "func": radio, "passInstance": True}, + "pingMon": {"noWrap": True, "func": ping, "passInstance": True} }