예제 #1
0
파일: cset.c 프로젝트: BitchX/BitchX1.1
void set_channel_limit(ChannelList *channel, int currentlimit, int add, int numusers)
{
	if ((now - channel->limit_time) < 30)
		return;
	if (add && numusers)
	{
		if ((currentlimit - numusers) < (add / 2) && ((numusers + add) != currentlimit))
			my_send_to_server(channel->server, "MODE %s +l %d", channel->channel, numusers + add);
		else if ((currentlimit - numusers) > (currentlimit + (add / 2)) && ((numusers + add) != currentlimit))
			my_send_to_server(channel->server, "MODE %s +l %d", channel->channel, numusers + add);
	}
	else
		my_send_to_server(channel->server, "MODE %s -l", channel->channel);
	channel->limit_time = now;
}
예제 #2
0
int delay_opz (void *arg, char *sub)
{
char * args = (char *)arg;
char * from = NULL;
char * host = NULL;
char * channel = NULL;	
char * mode = NULL;
char * serv_num = NULL;
ChannelList *chan = NULL;
int	this_server = from_server;
char *p = (char *) arg; /* original args unmodified  so we can free them */
	

	channel = next_arg(args, &args);
	from = next_arg(args, &args);
	host = next_arg(args, &args);
	mode = next_arg(args, &args);

	if ((serv_num = next_arg(args, &args)))
		this_server = my_atol(serv_num);
	chan = lookup_channel(channel, this_server, 0);
	if (chan && is_on_channel(channel, this_server, from) && chan->chop) 
	{
		NickList *nick;
		for (nick = next_nicklist(chan, NULL); nick; nick = next_nicklist(chan, nick))
		{
			if (!my_stricmp(nick->nick, from))
			{
				if (!my_stricmp(host, nick->host))
					break;
				else
				{
					new_free(&p); new_free(&sub);
					return 0;
				}
			}
		}
		if (nick && ((!nick_isop(nick) && *mode == 'o') || (!nick_isvoice(nick) && *mode == 'v')))
		{
			my_send_to_server(this_server, "MODE %s +%s %s", channel, mode, from); 
			if (get_int_var(SEND_OP_MSG_VAR))
				my_send_to_server(this_server, "NOTICE %s :You have been delay Auto-%s'd", from, *mode == 'o'? "op":"voice");
		}
	}
	new_free(&p); new_free(&sub);
	return 0;
}
예제 #3
0
파일: banlist.c 프로젝트: BitchX/BitchX1.2
void flush_mode(ChannelList *chan)
{
	
	if (mode_buf)
		my_send_to_server(chan?chan->server:from_server, "%s", mode_buf);
	new_free(&mode_buf);
	mode_len = 0;
}
예제 #4
0
int delay_kick (void *arg, char *sub)
{
char * args = (char *)arg;
char * from = NULL;
char * channel = NULL;	
char * serv_num = NULL;
int this_server = from_server;
int server;
ChannelList *chan;
char *p = (char *) arg; /* original args unmodified  so we can free them */

	if (protected)
	{
		from = next_arg(args, &args);
		channel = next_arg(args, &args);
		if ((serv_num = next_arg(args, &args)))
			this_server = my_atol(serv_num);
		if ((chan = prepare_command(&server, channel, 3)))
			my_send_to_server(this_server, "KICK %s %s :\002%s\002 Kick/ban me will ya", channel, from, _VERSION_);
		new_free(&protected);
	}
	new_free(&p); new_free(&sub);
	return 0;
}
예제 #5
0
NickList *check_auto(char *channel, NickList *nicklist, ChannelList *chan)
{

ShitList *shitptr = NULL;
UserList *userptr = NULL;
ChannelList *chan_ptr =  NULL;
char *ban;

	
	if (!channel || !*channel || !nicklist)
		return NULL;
	
	if (!chan)
	{
		ChannelList *chan2;
		chan2 = get_server_channels(from_server);
		chan_ptr = (ChannelList *) find_in_list((List **)&chan2, channel, 0);
	}
	else
		chan_ptr = chan;
	if (!chan_ptr)
		return NULL;		

	if (!chan_ptr->chop)
		return nicklist;
	userptr = nicklist->userlist;
	shitptr = nicklist->shitlist;


	if (userptr && !check_channel_match(userptr->channels, channel))
		userptr = NULL;
	if (shitptr && (!check_channel_match(shitptr->channels, channel) || isme(nicklist->nick)))
		shitptr = NULL;
		
	if (get_cset_int_var(chan_ptr->csets, SHITLIST_CSET) && shitptr != NULL && userptr == NULL)
	{
		char *theshit;
		time_t current = now;
		theshit = get_string_var(SHITLIST_REASON_VAR);
		switch(shitptr->level)
		{
		
			case 0:
				return nicklist;
				break;
			case 1:/* never give opz */
				if (nicklist->sent_deop < 4 && nick_isop(nicklist))
				{
					add_mode(chan_ptr, "o", 0, nicklist->nick, NULL, get_int_var(NUM_OPMODES_VAR));
					nicklist->sent_deop++;
					nicklist->sent_deop_time = current;
				}
				break;				
			case 2: /* Auto Kick  offender */
				add_mode(chan_ptr, NULL, 0, nicklist->nick, shitptr->reason?shitptr->reason:theshit, 0);
				break;
			case 3: /* kick ban the offender */
			case 4:	/* perm ban on offender */
				if (nicklist->sent_deop  < 4 || (nicklist->sent_deop < 4 && shitptr->level == 4))
				{
					send_to_server("MODE %s -o+b %s %s", channel, nicklist->nick, shitptr->filter);
					nicklist->sent_deop++;
					nicklist->sent_deop_time = current;
					if (get_int_var(AUTO_UNBAN_VAR) && shitptr->level != 4)
						add_timer(0, empty_string, get_int_var(AUTO_UNBAN_VAR) * 1000, 1, timer_unban, m_sprintf("%d %s %s", from_server, channel, shitptr->filter), NULL, -1, "auto-unban");
				}
				if (get_cset_int_var(chan_ptr->csets, KICK_IF_BANNED_CSET))
					send_to_server("KICK %s %s :%s", channel,
						nicklist->nick, (shitptr->reason && *shitptr->reason) ? shitptr->reason : theshit);
			default:
				break;
		}
		return nicklist;
	} 

	if (userptr && get_cset_int_var(chan_ptr->csets, USERLIST_CSET))
	{	
		char *buffer = NULL;
		time_t current = now;
		int done = 0;
		char *p = NULL;
		if (get_cset_int_var(chan_ptr->csets, AOP_CSET))
		{
			if ((userptr->flags & ADD_OPS))
			{
				done++;
				if (!userptr->password && !nicklist->sent_reop && !nick_isop(nicklist))
				{
					nicklist->sent_reop++;
					nicklist->sent_reop_time = current;
					if (!(userptr->flags & ADD_IOPS))
					{
						malloc_sprintf(&buffer, "%s %s %s %s %d", channel, nicklist->nick, nicklist->host, "o", from_server);
						add_timer(0, empty_string, 10 * 1000, 1, delay_opz, buffer, NULL, -1, "delay-ops");
					} 
					else
						send_to_server("MODE %s +o %s", chan_ptr->channel, nicklist->nick);
				}
			}
			else if ((userptr->flags & ADD_VOICE))
			{
				done++;
				if (!nicklist->sent_voice && !nick_isvoice(nicklist))
				{
					nicklist->sent_voice++;
					nicklist->sent_voice_time = current;
					if (!(userptr->flags & ADD_IOPS))
					{
						malloc_sprintf(&buffer, "%s %s %s %s %d", channel, nicklist->nick, nicklist->host, "v", from_server);
						add_timer(0, empty_string, 10 * 1000, 1, delay_opz, buffer, NULL, -1, "delay-ops");
					}
					else
						send_to_server("MODE %s +v %s", chan_ptr->channel, nicklist->nick);
				}
			}
		}
		if ((userptr->flags & USER_FLAG_OPS) && (p = get_string_var(USER_FLAG_OPS_VAR)))
		{
			done++;
			run_user_flag("USER_FLAG_OPS", p, nicklist, NULL);
		}
		if (done)
			return nicklist;
	}
	if (get_cset_int_var(chan_ptr->csets, KICK_IF_BANNED_CSET) && check_channel_match(get_string_var(PROTECT_CHANNELS_VAR), chan_ptr->channel))
	{
		char *ipban = NULL;
		char *u = NULL;
		if (!nicklist->host)
			return nicklist;
		ban = m_3dup(nicklist->nick, "!", nicklist->host);
		if (nicklist->ip && nicklist->host)
		{
			char *user = alloca(strlen(nicklist->host)+1);
			strcpy(user, nicklist->host);
			if ((u = strchr(user, '@')))
				*u = 0;
			ipban = m_opendup(nicklist->nick, "!", user, "@", nicklist->ip, NULL);
		}
		if (!isme(nicklist->nick) && (!eban_is_on_channel(ban, chan_ptr) && (ban_is_on_channel(ban, chan_ptr) || (ipban && ban_is_on_channel(ipban, chan_ptr)))) )
		{
			new_free(&ban);
			new_free(&ipban);
			if (nick_isop(nicklist) && !get_cset_int_var(chan_ptr->csets, KICK_OPS_CSET))
				return nicklist;
			my_send_to_server(from_server, "KICK %s %s :Banned", chan_ptr->channel, nicklist->nick);
		}
		new_free(&ban);
		new_free(&ipban);
	}
	return nicklist;
}
예제 #6
0
파일: funny.c 프로젝트: BitchX/BitchX1.1
void funny_namreply(char *from, char **Args)
{
char	*type,
	*channel;
static	char	format[40];
static	int	last_width = -1;
register char	*ptr;
register char	*line;
int user_count = 0;

	PasteArgs(Args, 2);
	type = Args[0];
	channel = Args[1];
	line = Args[2];

	/* protocol violation by server */
	if (!channel || !line)
		return;

	ptr = line;
	while (*ptr)
	{
		while (*ptr && (*ptr != ' '))
			ptr++;
		user_count++;
		while (*ptr && (*ptr == ' '))
			ptr++;
	}

	if (in_join_list(channel, from_server))
	{
		set_display_target(channel, LOG_CRAP);
		if (do_hook(current_numeric, "%s %s %s %s", from, type, channel,line) 
			&& do_hook(NAMES_LIST, "%s %s", channel, line)
			&& get_int_var(SHOW_CHANNEL_NAMES_VAR))
		{
			put_it("%s", convert_output_format(fget_string_var(FORMAT_NAMES_FSET), "%s %s %d",update_clock(GET_TIME), channel, user_count));
			print_funny_names(line);
		} 
		if ((user_count == 1) && (*line == '@'))
		{
			ChannelList *chan;
			if ((chan = lookup_channel(channel, from_server, CHAN_NOUNLINK)))
				if ((ptr = get_cset_str_var(chan->csets, CHANMODE_CSET)))
					my_send_to_server(from_server, "MODE %s %s", channel, ptr);
		}
		got_info(channel, from_server, GOTNAMES);
		reset_display_target();
		return;
	}
	if (last_width != get_int_var(CHANNEL_NAME_WIDTH_VAR))
	{
		if ((last_width = get_int_var(CHANNEL_NAME_WIDTH_VAR)) != 0)
			sprintf(format, "%%s: %%-%u.%us %%s",
				(unsigned char) last_width,
				(unsigned char) last_width);
		else
			strcpy(format, "%s: %s\t%s");
	}
	if (funny_min && (user_count < funny_min))
		return;
	else if (funny_max && (user_count > funny_max))
		return;
	if ((funny_flags & FUNNY_PRIVATE) && (*type == '='))
		return;
	if ((funny_flags & FUNNY_PUBLIC) && ((*type == '*') || (*type == '@')))
		return;
	if (type && channel)
	{
		if (match_str)
		{
			if (wild_match(match_str, channel) == 0)
				return;
		}
		if (do_hook(current_numeric, "%s %s %s %s", from, type, channel, line) && do_hook(NAMES_LIST, "%s %s", channel, line))
		{
			set_display_target(channel, LOG_CRAP);
			if (fget_string_var(FORMAT_NAMES_FSET))
			{
				put_it("%s", convert_output_format(fget_string_var(FORMAT_NAMES_FSET), "%s %s %d", update_clock(GET_TIME), channel, user_count));
				print_funny_names(line);
			} 
			else
			{
				switch (*type)
				{
				case '=':
					if (last_width &&(strlen(channel) > last_width))
					{
						channel[last_width-1] = '>';
						channel[last_width] = (char) 0;
					}
					put_it(format, "Pub", channel, line);
					break;
				case '*':
					put_it(format, "Prv", channel, line);
					break;
				case '@':
					put_it(format, "Sec", channel, line);
					break;
				}
			}
			reset_display_target();
		}
	}
}