/extensions/irc/js/lib/irc.js
JavaScript | 3790 lines | 2883 code | 550 blank | 357 comment | 516 complexity | 71aa5380f81e7bee862db20b8e42021b MD5 | raw file
Possible License(s): LGPL-3.0, MIT, BSD-3-Clause, MPL-2.0-no-copyleft-exception, GPL-2.0, LGPL-2.1
Large files files are truncated, but you can click here to view the full file
- /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is JSIRC Library.
- *
- * The Initial Developer of the Original Code is
- * New Dimensions Consulting, Inc.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Robert Ginda, rginda@ndcico.com, original author
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
- const JSIRC_ERR_NO_SOCKET = "JSIRCE:NS";
- const JSIRC_ERR_EXHAUSTED = "JSIRCE:E";
- const JSIRC_ERR_CANCELLED = "JSIRCE:C";
- const JSIRC_ERR_NO_SECURE = "JSIRCE:NO_SECURE";
- const JSIRC_ERR_OFFLINE = "JSIRCE:OFFLINE";
- const JSIRC_ERR_PAC_LOADING = "JSIRCE:PAC_LOADING";
- function userIsMe (user)
- {
- switch (user.TYPE)
- {
- case "IRCUser":
- return (user == user.parent.me);
- break;
- case "IRCChanUser":
- return (user.__proto__ == user.parent.parent.me);
- break;
- default:
- return false;
- }
- return false;
- }
- /*
- * Attached to event objects in onRawData
- */
- function decodeParam(number, charsetOrObject)
- {
- if (!charsetOrObject)
- charsetOrObject = this.currentObject;
- var rv = toUnicode(this.params[number], charsetOrObject);
- return rv;
- }
- // JavaScript won't let you delete things declared with "var", workaround:
- window.i = 1;
- const NET_OFFLINE = i++; // Initial, disconected.
- const NET_WAITING = i++; // Waiting before trying.
- const NET_CONNECTING = i++; // Trying a connect...
- const NET_CANCELLING = i++; // Cancelling connect.
- const NET_ONLINE = i++; // Connected ok.
- const NET_DISCONNECTING = i++; // Disconnecting.
- delete window.i;
- /*
- * irc network
- */
- function CIRCNetwork (name, serverList, eventPump, temporary)
- {
- this.unicodeName = name;
- this.viewName = name;
- this.canonicalName = name;
- this.encodedName = name;
- this.servers = new Object();
- this.serverList = new Array();
- this.ignoreList = new Object();
- this.ignoreMaskCache = new Object();
- this.state = NET_OFFLINE;
- this.temporary = Boolean(temporary);
- for (var i = 0; i < serverList.length; ++i)
- {
- var server = serverList[i];
- var password = ("password" in server) ? server.password : null;
- var isSecure = ("isSecure" in server) ? server.isSecure : false;
- this.serverList.push(new CIRCServer(this, server.name, server.port, isSecure,
- password));
- }
- this.eventPump = eventPump;
- if ("onInit" in this)
- this.onInit();
- }
- /** Clients should override this stuff themselves **/
- CIRCNetwork.prototype.INITIAL_NICK = "js-irc";
- CIRCNetwork.prototype.INITIAL_NAME = "INITIAL_NAME";
- CIRCNetwork.prototype.INITIAL_DESC = "INITIAL_DESC";
- /* set INITIAL_CHANNEL to "" if you don't want a primary channel */
- CIRCNetwork.prototype.INITIAL_CHANNEL = "#jsbot";
- CIRCNetwork.prototype.INITIAL_UMODE = "+iw";
- CIRCNetwork.prototype.MAX_CONNECT_ATTEMPTS = 5;
- CIRCNetwork.prototype.PAC_RECONNECT_DELAY = 5 * 1000;
- CIRCNetwork.prototype.getReconnectDelayMs = function() { return 15000; }
- CIRCNetwork.prototype.stayingPower = false;
- // "http" = use HTTP proxy, "none" = none, anything else = auto.
- CIRCNetwork.prototype.PROXY_TYPE_OVERRIDE = "";
- CIRCNetwork.prototype.TYPE = "IRCNetwork";
- CIRCNetwork.prototype.getURL =
- function net_geturl(target, flags)
- {
- if (this.temporary)
- return this.serverList[0].getURL(target, flags);
- /* Determine whether to use the irc:// or ircs:// scheme */
- var scheme = "irc";
- if ((("primServ" in this) && this.primServ.isConnected &&
- this.primServ.isSecure) ||
- this.hasOnlySecureServers())
- {
- scheme = "ircs"
- }
- var obj = {host: this.unicodeName, scheme: scheme};
- if (target)
- obj.target = target;
- if (flags)
- {
- for (var i = 0; i < flags.length; i++)
- obj[flags[i]] = true;
- }
- return constructIRCURL(obj);
- }
- CIRCNetwork.prototype.getUser =
- function net_getuser (nick)
- {
- if ("primServ" in this && this.primServ)
- return this.primServ.getUser(nick);
- return null;
- }
- CIRCNetwork.prototype.addServer =
- function net_addsrv(host, port, isSecure, password)
- {
- this.serverList.push(new CIRCServer(this, host, port, isSecure, password));
- }
- // Checks if a network has a secure server in its list.
- CIRCNetwork.prototype.hasSecureServer =
- function net_hasSecure()
- {
- for (var i = 0; i < this.serverList.length; i++)
- {
- if (this.serverList[i].isSecure)
- return true;
- }
- return false;
- }
- CIRCNetwork.prototype.hasOnlySecureServers =
- function net_hasOnlySecure()
- {
- for (var i = 0; i < this.serverList.length; i++)
- {
- if (!this.serverList[i].isSecure)
- return false;
- }
- return true;
- }
- CIRCNetwork.prototype.clearServerList =
- function net_clearserverlist()
- {
- /* Note: we don't have to worry about being connected, since primServ
- * keeps the currently connected server alive if we still need it.
- */
- this.servers = new Object();
- this.serverList = new Array();
- }
- /** Trigger an onDoConnect event after a delay. */
- CIRCNetwork.prototype.delayedConnect =
- function net_delayedConnect(eventProperties)
- {
- function reconnectFn(network, eventProperties)
- {
- network.immediateConnect(eventProperties);
- };
- if ((-1 != this.MAX_CONNECT_ATTEMPTS) &&
- (this.connectAttempt >= this.MAX_CONNECT_ATTEMPTS))
- {
- this.state = NET_OFFLINE;
- var ev = new CEvent("network", "error", this, "onError");
- ev.debug = "Connection attempts exhausted, giving up.";
- ev.errorCode = JSIRC_ERR_EXHAUSTED;
- this.eventPump.addEvent(ev);
- return;
- }
- this.state = NET_WAITING;
- this.reconnectTimer = setTimeout(reconnectFn,
- this.getReconnectDelayMs(),
- this,
- eventProperties);
- }
- /**
- * Immediately trigger an onDoConnect event. Use delayedConnect for automatic
- * repeat attempts, instead, to throttle the attempts to a reasonable pace.
- */
- CIRCNetwork.prototype.immediateConnect =
- function net_immediateConnect(eventProperties)
- {
- var ev = new CEvent("network", "do-connect", this, "onDoConnect");
- if (typeof eventProperties != "undefined")
- for (var key in eventProperties)
- ev[key] = eventProperties[key];
- this.eventPump.addEvent(ev);
- }
- CIRCNetwork.prototype.connect =
- function net_connect(requireSecurity)
- {
- if ("primServ" in this && this.primServ.isConnected)
- return true;
- // We need to test for secure servers in the network object here,
- // because without them all connection attempts will fail anyway.
- if (requireSecurity && !this.hasSecureServer())
- {
- // No secure server, cope.
- ev = new CEvent ("network", "error", this, "onError");
- ev.server = this;
- ev.debug = "No connection attempted: no secure servers in list";
- ev.errorCode = JSIRC_ERR_NO_SECURE;
- this.eventPump.addEvent(ev);
- return false;
- }
- this.state = NET_CONNECTING;
- this.connectAttempt = 0; // actual connection attempts
- this.connectCandidate = 0; // incl. requireSecurity non-attempts
- this.nextHost = 0;
- this.requireSecurity = requireSecurity || false;
- this.immediateConnect({"password": null});
- return true;
- }
- CIRCNetwork.prototype.quit =
- function net_quit (reason)
- {
- if (this.isConnected())
- this.primServ.logout(reason);
- }
- CIRCNetwork.prototype.cancel =
- function net_cancel()
- {
- // We're online, pull the plug on the current connection, or...
- if (this.state == NET_ONLINE)
- {
- this.quit();
- }
- // We're waiting for the 001, too late to throw a reconnect, or...
- else if (this.state == NET_CONNECTING)
- {
- this.state = NET_CANCELLING;
- this.primServ.connection.disconnect();
- // Throw the necessary error events:
- ev = new CEvent ("network", "error", this, "onError");
- ev.server = this;
- ev.debug = "Connect sequence was cancelled.";
- ev.errorCode = JSIRC_ERR_CANCELLED;
- this.eventPump.addEvent(ev);
- }
- // We're waiting for onDoConnect, so try a reconnect (which will fail us)
- else if (this.state == NET_WAITING)
- {
- this.state = NET_CANCELLING;
- // onDoConnect will throw the error events for us, as it will fail
- this.immediateConnect();
- }
- else
- {
- dd("Network cancel in odd state: " + this.state);
- }
- }
- /*
- * Handles a request to connect to a primary server.
- */
- CIRCNetwork.prototype.onDoConnect =
- function net_doconnect(e)
- {
- const NS_ERROR_OFFLINE = 0x804b0010;
- var c;
- // Clear the timer, if there is one.
- if ("reconnectTimer" in this)
- {
- clearTimeout(this.reconnectTimer);
- delete this.reconnectTimer;
- }
- var ev;
- if (this.state == NET_CANCELLING)
- {
- if ("primServ" in this && this.primServ.connection)
- this.primServ.connection.disconnect();
- else
- this.state = NET_OFFLINE;
- ev = new CEvent ("network", "error", this, "onError");
- ev.server = this;
- ev.debug = "Connect sequence was cancelled.";
- ev.errorCode = JSIRC_ERR_CANCELLED;
- this.eventPump.addEvent(ev);
- return false;
- }
- if ("primServ" in this && this.primServ.isConnected)
- return true;
- this.connectAttempt++;
- this.connectCandidate++;
- this.state = NET_CONNECTING; /* connection is considered "made" when server
- * sends a 001 message (see server.on001) */
- var host = this.nextHost++;
- if (host >= this.serverList.length)
- {
- this.nextHost = 1;
- host = 0;
- }
- if (this.serverList[host].isSecure || !this.requireSecurity)
- {
- ev = new CEvent ("network", "startconnect", this, "onStartConnect");
- ev.debug = "Connecting to " + this.serverList[host].unicodeName + ":" +
- this.serverList[host].port + ", attempt " + this.connectAttempt +
- " of " + this.MAX_CONNECT_ATTEMPTS + "...";
- ev.host = this.serverList[host].hostname;
- ev.port = this.serverList[host].port;
- ev.server = this.serverList[host];
- ev.connectAttempt = this.connectAttempt;
- ev.reconnectDelayMs = this.getReconnectDelayMs();
- this.eventPump.addEvent (ev);
- try
- {
- if (!this.serverList[host].connect(null))
- {
- /* connect failed, try again */
- this.delayedConnect();
- }
- }
- catch(ex)
- {
- this.state = NET_OFFLINE;
- ev = new CEvent("network", "error", this, "onError");
- ev.server = this;
- ev.debug = "Exception opening socket: " + ex;
- ev.errorCode = JSIRC_ERR_NO_SOCKET;
- if ((typeof ex == "object") && (ex.result == NS_ERROR_OFFLINE))
- ev.errorCode = JSIRC_ERR_OFFLINE;
- if ((typeof ex == "string") && (ex == JSIRC_ERR_PAC_LOADING))
- {
- ev.errorCode = JSIRC_ERR_PAC_LOADING;
- ev.retryDelay = CIRCNetwork.prototype.PAC_RECONNECT_DELAY;
- /* PAC loading is not a problem with any specific server. We'll
- * retry the connection in 5 seconds.
- */
- this.nextHost--;
- this.state = NET_WAITING;
- setTimeout(function(n) { n.immediateConnect() },
- ev.retryDelay, this);
- }
- this.eventPump.addEvent(ev);
- }
- }
- else
- {
- /* Server doesn't use SSL as requested, try next one.
- * In the meantime, correct the connection attempt counter */
- this.connectAttempt--;
- this.immediateConnect();
- }
- return true;
- }
- CIRCNetwork.prototype.isConnected =
- function net_connected (e)
- {
- return ("primServ" in this && this.primServ.isConnected);
- }
- CIRCNetwork.prototype.ignore =
- function net_ignore (hostmask)
- {
- var input = getHostmaskParts(hostmask);
- if (input.mask in this.ignoreList)
- return false;
- this.ignoreList[input.mask] = input;
- this.ignoreMaskCache = new Object();
- return true;
- }
- CIRCNetwork.prototype.unignore =
- function net_ignore (hostmask)
- {
- var input = getHostmaskParts(hostmask);
- if (!(input.mask in this.ignoreList))
- return false;
- delete this.ignoreList[input.mask];
- this.ignoreMaskCache = new Object();
- return true;
- }
- /*
- * irc server
- */
- function CIRCServer (parent, hostname, port, isSecure, password)
- {
- var serverName = hostname + ":" + port;
- var s;
- if (serverName in parent.servers)
- {
- s = parent.servers[serverName];
- }
- else
- {
- s = this;
- s.channels = new Object();
- s.users = new Object();
- }
- s.unicodeName = serverName;
- s.viewName = serverName;
- s.canonicalName = serverName;
- s.encodedName = serverName;
- s.hostname = hostname;
- s.port = port;
- s.parent = parent;
- s.isSecure = isSecure;
- s.password = password;
- s.connection = null;
- s.isConnected = false;
- s.sendQueue = new Array();
- s.lastSend = new Date("1/1/1980");
- s.lastPingSent = null;
- s.lastPing = null;
- s.sendsThisRound = 0;
- s.savedLine = "";
- s.lag = -1;
- s.usersStable = true;
- s.supports = null;
- s.channelTypes = null;
- s.channelModes = null;
- s.channelCount = -1;
- s.userModes = null;
- s.maxLineLength = 400;
- s.capab = new Object();
- parent.servers[s.canonicalName] = s;
- if ("onInit" in s)
- s.onInit();
- return s;
- }
- CIRCServer.prototype.MAX_LINES_PER_SEND = 0; /* unlimited */
- CIRCServer.prototype.MS_BETWEEN_SENDS = 1500;
- CIRCServer.prototype.READ_TIMEOUT = 100;
- CIRCServer.prototype.TOO_MANY_LINES_MSG = "\01ACTION has said too much\01";
- CIRCServer.prototype.VERSION_RPLY = "JS-IRC Library v0.01, " +
- "Copyright (C) 1999 Robert Ginda; rginda@ndcico.com";
- CIRCServer.prototype.OS_RPLY = "Unknown";
- CIRCServer.prototype.HOST_RPLY = "Unknown";
- CIRCServer.prototype.DEFAULT_REASON = "no reason";
- /* true means on352 code doesn't collect hostmask, username, etc. */
- CIRCServer.prototype.LIGHTWEIGHT_WHO = false;
- /* -1 == never, 0 == prune onQuit, >0 == prune when >X ms old */
- CIRCServer.prototype.PRUNE_OLD_USERS = -1;
- CIRCServer.prototype.TYPE = "IRCServer";
- // Define functions to set modes so they're easily readable.
- // name is the name used on the CIRCChanMode object
- // getValue is a function returning the value the canonicalmode should be set to
- // given a certain modifier and appropriate data.
- CIRCServer.prototype.canonicalChanModes = {
- i: {
- name: "invite",
- getValue: function (modifier) { return (modifier == "+"); }
- },
- m: {
- name: "moderated",
- getValue: function (modifier) { return (modifier == "+"); }
- },
- n: {
- name: "publicMessages",
- getValue: function (modifier) { return (modifier == "-"); }
- },
- t: {
- name: "publicTopic",
- getValue: function (modifier) { return (modifier == "-"); }
- },
- s: {
- name: "secret",
- getValue: function (modifier) { return (modifier == "+"); }
- },
- p: {
- name: "pvt",
- getValue: function (modifier) { return (modifier == "+"); }
- },
- k: {
- name: "key",
- getValue: function (modifier, data)
- {
- if (modifier == "+")
- return data;
- else
- return "";
- }
- },
- l: {
- name: "limit",
- getValue: function (modifier, data)
- {
- // limit is special - we return -1 if there is no limit.
- if (modifier == "-")
- return -1;
- else
- return data;
- }
- }
- };
- CIRCServer.prototype.toLowerCase =
- function serv_tolowercase(str)
- {
- /* This is an implementation that lower-cases strings according to the
- * prevailing CASEMAPPING setting for the server. Values for this are:
- *
- * o "ascii": The ASCII characters 97 to 122 (decimal) are defined as
- * the lower-case characters of ASCII 65 to 90 (decimal). No other
- * character equivalency is defined.
- * o "strict-rfc1459": The ASCII characters 97 to 125 (decimal) are
- * defined as the lower-case characters of ASCII 65 to 93 (decimal).
- * No other character equivalency is defined.
- * o "rfc1459": The ASCII characters 97 to 126 (decimal) are defined as
- * the lower-case characters of ASCII 65 to 94 (decimal). No other
- * character equivalency is defined.
- *
- */
- function replaceFunction(chr)
- {
- return String.fromCharCode(chr.charCodeAt(0) + 32);
- }
- var mapping = "rfc1459";
- if (this.supports)
- mapping = this.supports.casemapping;
- /* NOTE: There are NO breaks in this switch. This is CORRECT.
- * Each mapping listed is a super-set of those below, thus we only
- * transform the extra characters, and then fall through.
- */
- switch (mapping)
- {
- case "rfc1459":
- str = str.replace(/\^/g, replaceFunction);
- case "strict-rfc1459":
- str = str.replace(/[\[\\\]]/g, replaceFunction);
- case "ascii":
- str = str.replace(/[A-Z]/g, replaceFunction);
- }
- return str;
- }
- CIRCServer.prototype.getURL =
- function serv_geturl(target, flags)
- {
- var scheme = (this.isSecure ? "ircs" : "irc");
- var obj = {host: this.hostname, scheme: scheme, isserver: true,
- port: this.port, needpass: Boolean(this.password)};
- if (target)
- obj.target = target;
- if (flags)
- {
- for (var i = 0; i < flags.length; i++)
- obj[flags[i]] = true;
- }
- return constructIRCURL(obj);
- }
- CIRCServer.prototype.getUser =
- function chan_getuser(nick)
- {
- var tnick = this.toLowerCase(nick);
- if (tnick in this.users)
- return this.users[tnick];
- tnick = this.toLowerCase(fromUnicode(nick, this));
- if (tnick in this.users)
- return this.users[tnick];
- return null;
- }
- CIRCServer.prototype.getChannel =
- function chan_getchannel(name)
- {
- var tname = this.toLowerCase(name);
- if (tname in this.channels)
- return this.channels[tname];
- tname = this.toLowerCase(fromUnicode(name, this));
- if (tname in this.channels)
- return this.channels[tname];
- return null;
- }
- CIRCServer.prototype.connect =
- function serv_connect (password)
- {
- try
- {
- this.connection = new CBSConnection();
- }
- catch (ex)
- {
- ev = new CEvent ("server", "error", this, "onError");
- ev.server = this;
- ev.debug = "Couldn't create socket :" + ex;
- ev.errorCode = JSIRC_ERR_NO_SOCKET;
- ev.exception = ex;
- this.parent.eventPump.addEvent (ev);
- return false;
- }
- var config = { isSecure: this.isSecure };
- if (this.parent.PROXY_TYPE_OVERRIDE)
- config.proxy = this.parent.PROXY_TYPE_OVERRIDE;
- if (this.connection.connect(this.hostname, this.port, config))
- {
- var ev = new CEvent("server", "connect", this, "onConnect");
- if (password)
- this.password = password;
- ev.server = this;
- this.parent.eventPump.addEvent (ev);
- this.isConnected = true;
- if (jsenv.HAS_NSPR_EVENTQ)
- this.connection.startAsyncRead(this);
- else
- this.parent.eventPump.addEvent(new CEvent("server", "poll", this,
- "onPoll"));
- }
- return true;
- }
- /*
- * What to do when the client connects to it's primary server
- */
- CIRCServer.prototype.onConnect =
- function serv_onconnect (e)
- {
- this.parent.primServ = e.server;
- this.login(this.parent.INITIAL_NICK, this.parent.INITIAL_NAME,
- this.parent.INITIAL_DESC);
- return true;
- }
- CIRCServer.prototype.onStreamDataAvailable =
- function serv_sda (request, inStream, sourceOffset, count)
- {
- var ev = new CEvent ("server", "data-available", this,
- "onDataAvailable");
- ev.line = this.connection.readData(0, count);
- /* route data-available as we get it. the data-available handler does
- * not do much, so we can probably get away with this without starving
- * the UI even under heavy input traffic.
- */
- this.parent.eventPump.routeEvent(ev);
- }
- CIRCServer.prototype.onStreamClose =
- function serv_sockdiscon(status)
- {
- var ev = new CEvent ("server", "disconnect", this, "onDisconnect");
- ev.server = this;
- ev.disconnectStatus = status;
- if (ev.disconnectStatus == NS_ERROR_BINDING_ABORTED)
- ev.disconnectStatus = NS_ERROR_ABORT;
- this.parent.eventPump.addEvent (ev);
- }
- CIRCServer.prototype.flushSendQueue =
- function serv_flush()
- {
- this.sendQueue.length = 0;
- dd("sendQueue flushed.");
- return true;
- }
- CIRCServer.prototype.login =
- function serv_login(nick, name, desc)
- {
- nick = nick.replace(/ /g, "_");
- name = name.replace(/ /g, "_");
- if (!nick)
- nick = "nick";
- if (!name)
- name = nick;
- if (!desc)
- desc = nick;
- this.me = new CIRCUser(this, nick, null, name);
- if (this.password)
- this.sendData("PASS " + this.password + "\n");
- this.changeNick(this.me.unicodeName);
- this.sendData("USER " + name + " * * :" +
- fromUnicode(desc, this) + "\n");
- }
- CIRCServer.prototype.logout =
- function serv_logout(reason)
- {
- if (reason == null || typeof reason == "undefined")
- reason = this.DEFAULT_REASON;
- this.quitting = true;
- this.connection.sendData("QUIT :" +
- fromUnicode(reason, this.parent) + "\n");
- this.connection.disconnect();
- }
- CIRCServer.prototype.addTarget =
- function serv_addtarget(name)
- {
- if (arrayIndexOf(this.channelTypes, name[0]) != -1) {
- return this.addChannel(name);
- } else {
- return this.addUser(name);
- }
- }
- CIRCServer.prototype.addChannel =
- function serv_addchan(unicodeName, charset)
- {
- return new CIRCChannel(this, unicodeName, fromUnicode(unicodeName, charset));
- }
- CIRCServer.prototype.addUser =
- function serv_addusr(unicodeName, name, host)
- {
- return new CIRCUser(this, unicodeName, null, name, host);
- }
- CIRCServer.prototype.getChannelsLength =
- function serv_chanlen()
- {
- var i = 0;
- for (var p in this.channels)
- i++;
- return i;
- }
- CIRCServer.prototype.getUsersLength =
- function serv_chanlen()
- {
- var i = 0;
- for (var p in this.users)
- i++;
- return i;
- }
- CIRCServer.prototype.sendData =
- function serv_senddata (msg)
- {
- this.queuedSendData (msg);
- }
- CIRCServer.prototype.queuedSendData =
- function serv_senddata (msg)
- {
- if (this.sendQueue.length == 0)
- this.parent.eventPump.addEvent (new CEvent ("server", "senddata",
- this, "onSendData"));
- arrayInsertAt (this.sendQueue, 0, new String(msg));
- }
- /*
- * Takes care not to let more than MAX_LINES_PER_SEND lines out per
- * cycle. Cycle's are defined as the time between onPoll calls.
- */
- CIRCServer.prototype.messageTo =
- function serv_messto (code, target, msg, ctcpCode)
- {
- var lines = String(msg).split ("\n");
- var sendable = 0, i;
- var pfx = "", sfx = "";
- if (this.MAX_LINES_PER_SEND &&
- this.sendsThisRound > this.MAX_LINES_PER_SEND)
- return false;
- if (ctcpCode)
- {
- pfx = "\01" + ctcpCode;
- sfx = "\01";
- }
- for (i in lines)
- {
- if (lines[i])
- {
- while (lines[i].length > this.maxLineLength)
- {
- var extraLine = lines[i].substr(0, this.maxLineLength - 5);
- var pos = extraLine.lastIndexOf(" ");
- if ((pos >= 0) && (pos >= this.maxLineLength - 15))
- {
- // Smart-split.
- extraLine = lines[i].substr(0, pos) + "...";
- lines[i] = "..." + lines[i].substr(extraLine.length - 2);
- }
- else
- {
- // Dump-split.
- extraLine = lines[i].substr(0, this.maxLineLength);
- lines[i] = lines[i].substr(extraLine.length);
- }
- if (!this.messageTo(code, target, extraLine, ctcpCode))
- return false;
- }
- }
- }
- // Check this again, since we may have actually sent stuff in the loop above.
- if (this.MAX_LINES_PER_SEND &&
- this.sendsThisRound > this.MAX_LINES_PER_SEND)
- return false;
- for (i in lines)
- if ((lines[i] != "") || ctcpCode) sendable++;
- for (i in lines)
- {
- if (this.MAX_LINES_PER_SEND && (
- ((this.sendsThisRound == this.MAX_LINES_PER_SEND - 1) &&
- (sendable > this.MAX_LINES_PER_SEND)) ||
- this.sendsThisRound == this.MAX_LINES_PER_SEND))
- {
- this.sendData ("PRIVMSG " + target + " :" +
- this.TOO_MANY_LINES_MSG + "\n");
- this.sendsThisRound++;
- return true;
- }
- if ((lines[i] != "") || ctcpCode)
- {
- var line = code + " " + target + " :" + pfx;
- this.sendsThisRound++;
- if (lines[i] != "")
- {
- if (ctcpCode)
- line += " ";
- line += lines[i] + sfx;
- }
- else
- line += sfx;
- //dd ("-*- irc sending '" + line + "'");
- this.sendData(line + "\n");
- }
- }
- return true;
- }
- CIRCServer.prototype.sayTo =
- function serv_sayto (target, msg)
- {
- this.messageTo("PRIVMSG", target, msg);
- }
- CIRCServer.prototype.noticeTo =
- function serv_noticeto (target, msg)
- {
- this.messageTo("NOTICE", target, msg);
- }
- CIRCServer.prototype.actTo =
- function serv_actto (target, msg)
- {
- this.messageTo("PRIVMSG", target, msg, "ACTION");
- }
- CIRCServer.prototype.ctcpTo =
- function serv_ctcpto (target, code, msg, method)
- {
- msg = msg || "";
- method = method || "PRIVMSG";
- code = code.toUpperCase();
- if (code == "PING" && !msg)
- msg = Number(new Date());
- this.messageTo(method, target, msg, code);
- }
- CIRCServer.prototype.changeNick =
- function serv_changenick(newNick)
- {
- this.sendData("NICK " + fromUnicode(newNick, this) + "\n");
- }
- CIRCServer.prototype.updateLagTimer =
- function serv_uptimer()
- {
- this.connection.sendData("PING :LAGTIMER\n");
- this.lastPing = this.lastPingSent = new Date();
- }
- CIRCServer.prototype.userhost =
- function serv_userhost(target)
- {
- this.sendData("USERHOST " + fromUnicode(target, this) + "\n");
- }
- CIRCServer.prototype.userip =
- function serv_userip(target)
- {
- this.sendData("USERIP " + fromUnicode(target, this) + "\n");
- }
- CIRCServer.prototype.who =
- function serv_who(target)
- {
- this.sendData("WHO " + fromUnicode(target, this) + "\n");
- }
- /**
- * Abstracts the whois command.
- *
- * @param target intended user(s).
- */
- CIRCServer.prototype.whois =
- function serv_whois (target)
- {
- this.sendData("WHOIS " + fromUnicode(target, this) + "\n");
- }
- CIRCServer.prototype.whowas =
- function serv_whowas(target, limit)
- {
- if (typeof limit == "undefined")
- limit = 1;
- else if (limit == 0)
- limit = "";
- this.sendData("WHOWAS " + fromUnicode(target, this) + " " + limit + "\n");
- }
- CIRCServer.prototype.onDisconnect =
- function serv_disconnect(e)
- {
- function stateChangeFn(network, state) {
- network.state = state;
- };
- function delayedConnectFn(network) {
- network.delayedConnect();
- };
- /* If we're not connected and get this, it means we have almost certainly
- * encountered a read or write error on the socket post-disconnect. There's
- * no point propagating this any further, as we've already notified the
- * user of the disconnect (with the right error).
- */
- if (!this.isConnected)
- return;
- // Don't reconnect from a certificate error.
- var certErrors = [SEC_ERROR_EXPIRED_CERTIFICATE, SEC_ERROR_UNKNOWN_ISSUER,
- SEC_ERROR_UNTRUSTED_ISSUER, SEC_ERROR_UNTRUSTED_CERT,
- SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE,
- SEC_ERROR_CA_CERT_INVALID, SEC_ERROR_INADEQUATE_KEY_USAGE,
- SSL_ERROR_BAD_CERT_DOMAIN];
- var certError = arrayContains(certErrors, e.disconnectStatus);
- // Don't reconnect if our connection was aborted.
- var wasAborted = (e.disconnectStatus == NS_ERROR_ABORT);
- var dontReconnect = certError || wasAborted;
- if (((this.parent.state == NET_CONNECTING) && !dontReconnect) ||
- /* fell off while connecting, try again */
- (this.parent.primServ == this) && (this.parent.state == NET_ONLINE) &&
- (!("quitting" in this) && this.parent.stayingPower && !dontReconnect))
- { /* fell off primary server, reconnect to any host in the serverList */
- setTimeout(delayedConnectFn, 0, this.parent);
- }
- else
- {
- setTimeout(stateChangeFn, 0, this.parent, NET_OFFLINE);
- }
- e.server = this;
- e.set = "network";
- e.destObject = this.parent;
- e.quitting = this.quitting;
- for (var c in this.channels)
- {
- this.channels[c].users = new Object();
- this.channels[c].active = false;
- }
- this.connection = null;
- this.isConnected = false;
- delete this.quitting;
- }
- CIRCServer.prototype.onSendData =
- function serv_onsenddata (e)
- {
- if (!this.isConnected || (this.parent.state == NET_CANCELLING))
- {
- dd ("Can't send to disconnected socket");
- this.flushSendQueue();
- return false;
- }
- var d = new Date();
- this.sendsThisRound = 0;
- // Wheee, some sanity checking! (there's been at least one case of lastSend
- // ending up in the *future* at this point, which kinda busts things)
- if (this.lastSend > d)
- this.lastSend = 0;
- if (((d - this.lastSend) >= this.MS_BETWEEN_SENDS) &&
- this.sendQueue.length > 0)
- {
- var s = this.sendQueue.pop();
- if (s)
- {
- try
- {
- this.connection.sendData(s);
- }
- catch(ex)
- {
- dd("Exception in queued send: " + ex);
- this.flushSendQueue();
- var ev = new CEvent("server", "disconnect",
- this, "onDisconnect");
- ev.server = this;
- ev.reason = "error";
- ev.exception = ex;
- ev.disconnectStatus = NS_ERROR_ABORT;
- this.parent.eventPump.addEvent(ev);
- return false;
- }
- this.lastSend = d;
- }
- }
- else
- {
- this.parent.eventPump.addEvent(new CEvent("event-pump", "yield",
- null, ""));
- }
- if (this.sendQueue.length > 0)
- this.parent.eventPump.addEvent(new CEvent("server", "senddata",
- this, "onSendData"));
- return true;
- }
- CIRCServer.prototype.onPoll =
- function serv_poll(e)
- {
- var lines;
- var ex;
- var ev;
- try
- {
- if (this.parent.state != NET_CANCELLING)
- line = this.connection.readData(this.READ_TIMEOUT);
- }
- catch (ex)
- {
- dd ("*** Caught exception " + ex + " reading from server " +
- this.hostname);
- if (jsenv.HAS_RHINO && (ex instanceof java.lang.ThreadDeath))
- {
- dd("### catching a ThreadDeath");
- throw(ex);
- }
- else
- {
- ev = new CEvent ("server", "disconnect", this, "onDisconnect");
- ev.server = this;
- ev.reason = "error";
- ev.exception = ex;
- ev.disconnectStatus = NS_ERROR_ABORT;
- this.parent.eventPump.addEvent (ev);
- return false;
- }
- }
- this.parent.eventPump.addEvent (new CEvent ("server", "poll", this,
- "onPoll"));
- if (line)
- {
- ev = new CEvent ("server", "data-available", this, "onDataAvailable");
- ev.line = line;
- this.parent.eventPump.routeEvent(ev);
- }
- return true;
- }
- CIRCServer.prototype.onDataAvailable =
- function serv_ppline(e)
- {
- var line = e.line;
- if (line == "")
- return false;
- var incomplete = (line[line.length - 1] != '\n');
- var lines = line.split("\n");
- if (this.savedLine)
- {
- lines[0] = this.savedLine + lines[0];
- this.savedLine = "";
- }
- if (incomplete)
- this.savedLine = lines.pop();
- for (var i in lines)
- {
- var ev = new CEvent("server", "rawdata", this, "onRawData");
- ev.data = lines[i].replace(/\r/g, "");
- if (ev.data)
- {
- if (ev.data.match(/^(?::[^ ]+ )?(?:32[123]|352|315) /i))
- this.parent.eventPump.addBulkEvent(ev);
- else
- this.parent.eventPump.addEvent(ev);
- }
- }
- return true;
- }
- /*
- * onRawData begins shaping the event by parsing the IRC message at it's
- * simplest level. After onRawData, the event will have the following
- * properties:
- * name value
- *
- * set............"server"
- * type..........."parsedata"
- * destMethod....."onParsedData"
- * destObject.....server (this)
- * server.........server (this)
- * connection.....CBSConnection (this.connection)
- * source.........the <prefix> of the message (if it exists)
- * user...........user object initialized with data from the message <prefix>
- * params.........array containing the parameters of the message
- * code...........the first parameter (most messages have this)
- *
- * See Section 2.3.1 of RFC 1459 for details on <prefix>, <middle> and
- * <trailing> tokens.
- */
- CIRCServer.prototype.onRawData =
- function serv_onRawData(e)
- {
- var ary;
- var l = e.data;
- if (l.length == 0)
- {
- dd ("empty line on onRawData?");
- return false;
- }
- if (l[0] == ":")
- {
- // Must split only on REAL spaces here, not just any old whitespace.
- ary = l.match(/:([^ ]+) +(.*)/);
- e.source = ary[1];
- l = ary[2];
- ary = e.source.match(/([^ ]+)!([^ ]+)@(.*)/);
- if (ary)
- {
- e.user = new CIRCUser(this, null, ary[1], ary[2], ary[3]);
- }
- else
- {
- ary = e.source.match(/([^ ]+)@(.*)/);
- if (ary)
- {
- e.user = new CIRCUser(this, null, ary[1], null, ary[2]);
- }
- else
- {
- ary = e.source.match(/([^ ]+)!(.*)/);
- if (ary)
- e.user = new CIRCUser(this, null, ary[1], ary[2], null);
- }
- }
- }
- e.ignored = false;
- if (("user" in e) && e.user && ("ignoreList" in this.parent))
- {
- // Assumption: if "ignoreList" is in this.parent, we assume that:
- // a) it's an array.
- // b) ignoreMaskCache also exists, and
- // c) it's an array too.
- if (!(e.source in this.parent.ignoreMaskCache))
- {
- for (var m in this.parent.ignoreList)
- {
- if (hostmaskMatches(e.user, this.parent.ignoreList[m]))
- {
- e.ignored = true;
- break;
- }
- }
- /* Save this exact source in the cache, with results of tests. */
- this.parent.ignoreMaskCache[e.source] = e.ignored;
- }
- else
- {
- e.ignored = this.parent.ignoreMaskCache[e.source];
- }
- }
- e.server = this;
- var sep = l.indexOf(" :");
- if (sep != -1) /* <trailing> param, if there is one */
- {
- var trail = l.substr (sep + 2, l.length);
- e.params = l.substr(0, sep).split(/ +/);
- e.params[e.params.length] = trail;
- }
- else
- {
- e.params = l.split(/ +/);
- }
- e.decodeParam = decodeParam;
- e.code = e.params[0].toUpperCase();
- // Ignore all Privmsg and Notice messages here.
- if (e.ignored && ((e.code == "PRIVMSG") || (e.code == "NOTICE")))
- return true;
- e.type = "parseddata";
- e.destObject = this;
- e.destMethod = "onParsedData";
- return true;
- }
- /*
- * onParsedData forwards to next event, based on |e.code|
- */
- CIRCServer.prototype.onParsedData =
- function serv_onParsedData(e)
- {
- e.type = this.toLowerCase(e.code);
- if (!e.code[0])
- {
- dd (dumpObjectTree (e));
- return false;
- }
- e.destMethod = "on" + e.code[0].toUpperCase() +
- e.code.substr (1, e.code.length).toLowerCase();
- if (typeof this[e.destMethod] == "function")
- e.destObject = this;
- else if (typeof this["onUnknown"] == "function")
- e.destMethod = "onUnknown";
- else if (typeof this.parent[e.destMethod] == "function")
- {
- e.set = "network";
- e.destObject = this.parent;
- }
- else
- {
- e.set = "network";
- e.destObject = this.parent;
- e.destMethod = "onUnknown";
- }
- return true;
- }
- /* User changed topic */
- CIRCServer.prototype.onTopic =
- function serv_topic (e)
- {
- e.channel = new CIRCChannel(this, null, e.params[1]);
- e.channel.topicBy = e.user.unicodeName;
- e.channel.topicDate = new Date();
- e.channel.topic = toUnicode(e.params[2], e.channel);
- e.destObject = e.channel;
- e.set = "channel";
- return true;
- }
- /* Successful login */
- CIRCServer.prototype.on001 =
- function serv_001 (e)
- {
- this.parent.connectAttempt = 0;
- this.parent.connectCandidate = 0;
- this.parent.state = NET_ONLINE;
- // nextHost is incremented after picking a server. Push it back here.
- this.parent.nextHost--;
- /* servers won't send a nick change notification if user was forced
- * to change nick while logging in (eg. nick already in use.) We need
- * to verify here that what the server thinks our name is, matches what
- * we think it is. If not, the server wins.
- */
- if (e.params[1] != e.server.me.encodedName)
- {
- renameProperty(e.server.users, e.server.me.canonicalName,
- this.toLowerCase(e.params[1]));
- e.server.me.changeNick(toUnicode(e.params[1], this));
- }
- /* Set up supports defaults here.
- * This is so that we don't waste /huge/ amounts of RAM for the network's
- * servers just because we know about them. Until we connect, that is.
- * These defaults are taken from the draft 005 RPL_ISUPPORTS here:
- * http://www.ietf.org/internet-drafts/draft-brocklesby-irc-isupport-02.txt
- */
- this.supports = new Object();
- this.supports.modes = 3;
- this.supports.maxchannels = 10;
- this.supports.nicklen = 9;
- this.supports.casemapping = "rfc1459";
- this.supports.channellen = 200;
- this.supports.chidlen = 5;
- /* Make sure it's possible to tell if we've actually got a 005 message. */
- this.supports.rpl_isupport = false;
- this.channelTypes = [ '#', '&' ];
- /* This next one isn't in the isupport draft, but instead is defaulting to
- * the codes we understand. It should be noted, some servers include the
- * mode characters (o, h, v) in the 'a' list, although the draft spec says
- * they should be treated as type 'b'. Luckly, in practise this doesn't
- * matter, since both 'a' and 'b' types always take a parameter in the
- * MODE message, and parsing is not affected. */
- this.channelModes = {
- a: ['b'],
- b: ['k'],
- c: ['l'],
- d: ['i', 'm', 'n', 'p', 's', 't']
- };
- // Default to support of v/+ and o/@ only.
- this.userModes = [
- { mode: 'o', symbol: '@' },
- { mode: 'v', symbol: '+' }
- ];
- // Assume the server supports no extra interesting commands.
- this.servCmds = {};
- if (this.parent.INITIAL_UMODE)
- {
- e.server.sendData("MODE " + e.server.me.encodedName + " :" +
- this.parent.INITIAL_UMODE + "\n");
- }
- this.parent.users = this.users;
- e.destObject = this.parent;
- e.set = "network";
- }
- /* server features */
- CIRCServer.prototype.on005 =
- function serv_005 (e)
- {
- var oldCaseMapping = this.supports["casemapping"];
- /* Drop params 0 and 1. */
- for (var i = 2; i < e.params.length; i++) {
- var itemStr = e.params[i];
- /* Items may be of the forms:
- * NAME
- * -NAME
- * NAME=value
- * Value may be empty on occasion.
- * No value allowed for -NAME items.
- */
- var item = itemStr.match(/^(-?)([A-Z]+)(=(.*))?$/i);
- if (! item)
- continue;
- var name = item[2].toLowerCase();
- if (("3" in item) && item[3])
- {
- // And other items are stored as-is, though numeric items
- // get special treatment to make our life easier later.
- if (("4" in item) && item[4].match(/^\d+$/))
- this.supports[name] = Number(item[4]);
- else
- this.supports[name] = item[4];
- }
- else
- {
- // Boolean-type items stored as 'true'.
- this.supports[name] = !(("1" in item) && item[1] == "-");
- }
- }
- // Update all users and channels if the casemapping changed.
- if (this.supports["casemapping"] != oldCaseMapping)
- {
- var newName, encodedName;
- for (var user in this.users)
- {
- newName = this.toLowerCase(this.users[user].encodedName);
- renameProperty(this.users, user, newName);
- this.users[newName].canonicalName = newName;
- }
- for (var channel in this.channels)
- {
- newName = this.toLowerCase(this.channels[channel].encodedName);
- renameProperty(this.channels, this.channels[channel].canonicalName,
- newName);
- this.channels[channel].canonicalName = newName;
- for (user in this.channels[channel].users)
- {
- encodedName = this.channels[channel].users[user].encodedName;
- newName = this.toLowerCase(encodedName);
- renameProperty(this.channels[channel].users, user, newName);
- }
- }
- }
- // Supported 'special' items:
- // CHANTYPES (--> channelTypes{}),
- // PREFIX (--> userModes[{mode,symbol}]),
- // CHANMODES (--> channelModes{a:[], b:[], c:[], d:[]}).
- var m;
- if ("chantypes" in this.supports)
- {
- this.channelTypes = [];
- for (m = 0; m < this.supports.chantypes.length; m++)
- this.channelTypes.push( this.supports.chantypes[m] );
- }
- if ("prefix" in this.supports)
- {
- var mlist = this.supports.prefix.match(/^\((.*)\)(.*)$/i);
- if ((! mlist) || (mlist[1].length != mlist[2].length))
- {
- dd ("** Malformed PREFIX entry in 005 SUPPORTS message **");
- }
- else
- {
- this.userModes = [];
- for (m = 0; m < mlist[1].length; m++)
- this.userModes.push( { mode: mlist[1][m],
- symbol: mlist[2][m] } );
- }
- }
- if ("chanmodes" in this.supports)
- {
- var cmlist = this.supports.chanmodes.split(/,/);
- if ((!cmlist) || (cmlist.length < 4))
- {
- dd ("** Malformed CHANMODES entry in 005 SUPPORTS message **");
- }
- else
- {
- // 4 types - list, set-unset-param, set-only-param, flag.
- this.channelModes = {
- a: cmlist[0].split(''),
- b: cmlist[1].split(''),
- c: cmlist[2].split(''),
- d: cmlist[3].split('')
- };
- }
- }
- if ("cmds" in this.supports)
- {
- // Map this.supports.cmds [comma-list] into this.servCmds [props].
- var cmdlist = this.supports.cmds.split(/,/);
- for (var i = 0; i < cmdlist.length; i++)
- this.servCmds[cmdlist[i].toLowerCase()] = true;
- }
- this.supports.rpl_isupport = true;
- e.destObject = this.parent;
- e.set = "network";
- return true;
- }
- /* users */
- CIRCServer.prototype.on251 =
- function serv_251(e)
- {
- // 251 is the first message we get after 005, so it's now safe to do
- // things that might depend upon server features.
- if (("namesx" in this.supports) && this.supports.namesx)
- this.sendData("PROTOCTL NAMESX\n");
- if (this.parent.INITIAL_CHANNEL)
- {
- this.parent.primChan = this.addChannel(this.parent.INITIAL_CHANNEL);
- this.parent.primChan.join();
- }
- e.destObject = this.parent;
- e.set = "network";
- }
- /* channels */
- CIRCServer.prototype.on254 =
- function serv_254(e)
- {
- this.channelCount = e.params[2];
- e.destObject = this.parent;
- e.set = "network";
- }
- /* CAPAB response */
- CIRCServer.prototype.on290 =
- function my_290 (e)
- {
- // we expect some sort of identifier
- if (e.params.length < 2)
- return;
- switch (e.params[2])
- {
- case "IDENTIFY-MSG":
- /* Every message comes prefixed with either + or -
- + indicates the user is registered
- - indicates the user is not registered */
- this.capab.identifyMsg = true;
- break;
- }
- e.destObject = this.parent;
- e.set = "network";
- }
- /* user away message */
- CIRCServer.prototype.on301 =
- function serv_301(e)
- {
- e.user = new CIRCUser(this, null, e.params[2]);
- e.user.awayMessage = e.decodeParam(3, e.user);
- e.destObject = this.parent;
- e.set = "network";
- }
- /* whois name */
- CIRCServer.prototype.on311 =
- function serv_311 (e)
- {
- e.user = new CIRCUser(this, null, e.params[2], e.params[3], e.params[4]);
- e.user.desc = e.decodeParam(6, e.user);
- e.destObject = this.parent;
- e.set = "network";
- this.pendingWhoisLines = e.user;
- }
- /* whois server */
- CIRCServer.prototype.on312 =
- function serv_312 (e)
- {
- e.user = new CIRCUser(this, null, e.params[2]);
- e.user.connectionHost = e.params[3];
- e.destObject = this.parent;
- e.set = "network";
- }
- /* whois idle time */
- CIRCServer.prototype.on317 =
- function serv_317 (e)
- {
- e.user = new CIRCUser(this, null, e.params[2]);
- e.user.idleSeconds = e.params[3];
- e.destObject = this.parent;
- e.set = "network";
- }
- /* whois channel list */
- CIRCServer.prototype.on319 =
- function serv_319(e)
- {
- e.user = new CIRCUser(this, null, e.params[2]);
- e.destObject = this.parent;
- e.set = "network";
- }
- /* end of whois */
- CIRCServer.prototype.on318 =
- function serv_318(e)
- {
- e.user = new CIRCUser(this, null, e.params[2]);
- if ("pendingWhoisLines" in this)
- delete this.pendingWhoisLines;
- e.destObject = this.parent;
- e.set = "network";
- }
- /* ircu's 330 numeric ("X is logged in as Y") */
- CIRCServer.prototype.on330 =
- function serv_330(e)
- {
- e.user = new CIRCUser(this, null, e.params[2]);
- e.destObject = this.parent;
- e.set = "network";
- }
- /* TOPIC reply - no topic set */
- CIRCServer.prototype.on331 =
- function serv_331 (e)
- {
- e.channel = new CIRCChannel(this, null, e.params[2]);
- e.channel.topic = "";
- e.destObject = e.channel;
- e.set = "channel";
- return true;
- }
- /* TOPIC reply - topic set */
- CIRCServer.prototype.on332 =
- function serv_332 (e)
- {
- e.channel = new CIRCChannel(this, null, e.params[2]);
- e.channel.topic = toUnicode(e.params[3], e.channel);
- e.destObject = e.channel;
- e.set = "channel";
- return true;
- }
- /* topic information */
- CIRCServer.prototype.on333 =
- function serv_333 (e)
- {
- e.channel = new CIRCChannel(this, null, e.params[2]);
- e.channel.topicBy = toUnicode(e.params[3], this);
- e.channel.topicDate = new Date(Number(e.params[4]) * 1000);
- e.destObject = e.channel;
- e.set = "channel";
- return true;
- }
- /* who reply */
- CIRCSe…
Large files files are truncated, but you can click here to view the full file