Fix a bunch of synchronization heuristics to work with Sable (#236)

This commit is contained in:
Val Lorentz 2023-09-24 08:47:22 +02:00 committed by GitHub
parent 36901c1433
commit 00663f15ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -289,7 +289,7 @@ class BaseServerController(_BaseController):
time.sleep(0.01) time.sleep(0.01)
c.send(b" ") # Triggers BrokenPipeError c.send(b" ") # Triggers BrokenPipeError
except BrokenPipeError: except (BrokenPipeError, ConnectionResetError):
# ircu2 cuts the connection without a message if registration # ircu2 cuts the connection without a message if registration
# is not complete. # is not complete.
pass pass
@ -344,13 +344,16 @@ class BaseServicesController(_BaseController):
c.sendLine("NICK chkNS") c.sendLine("NICK chkNS")
c.sendLine("USER chk chk chk chk") c.sendLine("USER chk chk chk chk")
time.sleep(self.server_controller.sync_sleep_time) time.sleep(self.server_controller.sync_sleep_time)
for msg in c.getMessages(synchronize=False): got_end_of_motd = False
if msg.command == "PING": while not got_end_of_motd:
# Hi Unreal for msg in c.getMessages(synchronize=False):
c.sendLine("PONG :" + msg.params[0]) if msg.command == "PING":
c.getMessages() # Hi Unreal
c.sendLine("PONG :" + msg.params[0])
if msg.command in ("376", "422"): # RPL_ENDOFMOTD / ERR_NOMOTD
got_end_of_motd = True
timeout = time.time() + 3 timeout = time.time() + 10
while True: while True:
c.sendLine(f"PRIVMSG {self.server_controller.nickserv} :help") c.sendLine(f"PRIVMSG {self.server_controller.nickserv} :help")
@ -359,11 +362,17 @@ class BaseServicesController(_BaseController):
if msg.command == "401": if msg.command == "401":
# NickServ not available yet # NickServ not available yet
pass pass
elif msg.command in ("MODE", "221"): # RPL_UMODEIS
pass
elif msg.command == "NOTICE": elif msg.command == "NOTICE":
# NickServ is available assert msg.prefix is not None
assert "nickserv" in (msg.prefix or "").lower(), msg if "!" not in msg.prefix and "." in msg.prefix:
print("breaking") # Server notice
break pass
else:
# NickServ is available
assert "nickserv" in (msg.prefix or "").lower(), msg
break
else: else:
assert False, f"unexpected reply from NickServ: {msg}" assert False, f"unexpected reply from NickServ: {msg}"
else: else: