public function login($nick, $password = null) {
		if ($password) {
			if (!$this->connection->send("PASS {$password}")) {
				throw new \RuntimeException(
					"failed to send password to {$this->server}");
			}
		} else {
			if (!$this->connection->send("PASS NOPASS")) {
				throw new \RuntimeException(
					"failed to send nopass to {$this->server}");
			}
		}
		
		if (!$this->connection->send("NICK {$nick}")) {
			throw new \RuntimeException(
				"failed to set nick {$nick} on {$this->server}");
		}
		
		$this->loop(false);
		
		if (!$this->connection->send("USER {$nick} AS IRC BOT")) {
			throw new \RuntimeException(
				"failed to set user {$nick} on {$this->server}");
		}
		
		$this->loop(false);
		
		return $this;
	}