Fix previous "lingering bot" bug
When using !spawnevil on @TestSummoner, the @TestSpawn which was created would reconnect to the room because of faulty logic in room._run(). This would cause a few errors to occur. Fixed now!
This commit is contained in:
parent
1c3b9d0a20
commit
b8bb75a897
3 changed files with 10 additions and 7 deletions
|
|
@ -33,6 +33,8 @@ class Connection:
|
|||
Returns the task listening for packets, or None if the attempt failed.
|
||||
"""
|
||||
|
||||
logger.debug(f"Attempting to connect, max_tries={max_tries}")
|
||||
|
||||
await self.stop()
|
||||
|
||||
tries_left = max_tries
|
||||
|
|
@ -147,7 +149,7 @@ class Connection:
|
|||
#else:
|
||||
#logger.debug(f"Deleting task: {task}")
|
||||
#self._spawned_tasks = tasks
|
||||
#self._spawned_tasks = {task for task in self._spawned_tasks if not task.done()} # TODO: Reenable
|
||||
self._spawned_tasks = {task for task in self._spawned_tasks if not task.done()} # TODO: Reenable
|
||||
|
||||
def _wait_for_response(self, pid):
|
||||
future = asyncio.Future()
|
||||
|
|
|
|||
|
|
@ -113,9 +113,9 @@ class Controller:
|
|||
|
||||
async def stop(self):
|
||||
if self.room:
|
||||
logger.info(f"&{self.room.roomname}: Stopping")
|
||||
logger.info(f"@{self.nick}: Stopping")
|
||||
await self.room.stop()
|
||||
logger.debug(f"&{self.room.roomname}: Stopped. Deleting room")
|
||||
logger.debug(f"@{self.nick}: Stopped. Deleting room")
|
||||
self.room = None
|
||||
|
||||
async def set_nick(self, nick):
|
||||
|
|
|
|||
|
|
@ -53,12 +53,13 @@ class Room:
|
|||
|
||||
async def _run(self, task, max_tries=10, delay=60):
|
||||
while not self._stopping:
|
||||
if task.done():
|
||||
task = await self._conn.connect(max_tries=max_tries, delay=delay)
|
||||
if not task:
|
||||
return
|
||||
|
||||
await task
|
||||
await self.controller.on_disconnected()
|
||||
|
||||
task = await self._conn.connect(max_tries=max_tries, delay=delay)
|
||||
if not task:
|
||||
return
|
||||
|
||||
self.stopping = False
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue