CIRCServer.on005 Member

server features

Syntax

object.on005(e);

Arguments

ArgumentSummary
e

Returns

Remarks

See Also

Source Code

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;
}