Пример #1
0
static int msg_mode(const char *replyto, struct userlist *user, char *data)
{
	char *channel, *modes ;

	if (data == NULL) {
		msgreply(user, replyto, "Syntax error: mode <channel> <flags>");
		return (0);
	}

	channel = strtok(data, " ");
	modes = strtok(NULL, "");

	if (channel == NULL || modes == NULL) {
		msgreply(user, replyto, "Syntax error: mode <channel> <flags>");
		return (0);
	}

	if (GetChannelAccess(user, channel) < 0) {
		return (access_too_low(user, replyto));
	}
	info_log("Mode change %s on %s by %s\n", modes, channel, unick(user));
	msgreply(user, replyto, "Changing mode on %s to %s", channel, modes);
	irc_sprintf(usinfo(user), "MODE %s %s\n", channel, modes);

	return (0);
}
Пример #2
0
static int msg_topic(const char *replyto, struct userlist *user, char *data)
{
	char *channel, *topic ;

	if (data == NULL) {
		msgreply(user, replyto, "Syntax error: topic <channel> <text>");
		return (0);
	}

	channel = strtok(data, " ");
	topic = strtok(NULL, "");

	if (channel == NULL || topic == NULL) {
		msgreply(user, replyto, "Syntax error: topic <channel> <text>");
		return (0);
	}

	if (GetChannelAccess(user, channel) < 0) {
		return (access_too_low(user, replyto));
	}
	info_log("Topic on %s set to %s by %s\n", channel, topic, unick(user));

	msgreply(user, replyto, "Changing topic on %s", channel);

	irc_sprintf(usinfo(user), "TOPIC %s :%s\n", channel, topic);

	return (0);

}
Пример #3
0
static int msg_kick(const char *replyto, struct userlist *user, char *data)
{

	char *channel, *nick, *message ;
	struct userlist *target;
	int user_access;

	/* syntax: kick <channel> <nick> */
	channel = strtok(data, " ");
	nick = strtok(NULL, " ");
	message = strtok(NULL, "");

	if (channel == NULL || nick == NULL) {
		msgreply(user, replyto, "Syntax error: kick <channel> <nickname>");
		return (0);
	}

	if (strcaseeq(nick, user->userinfo->server->nick)) {
		info_log("%s tried to make me kick myself\n", unick(user));
		irc_sprintf(usinfo(user), "KICK %s %s :Try to make me kick myself eh?\n", channel, unick(user));
		return (0);
	}

	user_access = GetChannelAccess(user, channel);

	if (user_access < 0)
		return (access_too_low(user, replyto));

	target = GetFromChannel(nick, channel, user->userinfo->server);

	if (target == NULL)
		msgreply(user, replyto, "I don't see that user in the channel");

	if ((target->access >= 0) && (user_access > target->access)) {
		privmsg(usinfo(user), unick(target), "%s tried to kick you!", unick(user) );
		privmsg(usinfo(user), replyto, "attempt to kick user with higher access denied");
		return (0);
	}

	info_log("KICK %s %s\n", channel, unick(target));

	msgreply(user, replyto, "Kicking %s on %s", nick, channel);

	if (message == NULL) {
		irc_sprintf(usinfo(user), "KICK %s %s\n", channel, nick);
		return (0);
	} else {
		irc_sprintf(usinfo(user), "KICK %s %s :%s\n", channel, nick, message);
		return (0);
	}
}
Пример #4
0
int handle_command(struct userlist *user, const char *dest, char *message)
{
	const char *command;
	char *rest, *trest;
	const char *replyto;
	struct commandlist *listptr;
	int ret;
	
	if(user->access < 0) {
		/* banned users get nothing */
		return(0);
	}
	if(user->access > botinfo->floodexempt) {
		if(botinfo->ctcpdelay != 0 && botinfo->cmddelay+user->lastcmd >= currtime) {
        		time(&user->lastcmd);
        		return(0);
		}
	}
	time(&user->lastcmd);
                        
	if (strcaseeq(dest, user->userinfo->server->nick))
		replyto = unick(user);
	else
		replyto = dest;
	
	command = strtok(message, " ");
	rest = strtok(NULL, "");

	listptr = usercommandlist;
	
	while (listptr != NULL) {
		if (strcaseeq(command, listptr->cmd)) {
			if (user->access <= listptr->access) {
				if ( rest != NULL && (listptr->flags & cmd_param_rw )) { 
					trest = strdup(rest);
					ret = listptr->function(replyto, user, trest);
					safefree(trest);
					return(ret);
				} else {
					ret = listptr->function(replyto, user, rest);
					return (ret);
				}
			} else {
				return (access_too_low(user, replyto));
			}
		}
		listptr = listptr->next;

	}
	return (0);
}
Пример #5
0
static int msg_deop(const char *replyto, struct userlist *user, char *data)
{

	const char *channel, *nick, *snick, *tnick;
	struct socket_info *sinfo ;
	struct userlist *target;
	int user_access;

	channel = NULL;
	nick = NULL;

	if (data != NULL) {

		/* syntax: deop <channel> <nick> */

		channel = strtok(data, " ");
		nick = strtok(NULL, "");
	}

	if (channel == NULL) {
		if (replyto[0] == '#') {
			channel = replyto;
		} else {
			msgreply(user, replyto, "Syntax error: deop <channel> <nick>");
			return (0);
		}
	}

	user_access = GetChannelAccess(user, channel);

	if (user_access < 0) {
		return (access_too_low(user, replyto));
	}

	sinfo = usinfo(user) ;
	
	if (nick == NULL) {
		irc_sprintf(sinfo, "MODE %s -o %s\n", channel, unick(user));
		return(0) ;
	}

	target = GetFromChannel(nick, channel, user->userinfo->server);
	tnick = unick(target) ;

	snick = unick(user) ;

	if (target == NULL) {
		msgreply(user, replyto, "I don't see that user in the channel");
		return (0);
	}
		
	if ((target->access >= 0) && (user_access > target->access)) {
		privmsg(sinfo, tnick, "%s tried to deop you!", snick);
		msgreply(user, replyto, "attempt to deop user with higher access denied");
		return (0);
	}

	info_log("Deop %s on %s\n", snick, channel);
	msgreply(user, replyto, "Deopping %s on %s", tnick, channel);
	irc_sprintf(sinfo, "MODE %s -o %s\n", channel, tnick);
	return (0);
}