Add a way to more explicitly denote when a CAP handshake has ended early
This commit is contained in:
parent
a2292eb439
commit
4bab1aea30
3 changed files with 9 additions and 6 deletions
|
@ -265,6 +265,7 @@ class Module(ModuleManager.BaseModule):
|
|||
is_multiline = len(event["args"]) > 2 and event["args"][2] == "*"
|
||||
|
||||
if subcommand == "ls":
|
||||
event["server"].cap_started = True
|
||||
event["server"].server_capabilities.update(capabilities)
|
||||
if not is_multiline:
|
||||
matched_capabilities = set(event["server"
|
||||
|
@ -292,13 +293,14 @@ class Module(ModuleManager.BaseModule):
|
|||
elif subcommand == "ack":
|
||||
event["server"].capabilities.update(capabilities)
|
||||
if not is_multiline:
|
||||
results = self.events.on("received.cap.ack").call(
|
||||
self.events.on("received.cap.ack").call(
|
||||
capabilities=event["server"].capabilities,
|
||||
server=event["server"])
|
||||
|
||||
if not False in results:
|
||||
if not event["server"].waiting_for_capabilities():
|
||||
event["server"].send_capability_end()
|
||||
if event["server"].cap_started and not event["server"
|
||||
].waiting_for_capabilities():
|
||||
event["server"].cap_started = False
|
||||
event["server"].send_capability_end()
|
||||
elif subcommand == "nack":
|
||||
event["server"].send_capability_end()
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class Module(ModuleManager.BaseModule):
|
|||
username, token = self._get_token(event["server"])
|
||||
if CAP in event["capabilities"] and username and token:
|
||||
event["server"].send("RESUME %s %s" % (username, token))
|
||||
return False
|
||||
event["server"].cap_started = False
|
||||
|
||||
@utils.hook("received.resume")
|
||||
def on_resume(self, event):
|
||||
|
|
|
@ -26,6 +26,7 @@ class Server(IRCObject.Object):
|
|||
self.capabilities = set([]) # type: typing.Set[str]
|
||||
self.server_capabilities = {} # type: typing.Dict[str, str]
|
||||
self.batches = {} # type: typing.Dict[str, utils.irc.IRCLine]
|
||||
self.cap_started = False
|
||||
|
||||
self.write_buffer = b""
|
||||
self.buffered_lines = [] # type: typing.List[bytes]
|
||||
|
@ -361,7 +362,7 @@ class Server(IRCObject.Object):
|
|||
self._capabilities_waiting.add(capability)
|
||||
def capability_done(self, capability: str):
|
||||
self._capabilities_waiting.remove(capability)
|
||||
if not self._capabilities_waiting:
|
||||
if self.cap_started and not self._capabilities_waiting:
|
||||
self.send_capability_end()
|
||||
|
||||
def send_pass(self, password: str):
|
||||
|
|
Loading…
Reference in a new issue