Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion asyncirc/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@ async def _internal_cap_handler(conn: 'IrcProtocol', message: 'Message'):
if enabled:
handlers = filter(None, conn.cap_handlers[cap.name])
await asyncio.gather(*[func(conn, cap) for func in handlers])

if all(val[1] is not None for val in conn.server.caps.values()):
conn.send("CAP END")
# If SASL is enabled, SASL negotiation should be complete before sending CAP END,
# so this is done in the SASL handler.
if conn.sasl_mech == SASLMechanism.NONE:
conn.send("CAP END")

elif message.parameters[1] == 'LIST':
if conn.logger:
conn.logger.info("Current Capabilities: %s", caplist)
Expand Down Expand Up @@ -117,6 +122,11 @@ async def _do_sasl(conn: 'IrcProtocol', cap):
# TODO log SASL response
await conn.wait_for('902', '903', '904', '905', '906', '907', '908', timeout=30)

# Send CAP END here, because it shouldn't be sent before SASL auth is complete
# NOTE: there is a (probably unlikely) race condition here, if CAP negotiation is
# incomplete by this point.
conn.send("CAP END")


async def _isupport_handler(conn: 'IrcProtocol', message: 'Message'):
tokens = message.parameters[1:-1] # Remove the nick and trailing ':are supported by this server' message
Expand Down