コード例 #1
0
ファイル: usrcommands.c プロジェクト: ranauei/melabot
/*
static int msg_part(const char *replyto, struct userlist *user, const char *data)
{

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

	if(ExitChannel(data, user->userinfo->server)==-1) {
		msgreply(user, replyto, "I can't part a channel that I'm not in");
	} else {
		msgreply(user, replyto, "Parting %s", data);
		info_log("Parted %s by %s\n", data, user->userinfo->nick);
	}

	return (0);

}

static int msg_ctcp(const char *replyto, struct userlist *user, const char *data)
{

	if (data == NULL) {
		if (botinfo->ctcp == 1) {
			msgreply(user, replyto, "CTCP ON");
		} else {
			msgreply(user, replyto, "CTCP OFF");
		}
		
		return(0);
	}
	
	if (strcaseeq("off", data)) {
		botinfo->ctcp = 0;
		msgreply(user, replyto, "CTCP OFF");
		return(0);
	}
	if (strcaseeq("on", data)) {
		botinfo->ctcp = 1;
		msgreply(user, replyto, "CTCP ON");
		return(0);
	}
	msgreply(user, replyto, "Syntax error: ctcp <on/off>");
	return(0);
}
*/
static int 
msg_part(const char *replyto, struct userlist *user, char *data)
{
	char *channel, *message;
	
	if (data == NULL) {
		send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Syntax error: part <channel> [text]");
		return(0);
	}
	
	channel = strtok(data, " ");
	message = strtok(NULL, "");
	
	if (message == NULL) {
		privmsg(usinfo(user), channel, "Bye!");
	} else {
		privmsg(usinfo(user), channel, "%s", message);
	}

	if (ExitChannel(data, user->userinfo->server) == -1) {
		send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "I can't part a channel that I'm not in");
	} else {
		send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Parting %s", data);
		info_log("Parted %s by %s\n", data, user->userinfo->nick);
	}
	
	return(0);
}
コード例 #2
0
ファイル: usrcommands.c プロジェクト: ranauei/melabot
//mela actions :)
static int
msg_peluche(const char *replyto, struct userlist *user, char *data)
{
	char *message, *msg;
	int i;

	if (data != NULL) {
		message = strtok(data, "");

		if (*(message + strlen(message) - 1) == ' ')
			*(message + strlen(message) - 1) = '\0';
	
		msg = malloc(sizeof(char) * strlen(data) + 1);
		for (i = 0; i < strlen(data); i++)
			*(msg + i) = '=';
		*(msg + strlen(data)) = '\0';
	
		info_log("Peluche %s on %s by %s\n", message, replyto, unick(user));
		
		privmsg(usinfo(user), replyto, "%s: 8%sD", message, msg);

		free(msg);
	} else {
		info_log("Peluche on %s by %s\n", replyto, unick(user));

		privmsg(usinfo(user), replyto, "8=============D");
	}

	return (0);
}
コード例 #3
0
ファイル: chanop.c プロジェクト: bschwab/acidblood
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
ファイル: chanop.c プロジェクト: bschwab/acidblood
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);
}
コード例 #5
0
ファイル: chanop.c プロジェクト: bschwab/acidblood
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);

}
コード例 #6
0
ファイル: chanop.c プロジェクト: bschwab/acidblood
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);
}
コード例 #7
0
ファイル: usrcommands.c プロジェクト: ranauei/melabot
static int 
msg_freshhu(const char *replyto, struct userlist *user, char *data)
{
	char *message;
	
	if (data == NULL) {
		privmsg(usinfo(user), replyto, "PRHUUUUUUUUUUUUUU");
		
		return(0);
	}
	
	message = strtok(data, "");
	
	info_log("Freshhing %s on %s by %s\n", message, replyto, unick(user));

	if (message[strlen(message) - 1] == ' ')
        	message[strlen(message) - 1] = '\0';
	
	privmsg(usinfo(user), replyto, "%s: PRHUUUUUUUUUUUUUU", message);
	
	return(0);
}
コード例 #8
0
ファイル: usrcommands.c プロジェクト: ranauei/melabot
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);
}
コード例 #9
0
ファイル: usrcommands.c プロジェクト: ranauei/melabot
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);
}
コード例 #10
0
ファイル: usrcommands.c プロジェクト: ranauei/melabot
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);
}
コード例 #11
0
ファイル: usrcommands.c プロジェクト: ranauei/melabot
/*
static int msg_say(const char *replyto, struct userlist *user, char *data)
{
	char *channel, *message;

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

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

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

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

	info_log("Say %s on %s by %s\n", message, channel, unick(user));

	msguser(user, "Saying message on %s", channel);
	privmsg(usinfo(user),channel, "%s", message);
	return(0);

}
*/
static int 
msg_say(const char *replyto, struct userlist *user, char *data)
{
	char *message;
	
	if (data == NULL) {
		return(0);
	}
	
	message = strtok(data, "");
	
	info_log("Say %s on %s by %s\n", message, replyto, unick(user));
	
	privmsg(usinfo(user), replyto, "%s", message);
	
	return(0);
}
コード例 #12
0
ファイル: usrcommands.c プロジェクト: ranauei/melabot
//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);
}
コード例 #13
0
ファイル: usrcommands.c プロジェクト: ranauei/melabot
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);
}
コード例 #14
0
ファイル: chanop.c プロジェクト: bschwab/acidblood
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);
}
コード例 #15
0
ファイル: chanop.c プロジェクト: bschwab/acidblood
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);
}