Well, SASL on IRC is based on the Client CAPability Negotiation.
According to this specification you send a CAP LS
at the beginning, after this you send the USER
and NICK
. If you recive a CAP
response before the end of the motd/motd missing, the server supports CAP. Check if SASL is on the list of supported extensions, and request it.
If you get the end of motd/motd missing first, the server does not support CAP, and therefore does not support SASL.