CIRCServer.onChanMode Member
Syntax
object.onChanMode(e);
Arguments
Argument | Summary |
---|---|
e |
Returns
Remarks
See Also
Source Code
function serv_chanmode (e)
{
var modifier = "";
var params_eaten = 0;
var BASE_PARAM;
if (e.code.toUpperCase() == "MODE")
BASE_PARAM = 2;
else
if (e.code == "324")
BASE_PARAM = 3;
else
{
dd ("** INVALID CODE in ChanMode event **");
return false;
}
var mode_str = e.params[BASE_PARAM];
params_eaten++;
e.modeStr = mode_str;
e.usersAffected = new Array();
var nick;
var user;
var umList = this.userModes;
var cmList = this.channelModes;
var modeMap = this.canonicalChanModes;
var canonicalModeValue;
for (var i = 0; i < mode_str.length ; i++)
{
/* Take care of modifier first. */
if ((mode_str[i] == '+') || (mode_str[i] == '-'))
{
modifier = mode_str[i];
continue;
}
var done = false;
for (var m in umList)
{
if ((mode_str[i] == umList[m].mode) && (modifier != ""))
{
nick = e.params[BASE_PARAM + params_eaten];
user = new CIRCChanUser(e.channel, null, nick,
[ modifier + umList[m].mode ]);
params_eaten++;
e.usersAffected.push (user);
done = true;
break;
}
}
if (done)
continue;
// Update legacy canonical modes if necessary.
if (mode_str[i] in modeMap)
{
// Get the data in case we need it, but don't increment the counter.
var datacounter = BASE_PARAM + params_eaten;
var data = (datacounter in e.params) ? e.params[datacounter] : null;
canonicalModeValue = modeMap[mode_str[i]].getValue(modifier, data);
e.channel.mode[modeMap[mode_str[i]].name] = canonicalModeValue;
}
if (arrayContains(cmList.a, mode_str[i]))
{
var data = e.params[BASE_PARAM + params_eaten++];
if (modifier == "+")
{
e.channel.mode.modeA[data] = true;
}
else
{
if (data in e.channel.mode.modeA)
{
delete e.channel.mode.modeA[data];
}
else
{
dd("** Trying to remove channel mode '" + mode_str[i] +
"'/'" + data + "' which does not exist in list.");
}
}
}
else if (arrayContains(cmList.b, mode_str[i]))
{
var data = e.params[BASE_PARAM + params_eaten++];
if (modifier == "+")
{
e.channel.mode.modeB[mode_str[i]] = data;
}
else
{
// Save 'null' even though we have some data.
e.channel.mode.modeB[mode_str[i]] = null;
}
}
else if (arrayContains(cmList.c, mode_str[i]))
{
if (modifier == "+")
{
var data = e.params[BASE_PARAM + params_eaten++];
e.channel.mode.modeC[mode_str[i]] = data;
}
else
{
e.channel.mode.modeC[mode_str[i]] = null;
}
}
else if (arrayContains(cmList.d, mode_str[i]))
{
e.channel.mode.modeD[mode_str[i]] = (modifier == "+");
}
else
{
dd("** UNKNOWN mode symbol '" + mode_str[i] + "' in ChanMode event **");
}
}
e.destObject = e.channel;
e.set = "channel";
return true;
}