psychs/limechat — pull request #195 by moshee (2013-12-13 08:58:16+00:00)
Title: Fix server capabilities handling

Sometimes users want to enable stuff like ZNC server-time without using SASL. The old assumption that some servers just randomly reject connections when `CAP REQ` is sent before PASS seems to have been somewhat mistaken. According to [the current spec][1], all we need is to send `CAP END` after `CAP REQ` to continue logging in.

[1]: http://ircv3.atheme.org/specification/capability-negotiation-3.1

So instead of testing for SASL being enabled before requesting any capabilities at all, I've moved the `CAP REQ`s to the receiveCap handler so that the client only requests capabilities that are supported by the server. While this isn't strictly necessary (the server will just send `CAP NAK`s) it's probably a good thing™. This also puts all the cap handling in one place.

Tested (works) with ZNC 1.0, hybrid, charybdis, ircd-seven (Freenode).