From ab466756cc9d6c20ac9a785769be565a73fbd45b Mon Sep 17 00:00:00 2001 From: jesopo Date: Sun, 23 Jun 2019 11:23:52 +0100 Subject: [PATCH] Handle `CAP ACK -` and ACK from a REQ not sent by ircv3.py --- modules/line_handler/ircv3.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/modules/line_handler/ircv3.py b/modules/line_handler/ircv3.py index 9441f165..488af1dd 100644 --- a/modules/line_handler/ircv3.py +++ b/modules/line_handler/ircv3.py @@ -84,7 +84,12 @@ def cap(exports, events, event): events.on("received.cap.del").call(server=event["server"], capabilities=capabilities) elif subcommand == "ACK": - event["server"].agreed_capabilities.update(capabilities) + for cap_name, cap_args in capabilities.items(): + if cap_name[0] == "-": + event["server"].agreed_capabilities.discard(cap_name[1:]) + else: + event["server"].agreed_capabilities.add(cap_name) + events.on("received.cap.ack").call(capabilities=capabilities, server=event["server"]) @@ -115,12 +120,13 @@ def cap(exports, events, event): if subcommand == "ACK" or subcommand == "NAK": ack = subcommand == "ACK" for capability in capabilities: - cap_obj = event["server"].capabilities_requested[capability] - del event["server"].capabilities_requested[capability] - if ack: - cap_obj.ack() - else: - cap_obj.nak() + if capability in event["server"].capabilities_requested: + cap_obj = event["server"].capabilities_requested[capability] + del event["server"].capabilities_requested[capability] + if ack: + cap_obj.ack() + else: + cap_obj.nak() if (not event["server"].capabilities_requested and not event["server"].waiting_for_capabilities()):