From 5991e02b0a234a138897007fa369cedaba2251e9 Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 5 Feb 2019 19:20:02 +0000 Subject: [PATCH] Manually count ACK/NAK for REQed CAPs before ENDing CAP negotiation --- modules/line_handler.py | 19 +++++++++---------- src/IRCServer.py | 2 ++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/line_handler.py b/modules/line_handler.py index cb5d5631..7a692bd1 100644 --- a/modules/line_handler.py +++ b/modules/line_handler.py @@ -314,17 +314,16 @@ class Module(ModuleManager.BaseModule): capabilities=capabilities) elif subcommand == "ack": event["server"].capabilities.update(capabilities) - if not is_multiline: - self._event(event, "cap.ack", - capabilities=event["server"].capabilities, - server=event["server"]) + self._event(event, "cap.ack", capabilities=capabilities, + server=event["server"]) - 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() + if subcommand == "ack" or subcommand == "nak": + for capability in capabilities: + event["server"].requested_capabilities.remove(capability) + if (event["server"].cap_started and + not event["server"].waiting_for_capabilities()): + event["server"].cap_started = False + event["server"].send_capability_end() # the server is asking for authentication @utils.hook("raw.received.authenticate") diff --git a/src/IRCServer.py b/src/IRCServer.py index 69235f54..c01c83f5 100644 --- a/src/IRCServer.py +++ b/src/IRCServer.py @@ -30,6 +30,7 @@ class Server(IRCObject.Object): self._capability_queue = set([]) # type: typing.Set[str] self._capabilities_waiting = set([]) # type: typing.Set[str] self.capabilities = set([]) # type: typing.Set[str] + self.requested_capabilities = [] # type: typing.List[str] self.server_capabilities = {} # type: typing.Dict[str, str] self.batches = {} # type: typing.Dict[str, utils.irc.IRCLine] self.cap_started = False @@ -363,6 +364,7 @@ class Server(IRCObject.Object): def send_capability_queue(self): if self.has_capability_queue(): capabilities = " ".join(self._capability_queue) + self.requested_capabilities = list(self._capability_queue) self._capability_queue.clear() self.send_capability_request(capabilities) def has_capability_queue(self):