rem: this.tweaktmpmode(CHANMODE_INVITE); 
add: this.tweaktmpmode(CHANMODE_INVITE,chan); 
context: function IRCClient_set_chanmode(chan,modeline,bounce_modes) {	if (!chan || !modeline)		return;	cm_args = modeline.split(' ');	add=true;	addbits=CHANMODE_NONE;	delbits=CHANMODE_NONE;	state_arg = new Array();	state_arg[CHANMODE_KEY] = "";	state_arg[CHANMODE_LIMIT] = "";	chan_tmplist=new Array();	chan_tmplist[CHANLIST_OP]=new Array();	chan_tmplist[CHANLIST_DEOP]=new Array();	chan_tmplist[CHANLIST_VOICE]=new Array();	chan_tmplist[CHANLIST_DEVOICE]=new Array();	chan_tmplist[CHANLIST_BAN]=new Array();	chan_tmplist[CHANLIST_UNBAN]=new Array();	mode_counter=0;	mode_args_counter=1; // start counting at the args, not the modestring	for (modechar in cm_args[0]) {		mode_counter++;		switch (cm_args[0][modechar]) {			case "+":				add=true;				mode_counter--;				break;			case "-":				add=false;				mode_counter--;				break;			case "b":				if(add && (cm_args.length <= mode_args_counter)) {					addbits|=CHANMODE_BAN; // list bans					break;				}				this.tweaktmpmodelist(CHANLIST_BAN,CHANLIST_UNBAN);				mode_args_counter++;				break;			case "i":				this.tweaktmpmode(CHANMODE_INVITE);				break;			case "k":				if(cm_args.length > mode_args_counter) {					this.tweaktmpmode(CHANMODE_KEY);					state_arg[CHANMODE_KEY]=cm_args[mode_args_counter];					mode_args_counter++;				}				break;			case "l":				if (add && (cm_args.length > mode_args_counter)) {					this.tweaktmpmode(CHANMODE_LIMIT);					regexp = "^[0-9]{1,4}$";					if(cm_args[mode_args_counter].match(regexp))						state_arg[CHANMODE_LIMIT]=cm_args[mode_args_counter];					mode_args_counter++;				} else if (!add) {					this.tweaktmpmode(CHANMODE_LIMIT);					if (cm_args.length > mode_args_counter)						mode_args_counter++;				}				break;			case "m":				this.tweaktmpmode(CHANMODE_MODERATED);				break;			case "n":				this.tweaktmpmode(CHANMODE_NOOUTSIDE);				break;			case "o":				if (cm_args.length <= mode_args_counter)					break;				this.tweaktmpmodelist(CHANLIST_OP,CHANLIST_DEOP);				mode_args_counter++;				break;			case "p":				if( (add && !(chan.mode&CHANMODE_SECRET) ||				     (delbits&CHANMODE_SECRET) ) || (!add) )					this.tweaktmpmode(CHANMODE_PRIVATE);				break;			case "s":				if( (add && !(chan.mode&CHANMODE_PRIVATE) ||				     (delbits&CHANMODE_PRIVATE) ) || (!add) )					this.tweaktmpmode(CHANMODE_SECRET);				break;			case "t":				this.tweaktmpmode(CHANMODE_TOPIC);				break;			case "v":				if (cm_args.length <= mode_args_counter)					break;				this.tweaktmpmodelist(CHANLIST_VOICE,CHANLIST_DEVOICE);				mode_args_counter++;				break;			default:				if ((!this.parent) && (!this.server))					this.numeric("472", cm_args[0][modechar] + " :is unknown mode char to me.");				mode_counter--;				break;		}		if (mode_counter == max_modes)			break;	}	addmodes = "";	delmodes = "";	addmodeargs = "";	delmodeargs = "";	// If we're bouncing modes, traverse our side of what the modes look	// like and remove any modes not mentioned by what was passed to the	// function.  Or, clear any ops, voiced members, or bans on the 'bad'	// side of the network sync.  FIXME: Bans get synchronized later.	if (bounce_modes) {		for (cm in MODE) {			if (MODE[cm].state && (chan.mode&cm) && !(addbits&cm)) {				delbits |= cm;			} else if (MODE[cm].list) {				for (member in chan.modelist[MODE[cm].list]) {					delmodes += MODE[cm].modechar;					delmodeargs += " " + Clients[chan.modelist[MODE[cm].list][member]].nick;					chan.del_modelist(chan.modelist[MODE[cm].list][member],MODE[cm].list);				}			}		}	}	// Now we run through all the mode toggles and construct our lists for	// later display.  We also play with the channel bit switches here.	for (cm in MODE) {		if (MODE[cm].state) {			if ((cm&CHANMODE_KEY) && (addbits&CHANMODE_KEY) && 			    state_arg[cm] && chan.arg[cm] && !this.server &&			    !this.parent && !bounce_modes) {				this.numeric(467, chan.nam + " :Channel key already set.");			} else if ((addbits&cm) && !(chan.mode&cm)) {				addmodes += MODE[cm].modechar;				chan.mode |= cm;				if (MODE[cm].args && MODE[cm].state) {					addmodeargs += " " + state_arg[cm];					chan.arg[cm] = state_arg[cm];				}			} else if ((delbits&cm) && (chan.mode&cm)) {				delmodes += MODE[cm].modechar;				chan.mode &= ~cm;				if (MODE[cm].args && MODE[cm].state) {					delmodeargs += " " + state_arg[cm];					chan.arg[cm] = "";				}			}		}	}	// This is a special case, if +b was passed to us without arguments,	// we simply display a list of bans on the channel.	if (addbits&CHANMODE_BAN) {		for (the_ban in chan.modelist[CHANLIST_BAN]) {			this.numeric(367, chan.nam + " " + chan.modelist[CHANLIST_BAN][the_ban] + " " + chan.bancreator[the_ban] + " " + chan.bantime[the_ban]);		}		this.numeric(368, chan.nam + " :End of Channel Ban List.");	}	// Now we play with the channel lists by adding or removing what was	// given to us on the modeline.	this.affect_mode_list(CHANLIST_OP)	this.affect_mode_list(CHANLIST_VOICE);	this.affect_mode_list(CHANLIST_BAN);	if (!addmodes && !delmodes)		return 0;	final_modestr = "";	if (addmodes)		final_modestr += "+" + addmodes;	if (delmodes)		final_modestr += "-" + delmodes;	if (addmodeargs)		final_modestr += addmodeargs;	if (delmodeargs)		final_modestr += delmodeargs;	var final_args = final_modestr.split(' ');	var arg_counter = 0;	var mode_counter = 0;	var mode_output = "";	var f_mode_args = "";	for (marg in final_args[0]) {		switch (final_args[0][marg]) {			case "+":				mode_output += "+";				add = true;				break;			case "-":				mode_output += "-";				add = false;				break;			case "l":				if (!add) {					mode_counter++;					mode_output += final_args[0][marg];					break;				}			case "b": // only modes with arguments			case "k":			case "l":			case "o":			case "v":				arg_counter++;				f_mode_args += " " + final_args[arg_counter];			default:				mode_counter++;				mode_output += final_args[0][marg];				break;		}		if (mode_counter >= max_modes) {			var str = "MODE " + chan.nam + " " + mode_output + f_mode_args;			if (!this.server)				this.bcast_to_channel(chan.nam, str, true);			else				this.bcast_to_channel(chan.nam, str, false);			if (chan.nam[0] != "&")				this.bcast_to_servers(str);			if (add)				mode_output = "+";			else				mode_output = "-";			f_mode_args = "";		}	}	if (mode_output.length > 1) {		str = "MODE " + chan.nam + " " + mode_output + f_mode_args;		if (!this.server)			this.bcast_to_channel(chan.nam, str, true);		else			this.bcast_to_channel(chan.nam, str, false);		if (chan.nam[0] != "&")			this.bcast_to_servers(str);	}	return 1;}
meta: 9592	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9592/d3f4f65f9665b769a4a719dceeed060a19423ede/ircd.js/clean/ircd.js