Exemplo n.º 1
0
void do_shitlist(COMMAND_ARGS)
{
	Shit	*shit;

	table_buffer("\037channel\037\t\037mask\037\t\037action\037\t\037set by\037\t\037reason\037\t\037expires\037");
	for(shit=current->shitlist;shit;shit=shit->next)
	{
		table_buffer(FMT_6XSTRTAB,shit->chan,shit->mask,shit_actions[shit->action],
			nickcpy(NULL,shit->from),shit->reason,time2away(shit->expire));
	}
	table_send(from,2);
}
Exemplo n.º 2
0
int do_help_callback(char *line)
{
#ifdef DEBUG
	debug("(do_help_callback) `%s'\n",line);
#endif /* DEBUG */
	table_buffer(FMT_PLAIN,line);
	return(FALSE);
}
Exemplo n.º 3
0
void do_kicksay(COMMAND_ARGS)
{
	/*
	 *  on_msg checks: CARGS
	 */
	KickSay *kick;
	char	*channel,*mask;
	int	inum;

	channel = chop(&rest);
	if (!channel)
	{
		if (!current->kicklist)
		{
			to_user(from,"Kicksay list is empty");
			return;
		}

		if (dcc_only_command(from))
			return;

		table_buffer("\037channel\037\t\037action\037\t\037string\037\t\037kick reason\037");
		for(kick=current->kicklist;kick;kick=kick->next)
		{
			table_buffer("%s\t%s\t%s\t%s",kick->chan,ks_actions[kick->action],kick->mask,kick->reason);
		}
		table_send(from,2);
		return;
	}

	if (ischannel(channel) || *channel == '*')
	{

		if (get_useraccess(from,channel) < cmdaccess)
			return;

		inum = DEFAULT_KS_LEVEL;
		if (*rest != '"')
		{
			inum = a2i(chop(&rest));
			if (errno || inum < 0 || inum > MAX_KS_LEVEL)
				return;
		}

		mask = get_token(&rest,"\"");

		if (!mask || !*mask)
			goto usage;

		/*
		 *  check for previously existing kicks
		 */
		if ((kick = find_kicksay(mask,channel)) != NULL)
		{
			to_user(from,"I'm already kicking on \"%s\"",kick->mask);
			return;
		}

		/*
		 *  dig out the reason (the rest)
		 */
		while(rest && *rest == ' ')
			rest++;
		if (!*rest)
			goto usage;

		/*
		 *  add it to the list
		 */
		set_mallocdoer(do_kicksay);
		kick = (KickSay*)Calloc(sizeof(KickSay) + Strlen(channel,mask,rest,NULL));

		kick->next = current->kicklist;
		current->kicklist = kick;
		kick->action = inum;

		if (!matches("\\*?*\\*",mask))
			kick->chan = Strcpy(kick->mask,mask) + 1;
		else
		{
			kick->mask[0] = '*';
			Strcpy(kick->mask+1,mask);
			kick->chan = Strcat(kick->mask,MATCH_ALL) + 1;
		}
		kick->reason = Strcpy(kick->chan,channel) + 1;
				Strcpy(kick->reason,rest);

		to_user(from,"Now kicking on \"%s\" on %s",mask,channel);
		current->ul_save++;
		return;
	}
usage:
	usage(from);	/* usage for CurrentCmd->name */
}
Exemplo n.º 4
0
void do_help(COMMAND_ARGS)
{
	char	line[MSGLEN];
	char	*pt;
	int	i,level,axs;
	int	cur,nxt,count,ci,tl;
	int	in;

	if (dcc_only_command(from))
		return;

	axs = get_maxaccess(from);

	if (!*rest)
	{
		cur = -1;
		*line = 0;
help_loop:
		count = 0;
		nxt = OWNERLEVEL;

		for(i=0;mcmd[i].name;i++)
		{
			tl = acmd[i];
			if ((tl < nxt) && (tl > cur))
				nxt = tl;
			if (tl != cur)
				continue;
			if (count == 0)
				sprintf(line,"\037Level %3i\037: ",cur);
			count++;
		}
		if (!count)
		{
			cur = nxt;
			goto help_loop;
		}
		ci = count;
		for(i=0;mcmd[i].name;i++)
		{
			tl = acmd[i];
			if (tl != cur)
				continue;
			if (ci != count)
				Strcat(line,", ");
			print_help(from,line,strlen(mcmd[i].name));
			if (*line == 0)
				Strcpy(line,"           ");
			Strcat(line,(char*)mcmd[i].name);
			count--;
		}
		print_help(from,line,500);
		if ((cur != OWNERLEVEL) && (nxt <= axs))
			cur = nxt;
		else
			return;
		goto help_loop;
	}

	level = a2i(rest);
	if (!errno)
	{
		if ((level > axs) || (level < 0))
			level = axs;
		to_user(from,"\037Commands available at Level %i:\037",level);
		*line = 0;
		ci = 0;
		for(i=0;mcmd[i].name;i++)
		{
			if (acmd[i] <= level)
			{
				if (ci != 0)
					Strcat(line,", ");
				ci++;
				print_help(from,line,strlen(mcmd[i].name));
				Strcat(line,(char*)mcmd[i].name);
			}
		}
		if (ci)
			print_help(from,line,58);
		else
			to_user(from,TEXT_NONE);
		return;
	}

	if (STRCHR(rest,'*'))
	{
		line[0] = 0;
		ci = 0;
		to_user(from,"\037Commands that match query %s\037:",rest);
		for(i=0;mcmd[i].name;i++)
		{
			if ((!matches(rest,(char*)mcmd[i].name)) && (acmd[i] <= axs))
			{
				if (ci != 0)
					Strcat(line,", ");
				ci++;
				print_help(from,line,strlen(mcmd[i].name));
				Strcat(line,(char*)mcmd[i].name);
			}
		}
		if (ci)
			print_help(from,line,500);
		else
			to_user(from,TEXT_NONE);
		return;
	}

	/*
	 *  We dont want to show help for "../../../../../../etc/passwd"
	 */
	if (!is_safepath(rest))
		return;

	pt = Strcpy(line,HELPDIR);
	for(i=0;(rest[i]);i++)
	{
		if (rest[i] >= 'a' && rest[i] <= 'z')
			*pt = rest[i] - 0x20;
		else
			*pt = rest[i];
		pt++;
	}
	*pt = 0;
#ifdef DEBUG
	debug("(do_help) help file check: %s\n",line);
#endif /* DEBUG */
	if ((in = open(line,O_RDONLY)) < 0)
	{
		to_user(from,"No help found for \"%s\"",rest);
		return;
	}

#ifdef DEBUG
	debug("(do_help) helpfile for = '%s'\n",rest);
#endif /* DEBUG */

	table_buffer("\037Help on %s\037",rest);
	level = access_needed(rest);
	if (level > 200)
		table_buffer("Level needed: Command disabled");
	else
	if (level > 0)
		table_buffer("Level needed: %i",level);
	for(i=0;ulist[i].command;i++)
	{
		if (!Strcasecmp(rest,ulist[i].command))
		{
			pt = (ulist[i].usage) ? ulist[i].usage : "";
			table_buffer("Usage: %s %s",ulist[i].command,pt);
			break;
		}
	}
	readline(in,&do_help_callback);				/* readline closes in */
	table_send(from,0);
}