예제 #1
0
void check_botjoin(Chan *chan, ChanUser *cu)
{
	BotNet	*bn;
	BotInfo *binfo;

#ifdef DEBUG
	debug("(check_botjoin) chan = %s; cu = %s!%s\n",chan->name,cu->nick,cu->userhost);
#endif /* DEBUG */

	for(bn=botnetlist;bn;bn=bn->next)
	{
		if (bn->status != BN_LINKED)
			continue;

		for(binfo=bn->botinfo;binfo;binfo=binfo->next)
		{
			if (!nickcmp(cu->nick,binfo->nuh) &&
				!Strcasecmp(cu->userhost,getuh(binfo->nuh)))
			{
				if ((cu = find_chanbot(chan,binfo->nuh)) == NULL)
					return;
				cu->flags |= CU_NEEDOP;
				send_mode(chan,50,QM_CHANUSER,'+','o',(void*)cu);
#ifdef DEBUG
				debug("(check_botjoin) CU_NEEDOP set, mode pushed\n");
#endif /* DEBUG */
				return;
			}
		}
	}
}
예제 #2
0
파일: shit.c 프로젝트: MadCamel/energymech
Shit *get_shituser(char *userhost, char *channel)
{
	ChanUser *cu;
	Chan	*chan;
	Shit	*shit;
	char	*p;

#ifdef DEBUG
	debug("(get_shituser) userhost = '%s', channel = '%s'\n",
		nullstr(userhost),nullstr(channel));
#endif /* DEBUG */
	/*
	 *  save us a few million function calls if the shitlist is empty
	 */
	if (!current->shitlist)
		return(NULL);
	if (!nickcmp(current->nick,userhost))
		return(NULL);
	for(chan=current->chanlist;chan;chan=chan->next)
	{
		for(cu=chan->users;cu;cu=cu->next)
		{
			p = get_nuh(cu);
			if (matches(userhost,p))
				continue;
			if ((shit = find_shit(p,channel)) != NULL)
				return(shit);
		}
	}
	return(NULL);
}
예제 #3
0
ChanUser *find_chanbot(Chan *chan, char *nick)
{
	ChanUser *cu;

	if (chan->cacheuser && !nickcmp(nick,chan->cacheuser->nick)
		&& chan->cacheuser->user && chan->cacheuser->user->x.x.access == BOTLEVEL)
		return(chan->cacheuser);

	for(cu=chan->users;cu;cu=cu->next)
	{
		if (cu->user && cu->user->x.x.access == BOTLEVEL)
		{
			if (!nickcmp(nick,cu->nick))
				return(chan->cacheuser = cu);
		}
	}
	return(NULL);
}
예제 #4
0
void do_seen(COMMAND_ARGS)
{
	Seen	*seen;
	char	ago[35];		/* enought for "36500 days, 23 hours and 59 minutes" (100 years) */
	char	*chan,*fmt,*n,*u,*c1,*c2,*c3;
	time_t	when;
	int	d,h,m,mul;

	chan = get_channel(to,&rest);
	mul = get_maxaccess(from);

	if (!*rest)
	{
		if (mul) to_user_q(from,"Who do you want me look for?");
		return;
	}

	n = chop(&rest);
	if (!is_nick(n))
	{
		if (mul) to_user_q(from,ERR_NICK,n);
		return;
	}

	if (!nickcmp(n,current->nick))
	{
		fmt = "%s is me you dweeb!";
	}
	else
	if (!nickcmp(n,from))
	{
		fmt = "Trying to find yourself %s?";
	}
	else
	{
		for(seen=seenlist;seen;seen=seen->next)
		{
			if (!Strcasecmp(n,seen->nick))
				break;
		}

		if (!seen)
		{
			fmt = "I have no memory of %s";
		}
		else
		{
			when = now - seen->when;
			d = when / 86400;
			h = (when -= d * 86400) / 3600;
			m = (when -= h * 3600) / 60;

			*ago = 0;
			c2 = ago;

			if (d)
			{
				sprintf(c2,"%i day%s, ",d,EXTRA_CHAR(d));
			}
			if (h || d)
			{
				sprintf(ago,"%s%i hour%s and ",ago,h,EXTRA_CHAR(h));
			}
			sprintf(ago,"%s%i minute%s",ago,m,EXTRA_CHAR(m));

			n = seen->nick;
			u = seen->userhost;
			c1 = seen->pa;
			c2 = ago;

			switch(seen->t)
			{
			case SEEN_PARTED:
				fmt = "%s (%s) parted from %s, %s ago";
				break;
			case SEEN_QUIT:
				fmt = "%s (%s) signed off with message \"%s\", %s ago";
				break;
			case SEEN_NEWNICK:
				fmt = "%s (%s) changed nicks to %s, %s ago";
				break;
			case SEEN_KICKED:
				c2 = seen->pb;
				c3 = ago;
				fmt = "%s (%s) was kicked by %s with message \"%s\", %s ago";
			}
		}
	}

	to_user_q(from,fmt,n,u,c1,c2,c3);
}
예제 #5
0
void make_seen(char *nick, char *userhost, char *pa, char *pb, time_t when, int t)
{
	Seen	*seen,**pp;
	char	*pt;
	uchar	c1;
	int	i;

	for(pt=userhost;*pt;pt++)
	{
		if (*pt == '!')
		{
			userhost = pt + 1;
			break;
		}
	}

	c1 = nickcmptab[(uchar)(*nick)];
	pt = nick + 1;
	pp = &seenlist;

step_one:
	if (*pp)
	{
		if (c1 > nickcmptab[(uchar)(*(*pp)->nick)])
		{
			pp = &(*pp)->next;
			goto step_one;
		}
	}

step_two:
	if (*pp)
	{
		if (c1 == nickcmptab[(uchar)(*(*pp)->nick)])
		{
			i = nickcmp(pt,(*pp)->nick+1);
			if (i > 0)
			{
				pp = &(*pp)->next;
				goto step_two;
			}
			if (!i)
			{
				seen = *pp;
				*pp = seen->next;
				Free((char**)&seen);
			}
		}
	}

	/*
	 *  dont f**k with this code unless you really know what you're doing
	 *  pa might be NULL, but then pb is NULL also; pb might be NULL
	 *  any NULL terminates the Strlen() check
	 */
	set_mallocdoer(make_seen);
	seen = (Seen*)Calloc(sizeof(Seen) + Strlen(nick,userhost,pa,pb,NULL));

	seen->next = *pp;
	*pp = seen;
	seen->when = when;
	seen->t = t;
	/* Calloc sets to zero seen->pa = seen->pb = NULL; */

	seen->userhost = Strcpy(seen->nick,nick) + 1;
	pt = Strcpy(seen->userhost,userhost) + 1;
	if (pa)
	{
		seen->pa = pt;
		pt = Strcpy(seen->pa,pa) + 1;
		if (pb)
		{
			seen->pb = pt;
			Strcpy(seen->pb,pb);
		}
	}

}