diff --git a/.gitignore b/.gitignore index 788eb51..2ff42a7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ logs test.json elitebot .idea -venv \ No newline at end of file +venv +test.yaml \ No newline at end of file diff --git a/src/bot.py b/src/bot.py index 7951be4..3b29084 100644 --- a/src/bot.py +++ b/src/bot.py @@ -156,12 +156,21 @@ class Bot: self.connected = False return + async def send_ping(self): + while True: + await asyncio.sleep(60) + await self.ircsend(f'PING :{self.config["Connection"].get("Hostname")}') + async def start(self): + ping_task = None while True: if not self.connected: try: await self.connect() self.connected = True + # Start the ping task after the bot has connected + if ping_task is None or ping_task.done(): + ping_task = asyncio.create_task(self.send_ping()) except Exception as e: self.logger.error(f'Connection error: {e}') await asyncio.sleep(60)