function NickServPlugin(bot) {
	var self = this;
	self.name = "nickserv";
	self.help = "NickServ plugin";
	self.depend = [];

	self.password = null;

	self.load = function(data) {
		self.password = data.password;
	};

	self.callbacks = {};
	self.identified = function(nick, callback) {
		if (!(nick in self.callbacks)) {
			bot.say("NickServ", "ACC " + nick + " *");
			self.callbacks[nick] = callback;
		}
	};

	self.nickCallbacks = {};
	self.nickIdentified = function(nick, callback) {
		if (!(nick in self.nickCallbacks)) {
			bot.say("NickServ", "ACC " + nick);
			self.nickCallbacks[nick] = callback;
		}
	};


	self.events = {
		"registered": function() {
			bot.say("NickServ", "IDENTIFY " + self.password);
		},

		"notice": function(nick, to, text) {
			if (nick == "NickServ") {
				var parts = text.split(" ");
				// multiple callbacks for same nick don't work
				if (parts[0] in self.callbacks) {
					self.callbacks[parts[0]](parts[4] == "3" ? parts[2] : null);
					delete self.callbacks[parts[0]];
				}
				else if (parts[0] in self.nickCallbacks) {
					self.nickCallbacks[parts[0]](parts[2] == "3");
					delete self.nickCallbacks[parts[0]];
				}
			}
		}
	};
}

module.exports = NickServPlugin;

@@ -612,41 +612,24 @@
 %7D;%0A%0A
-%0A
 %09self.
-events = %7B%0A%09%09%22registered%22:
+identify =
  fun
@@ -634,25 +634,24 @@
 unction() %7B%0A
-%09
 %09%09bot.say(%22N
@@ -690,16 +690,87 @@
 sword);%0A
+%09%7D;%0A%0A%09self.events = %7B%0A%09%09%22registered%22: function() %7B%0A%09%09%09self.identify();%0A
 %09%09%7D,%0A%0A%09%09

allow manually calling bot identification