From 1b3c537e0a805d924575a90bf5700cc0f8e0e217 Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 2 Apr 2020 18:43:59 +0100 Subject: [PATCH] only try SASL on CAP NEW when one of the new CAPs is SASL --- ircrobots/server.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ircrobots/server.py b/ircrobots/server.py index 8c06f2f..f8a9bc9 100644 --- a/ircrobots/server.py +++ b/ircrobots/server.py @@ -68,7 +68,7 @@ class Server(IServer): elif emit.subcommand in ["ACK", "NAK"]: await self._cap_ack(emit) elif emit.subcommand == "NEW": - await self._cap_new() + await self._cap_new(emit) async def _on_read_line(self, line: Line): for i, (response, future) in enumerate(self._wait_for): @@ -137,8 +137,11 @@ class Server(IServer): if not self._requested_caps: await self.send(build("CAP", ["END"])) - async def _cap_new(self): - await self._maybe_sasl() + async def _cap_new(self, emit: Emit): + if not emit.tokens is None: + tokens = [t.split("=", 1)[0] for t in emit.tokens] + if CAP_SASL.available(tokens): + await self._maybe_sasl() async def _maybe_sasl(self) -> bool: if (self.sasl_state == SASLResult.NONE and