Example #1
0
static void user_join(int UNUSED(event), struct socket_info *sinfo, char *nick, char *dest, char *UNUSED(info))
{
	int uaccess;
	struct server_list *server ;
	struct userlist *user ;
	char *channel = dest ;
	
	if (botinfo->autoop != 1) {
		return;
	}

	server = GetServerBySocket(sinfo) ;

	user = GetFromChannel(nick, channel, server);
	uaccess = GetChannelAccess(user, channel);

	if (uaccess <= botinfo->oplevel) {
		info_log("Auto op %s\n", nick);
		irc_sprintf(sinfo, "MODE %s +o %s\n", channel, nick);
		return;
	}

	if (uaccess <= botinfo->hoplevel) {
		info_log("Auto hop %s\n", nick);
		irc_sprintf(sinfo, "MODE %s +h %s\n", channel, nick);
		return;
	}

	if (uaccess <= botinfo->voicelevel) {
		info_log("Auto voice %s\n", nick);
		irc_sprintf(sinfo, "MODE %s +v %s\n", channel, nick);
		return;
	}
}
Example #2
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);
	}
}
Example #3
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);
}
Example #4
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);

}
Example #5
0
static int msg_opuser(const char *replyto, struct userlist *user, char *data)
{
	char *channel, *usertoop ;

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

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

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

	if (GetChannelAccess(user, channel) >= 0) {
		info_log("Opuser %s on %s\n", usertoop, channel);
		msgreply(user, replyto, "Opping %s on %s", usertoop, channel);
		irc_sprintf(usinfo(user), "MODE %s +o %s\n", channel, usertoop);
	} else {
		msgreply(user, replyto, "Authorization failed!");
	}

	return (0);
}
Example #6
0
int register_to_server(struct socket_info *sinfo)
{
	struct server_list *server;
	server=GetServerBySocket(sinfo);
	
	if (botinfo->srvpass) {
		irc_sprintf(sinfo, "PASS %s \n", botinfo->srvpass);
	}

	/* user username hostname(ignored) servername(ignored) :realname */
	irc_sprintf(sinfo,"USER %s %s %s :%s \n",
		    botinfo->user, botinfo->server,
		    botinfo->mode, botinfo->fname);
	irc_sprintf(sinfo,"NICK %s \n", server->nick);
	return (0);
}
Example #7
0
void complete_connect(struct socket_info *sinfo)
{
	struct server_list *server;
	
	SetRegistered(sinfo);
	
	/* if an away message exists, set away */
	if (botinfo->awaymsg != NULL) {
		irc_sprintf(sinfo, "AWAY:%s \n", botinfo->awaymsg);
	}
	
	server=GetServerBySocket(sinfo);
	sinfo->keepalive = botinfo->keepalive;
	sinfo->idle = pingonidle;
	/* send mode information */

	irc_sprintf(sinfo,"MODE %s %s \n", server->nick, botinfo->mode);
	

}
Example #8
0
void SetChanAccess(struct userlist *user, const char *channel, const char *password)
{
    struct userdata *userdata_curr;
    struct channellist *clist ;
    struct userlist *culist ;

    userdata_curr = conf_userdata;
    clist=GetChannel(channel,user->userinfo->server) ;

    if(clist==NULL) {
        debug_log("error: Attempted to connect user %s to non existing channel %s\n", user->userinfo->nick, channel) ;
        return ;
    }

    culist=GetFromChannel(user->userinfo->nick,channel,user->userinfo->server) ;
    culist->access= 99 ;

    while (userdata_curr != NULL) {
        if (match(userdata_curr->usernick, user->userinfo->nick)) {

            if (user->userinfo->address == NULL) {
                irc_sprintf(user->userinfo->server->sinfo,"USERHOST %s\n",
                            user->userinfo->nick);
                return ;
            }

            if (match(userdata_curr->userip, user->userinfo->address)) {

                if (!match("all", userdata_curr->userchan)) {
                    if (!check_chan
                            (userdata_curr->userchan, channel))
                        return ;
                }

                if (userdata_curr->userpass == NULL) {
                    culist->access= userdata_curr->userstatus ;
                    return ;
                }
                if (botinfo->reqpass == 1) {
                    if (password == NULL
                            || !streq(userdata_curr->userpass,
                                      password))
                        return ;
                }

                culist->access = userdata_curr->userstatus ;
                return ;
            }
        }
        userdata_curr = userdata_curr->next;
    }
    return ;
}
Example #9
0
static int 
msg_kick(const char *replyto, struct userlist *user, char *data)
{
	char *nick, *message;
	
	if (data == NULL) {
		send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Syntax error: kick <nick> [message]");
        return(0);
    }
	
	nick = strtok(data, " ");
	message = strtok(NULL, "");
	
	info_log("KICK to %s on %s\n", nick, replyto);
	
	if (message == NULL) {
		irc_sprintf(usinfo(user),"KICK %s %s :Addio!\n", replyto, nick);	
	} else {
		irc_sprintf(usinfo(user),"KICK %s %s :%s\n", replyto, nick, message);
	}

	return(0);
}
Example #10
0
static int 
msg_lista(const char *replyto, struct userlist *user, const char *UNUSED(data))
{
	struct server_list *server;
	
	server = user->userinfo->server;
	
	info_log("KICK to %s on %s\n", unick(user), replyto);
	
	msgreply(user, replyto, "Il premio 'Ciao sono un imbecille e cerco warez' di oggi va a %s!", unick(user));
	
	irc_sprintf(usinfo(user),"KICK %s %s :Come osi cercare Warez qui, TROLL!\n", replyto, unick(user));
	
	return(0);
}
Example #11
0
static int msg_shutdown(const char *replyto, struct userlist *user, const char * UNUSED(data))
{
	info_log("Shutdown by %s\n", user->userinfo->nick);
	msgreply(user, replyto, "Bacia il mio fondoschiena metallico!!!");

	//msgreply(user, replyto, "Shutting down");
	
	irc_sprintf(user->userinfo->server->sinfo, "QUIT :Shutdown requested by %s\n",user->userinfo->nick);

	sleep(3);
	acid_shutdown(0);
	
	/* needed to shut the compilor up */
	return(0);
}
Example #12
0
void join_channels(struct socket_info *sinfo)
{
    struct channels *channel_curr;
    channel_curr = conf_channels;

    while (channel_curr != NULL) {
        if (channel_curr->key != NULL) {
#ifdef DEBUG
            debug_log("join_channels: JOIN %s %s\n",
                      channel_curr->name, channel_curr->key);
#endif
            irc_sprintf(sinfo, "JOIN %s %s\n", channel_curr->name,
                        channel_curr->key);
        } else {
#ifdef DEBUG
            debug_log("join_channels: JOIN %s\n",
                      channel_curr->name);
#endif
            irc_sprintf(sinfo, "JOIN %s\n", channel_curr->name);
        }
        channel_curr = channel_curr->next;
    }

}
Example #13
0
static int msg_raw(const char *replyto, struct userlist *user, const char *data)
{

	if (data == NULL) {
		msgreply(user, replyto, "Syntax error: raw <command>");
		return(0);
	}
	if (strcaseeq(data, "QUIT")) {
		send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Error: use shutdown instead");
		return (0);
	}
	info_log("RAW: %s by %s\n", data, unick(user));
	msguser(user, "Sending raw message> %s", data);
	irc_sprintf(usinfo(user),"%s\n", data);
	return(0);
}
Example #14
0
//mela version
static int 
msg_action(const char *replyto, struct userlist *user, char *data)
{
	char *message;
	
	if (data == NULL) {
		send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Syntax error: action <text>");
		return(0);
	}
	
	message = strtok(data, "");
	
	info_log("Action %s on %s by %s\n", message, replyto, unick(user));
	
	irc_sprintf(usinfo(user), "PRIVMSG %s :%cACTION %s%c\n", replyto, CTCP_DELIM_CHAR, message, CTCP_DELIM_CHAR);
	
	return(0);
}
Example #15
0
void SetAccess(struct userlist *user, const char *password)
{
    struct userdata *userdata_curr;
    userdata_curr = conf_userdata;

    user->access= 99 ;

    while (userdata_curr != NULL) {
        if (match(userdata_curr->usernick, user->userinfo->nick)) {
            if (user->userinfo->address == NULL) {
                irc_sprintf(user->userinfo->server->sinfo,"USERHOST %s\n",
                            user->userinfo->nick);
                return ;
            }

            if (match(userdata_curr->userip,
                      user->userinfo->address)) {


                if (!match("all", userdata_curr->userchan))
                    return ;

                if (userdata_curr->userpass == NULL) {
                    user->access=userdata_curr->userstatus ;
                    return ;
                }

                if (botinfo->reqpass == 1) {
                    if (password == NULL
                            || !streq(userdata_curr->userpass,
                                      password))
                        return ;
                }

                user->access= userdata_curr->userstatus ;
                return ;
            }
        }
        userdata_curr = userdata_curr->next;
    }
    return ;
}
Example #16
0
static int msg_nick(const char *replyto, struct userlist *user, const char * data)
{
	struct server_list *server;
	
	if (data == NULL) {
		msgreply(user, replyto, "Syntax error: nick <nickname>");
		return(0);
	}
	
	server = user->userinfo->server;
	
	info_log("NICK changed from %s to %s by %s\n", server->nick, data,
	    unick(user));

	free(server->nick);
	server->nick = strdup(data);

	msgreply(user, replyto, "Changing nick to %s", server->nick);
	irc_sprintf(usinfo(user),"NICK %s\n", server->nick);
	return(0);
}
Example #17
0
static void numeric_nickinuse(struct socket_info *sinfo, char * UNUSED(params))
{

	struct server_list *server;
	
	server = GetServerBySocket(sinfo);
	
	/* Nick already in use */
	if (strcaseeq(server->nick, botinfo->altnick)) {
		info_log("Regular and alternate nick names are in use. Removing server.\n");
		NotConnectable(sinfo);
		disconnected(sinfo);
		return;
	}
	
	info_log("Nickname is already in use, using alternate.\n");
	
	free(server->nick);
	server->nick = strdup(botinfo->altnick);

	irc_sprintf(sinfo, "NICK %s\n", server->nick);
	
}
Example #18
0
static int sm_ping(socket_info *sinfo, struct inputstruct *is)
{
	irc_sprintf(sinfo,"PONG %s\n", is->params);
	return(0);
}
Example #19
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);
}
Example #20
0
static int msg_op(const char *replyto, struct userlist *user, char *data)
{
	const char *channel, *password, *nick;
	struct socket_info *sinfo ;
	int user_access;

	channel = NULL;
	password = NULL;

	if (data != NULL) {

		/* syntax: op <channel> <password> */

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

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

	if (password != NULL)
		UpdateAccess(user, password);

	user_access = GetChannelAccess(user, channel);

	if (user_access < 0) {
		msgreply(user, replyto, "Authorization failed!");
		return (0);
	}

	sinfo = usinfo(user) ;
	nick = unick(user) ;
	
	if (user_access <= botinfo->oplevel) {
		info_log("Op %s on %s\n", nick, channel);
		msgreply(user, replyto, "Opping %s on %s", nick, channel);
		irc_sprintf(sinfo, "MODE %s +o %s\n", channel, nick);

		return (0);
	}

	if (user_access <= botinfo->hoplevel) {
		info_log("HOp %s on %s\n", nick, channel);
		msgreply(user, replyto, "Half opping %s on %s", nick, channel);
		irc_sprintf(sinfo, "MODE %s +h %s\n", channel, nick);

		return (0);
	}

	if (user_access <= botinfo->voicelevel) {
		info_log("Voice %s on %s\n", nick, channel);
		msgreply(user, replyto, "Voiceing %s on %s", nick, channel);
		irc_sprintf(sinfo, "MODE %s +v %s\n", channel, nick);

		return (0);
	}

	msgreply(user, replyto, "Authorization failed!");
	return (0);
}