diff --git a/src/irc/ConnectionInstance.ts b/src/irc/ConnectionInstance.ts index dd50f90f5..07c7a1041 100644 --- a/src/irc/ConnectionInstance.ts +++ b/src/irc/ConnectionInstance.ts @@ -107,7 +107,7 @@ export class ConnectionInstance { * connect. * @return {Promise} Resolves if connected; rejects if failed to connect. */ - public connect(): Promise { + public connect(onConnect: () => void): Promise { if (this.dead) { throw new Error("connect() called on dead client: " + this.nick); } @@ -128,6 +128,7 @@ export class ConnectionInstance { this.state = "connected"; this.resetPingSendTimer(); this.connectDefer.resolve(this); + onConnect() }); return this.connectDefer.promise; } @@ -379,7 +380,13 @@ export class ConnectionInstance { if (onCreatedCallback) { onCreatedCallback(inst); } - return inst.connect(); + const onConnect = () => { + if (opts.password && !server.useSasl()) { + nodeClient.say("NickServ", "IDENTIFY " + opts.password); + } + } + const conn = inst.connect(onConnect); + return conn; }; let connAttempts = 0;