#include "cmd_neonspam.h"
-typedef char* neonspam_cmd_set_function(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
-static char* neonspam_cmd_set_trigger(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
-static char* neonspam_cmd_setflags(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
-static char* neonspam_cmd_setexcept(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
-static char* neonspam_cmd_set_reaction(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
-static char* neonspam_cmd_set_reaction_time(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
-static char* neonspam_cmd_setpercent(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
-static char* neonspam_cmd_setsensibility(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
-static char* neonspam_cmd_set_spamlimit(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
-static char* neonspam_cmd_setscanops(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
-static char* neonspam_cmd_setscanvoice(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
-static char* neonspam_cmd_setscanexcept(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
+typedef char* neonspam_cmd_set_function(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
+static char* neonspam_cmd_set_trigger(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
+static char* neonspam_cmd_setflags(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
+static char* neonspam_cmd_setexcept(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
+static char* neonspam_cmd_set_reaction(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
+static char* neonspam_cmd_set_reaction_time(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
+static char* neonspam_cmd_setpercent(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
+static char* neonspam_cmd_setsensibility(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
+static char* neonspam_cmd_set_spamlimit(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
+static char* neonspam_cmd_setscanops(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
+static char* neonspam_cmd_setscanvoice(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
+static char* neonspam_cmd_setscanexcept(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf);
static MYSQL_ROW neonspam_settings_row, neonspam_settings_defaults;
#define SPAMSERV_SETTINGS_QUERY "`channel_spam_reaction`, `channel_spam_reaction_duration`, `channel_flood_reaction`, `channel_flood_reaction_duration`, `channel_join_reaction`, `channel_join_reaction_duration`, `channel_botnet_bantime`, `channel_caps_reaction`, `channel_caps_reaction_duration`, `channel_digit_reaction`, `channel_digit_reaction_duration`, `channel_badword_reaction`, `channel_badword_reaction_duration`"
if(isGodMode(user)) {
event->flags |= CMDFLAG_OPLOG;
} else {
- reply(getTextBot(), user, "NS_SET_DEFAULTS_OWNER", chan->name);
+ reply(textclient, user, "NS_SET_DEFAULTS_OWNER", chan->name);
return;
}
}
sprintf(defaultskey, "%08x", seed);
if(argc > 1 && !strcmp(argv[1], defaultskey)) {
printf_mysql_query("UPDATE `channels` SET " SPAMSERV_SETTINGS_RESET " WHERE `channel_id` = '%d'", chan->channel_id);
- reply(getTextBot(), user, "NS_SET_DEFAULTS_DONE", chan->name);
+ reply(textclient, user, "NS_SET_DEFAULTS_DONE", chan->name);
logEvent(event);
} else {
- reply(getTextBot(), user, "NS_SET_DEFAULTS_CODE", chan->name, defaultskey);
+ reply(textclient, user, "NS_SET_DEFAULTS_CODE", chan->name, defaultskey);
}
} else if(argc && strcmp(argv[0], "help")) {
//find the correct command
char valueBuf[MAXLEN], nameBuf[MAXLEN];
char *value, *optimized_value, *option_help;
neonspam_cmd_set_function *func = neonspam_settings[i].function;
- value = func(client, user, chan, event, neonspam_settings[i].intparam, neonspam_settings[i].charparam, args, valueBuf);
+ value = func(client, textclient, user, chan, event, neonspam_settings[i].intparam, neonspam_settings[i].charparam, args, valueBuf);
if(value) {
optimized_value = value;
if(neonspam_settings[i].flags & SET_BOOL) {
option_help = get_language_string(user, nameBuf);
} else
option_help = NULL;
- reply(getTextBot(), user, "\002%s\002 %s%s%s", neonspam_settings[i].setting, optimized_value, (option_help ? " - " : ""), (option_help ? option_help : ""));
+ reply(textclient, user, "\002%s\002 %s%s%s", neonspam_settings[i].setting, optimized_value, (option_help ? " - " : ""), (option_help ? option_help : ""));
if(neonspam_settings[i].flags & SET_OPT) {
int maxoption = (neonspam_settings[i].flags & SET_OPT_MAX) >> SET_OPT_SHIFT;
for(j = 0; j < maxoption; j++) {
sprintf(nameBuf, "SS_SET_OPTION_%s_%d", neonspam_settings[i].setting, j);
option_help = get_language_string(user, nameBuf);
- reply(getTextBot(), user, " \002%d\002 - %s", j, option_help);
+ reply(textclient, user, " \002%d\002 - %s", j, option_help);
}
}
if((neonspam_settings[i].flags & SET_HELP) && argc && !strcmp(argv[0], "help")) {
sprintf(nameBuf, "SS_SET_HELP_%s", neonspam_settings[i].setting);
tmp = get_language_string(user, nameBuf);
if(tmp) {
- reply(getTextBot(), user, " %s", tmp);
+ reply(textclient, user, " %s", tmp);
}
}
}
}
if(j == 0) {
//unknown setting
- reply(getTextBot(), user, "NS_SET_UNKNOWN_SETTING", argv[0]);
+ reply(textclient, user, "NS_SET_UNKNOWN_SETTING", argv[0]);
}
} else {
char valueBuf[MAXLEN], nameBuf[MAXLEN];
res = mysql_use();
neonspam_settings_row = mysql_fetch_row(res);
i = -1;
- reply(getTextBot(), user, "NS_SET_HEADER", chan->name);
+ reply(textclient, user, "NS_SET_HEADER", chan->name);
while(neonspam_settings[++i].setting) {
if((chan->spam_settings->flags & (neonspam_settings[i].if_flag & SPAMSETTINGS_FLAGS)) != (neonspam_settings[i].if_flag & SPAMSETTINGS_FLAGS))
continue;
if((neonspam_settings[i].if_flag & SPAMSETTINGS_ISTIMEBAN) && !boolflag)
continue;
neonspam_cmd_set_function *func = neonspam_settings[i].function;
- value = func(client, user, chan, event, neonspam_settings[i].intparam, neonspam_settings[i].charparam, NULL, valueBuf);
+ value = func(client, textclient, user, chan, event, neonspam_settings[i].intparam, neonspam_settings[i].charparam, NULL, valueBuf);
if(neonspam_settings[i].if_flag & SPAMSETTINGS_SETTIMEBAN)
boolflag = !strcmp(value, "2");
//TODO: append option or help info
}
char **table_lines = table_end(table);
for(i = 0; i < table->entrys; i++) {
- reply(getTextBot(), user, table_lines[i]);
+ reply(textclient, user, table_lines[i]);
}
table_free(table);
}
}
-static char* neonspam_cmd_set_trigger(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf) {
+static char* neonspam_cmd_set_trigger(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf) {
char *trigger;
//get current trigger
MYSQL_RES *res;
if(isGodMode(user)) {
event->flags |= CMDFLAG_OPLOG;
} else {
- reply(getTextBot(), user, "NS_SET_TRIGGER_OWNER", chan->name);
+ reply(textclient, user, "NS_SET_TRIGGER_OWNER", chan->name);
return NULL;
}
}
return trigger;
}
-static char* neonspam_cmd_setflags(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int flag, char *charparam, char *argument, char *retBuf) {
+static char* neonspam_cmd_setflags(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int flag, char *charparam, char *argument, char *retBuf) {
char *value = ((chan->spam_settings->flags & flag) ? "1" : "0");
if(argument) {
//binary argument...
} else if(!strcmp(argument, "1") || !stricmp(argument, "on") || !stricmp(argument, get_language_string(user, "NS_SET_ON"))) {
chan->spam_settings->flags |= flag;
} else {
- reply(getTextBot(), user, "NS_SET_INVALID_BOOLEAN", argument);
+ reply(textclient, user, "NS_SET_INVALID_BOOLEAN", argument);
return NULL;
}
char str_flags[50];
return value;
}
-static char* neonspam_cmd_setexcept(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int exceptlvl_index, char *field, char *argument, char *retBuf) {
+static char* neonspam_cmd_setexcept(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int exceptlvl_index, char *field, char *argument, char *retBuf) {
unsigned int value = chan->spam_settings->exceptlevel[exceptlvl_index];
if(argument) {
//numeric argument... (access)
int caccess = atoi(argument);
if(caccess < 0 || caccess > 501) {
- reply(getTextBot(), user, "NS_INVALID_ACCESS", caccess);
+ reply(textclient, user, "NS_INVALID_ACCESS", caccess);
return NULL;
}
int uaccess = getChannelAccess(user, chan);
if(isGodMode(user)) {
event->flags |= CMDFLAG_OPLOG;
} else {
- reply(getTextBot(), user, "NS_SET_CANNOT_SET");
+ reply(textclient, user, "NS_SET_CANNOT_SET");
return NULL;
}
}
if(isGodMode(user)) {
event->flags |= CMDFLAG_OPLOG;
} else {
- reply(getTextBot(), user, "NS_SET_BADLEVEL");
+ reply(textclient, user, "NS_SET_BADLEVEL");
return NULL;
}
}
return retBuf;
}
-static char* neonspam_cmd_set_reaction(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int mysqlindex, char *mysqlfield, char *argument, char *retBuf) {
+static char* neonspam_cmd_set_reaction(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int mysqlindex, char *mysqlfield, char *argument, char *retBuf) {
if(argument) {
/* valid options:
* 0/kick - kick
} else if(!strcmp(argument, "2") || !stricmp(argument, "ban")) {
argument = "2";
} else {
- reply(getTextBot(), user, "NS_SET_INVALID_OPTION_STR", argument);
+ reply(textclient, user, "NS_SET_INVALID_OPTION_STR", argument);
return NULL;
}
printf_mysql_query("UPDATE `channels` SET `%s` = '%s' WHERE `channel_id` = '%d' ", mysqlfield, argument, chan->channel_id);
}
}
-static char* neonspam_cmd_set_reaction_time(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int mysqlindex, char *mysqlfield, char *argument, char *retBuf) {
+static char* neonspam_cmd_set_reaction_time(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int mysqlindex, char *mysqlfield, char *argument, char *retBuf) {
int duration;
if(argument) {
duration = strToTime(user, argument);
if(duration < 30) {
- reply(getTextBot(), user, "NS_TIMEBAN_DURATION_TOO_SHORT", 30);
+ reply(textclient, user, "NS_TIMEBAN_DURATION_TOO_SHORT", 30);
return NULL;
}
printf_mysql_query("UPDATE `channels` SET `%s` = '%s' WHERE `channel_id` = '%d' ", mysqlfield, argument, chan->channel_id);
return retBuf;
}
-static char* neonspam_cmd_setpercent(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int percent_index, char *mysqlfield, char *argument, char *retBuf) {
+static char* neonspam_cmd_setpercent(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int percent_index, char *mysqlfield, char *argument, char *retBuf) {
unsigned int value = chan->spam_settings->percent[percent_index];
if(argument) {
//numeric argument... (access)
value = atoi(argument);
if(value < 0 || value > 100) {
//invalid percent value
- reply(getTextBot(), user, "SS_SET_PERCENT", value);
+ reply(textclient, user, "SS_SET_PERCENT", value);
return NULL;
}
chan->spam_settings->percent[percent_index] = value;
return retBuf;
}
-static char* neonspam_cmd_setsensibility(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int sensibility_index, char *mysqlfield, char *argument, char *retBuf) {
+static char* neonspam_cmd_setsensibility(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int sensibility_index, char *mysqlfield, char *argument, char *retBuf) {
if(argument) {
//change value
char *delimiter = strstr(argument, ":");
if(!delimiter) {
//invalid format
- reply(getTextBot(), user, "SS_SET_SENSIBILITY", argument);
+ reply(textclient, user, "SS_SET_SENSIBILITY", argument);
return NULL;
}
*delimiter = '\0';
int timep = atoi(delimiter);
if(amount > MAX_FLOOD_AMOUNT || amount < MIN_FLOOD_AMOUNT) {
//invalid amount
- reply(getTextBot(), user, "SS_SET_SENSIBILITY_AMOUNT", amount, MIN_FLOOD_AMOUNT, MAX_FLOOD_AMOUNT);
+ reply(textclient, user, "SS_SET_SENSIBILITY_AMOUNT", amount, MIN_FLOOD_AMOUNT, MAX_FLOOD_AMOUNT);
return NULL;
}
if(timep > MAX_FLOOD_TIME || timep < 0) {
//invalid time period
- reply(getTextBot(), user, "SS_SET_SENSIBILITY_TIME", timep, 0, MAX_FLOOD_TIME);
+ reply(textclient, user, "SS_SET_SENSIBILITY_TIME", timep, 0, MAX_FLOOD_TIME);
return NULL;
}
char amountfield[50], timefield[50];
return retBuf;
}
-static char* neonspam_cmd_set_spamlimit(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf) {
+static char* neonspam_cmd_set_spamlimit(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int intparam, char *charparam, char *argument, char *retBuf) {
if(argument) {
//change value
int amount = atoi(argument);
if(amount > 10 || amount < 2) {
//invalid amount
- reply(getTextBot(), user, "SS_SET_SPAMLIMIT", amount, 2, 10);
+ reply(textclient, user, "SS_SET_SPAMLIMIT", amount, 2, 10);
return NULL;
}
printf_mysql_query("UPDATE `channels` SET `channel_maxrepeat` = '%d' WHERE `channel_id` = '%d' ", amount, chan->channel_id);
return retBuf;
}
-static char* neonspam_cmd_setscanops(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int flag, char *charparam, char *argument, char *retBuf) {
+static char* neonspam_cmd_setscanops(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int flag, char *charparam, char *argument, char *retBuf) {
int i = 0;
int value = -1;
int identical = 1;
} else if(!strcmp(argument, "1") || !stricmp(argument, "on") || !stricmp(argument, get_language_string(user, "NS_SET_ON"))) {
value = 1;
} else {
- reply(getTextBot(), user, "NS_SET_INVALID_BOOLEAN", argument);
+ reply(textclient, user, "NS_SET_INVALID_BOOLEAN", argument);
return NULL;
}
i = 0;
while(neonspam_settings[i].setting) {
if(neonspam_settings[i].flags & SET_SCANOPS) {
neonspam_cmd_set_function *func = neonspam_settings[i].function;
- func(client, user, chan, event, neonspam_settings[i].intparam, neonspam_settings[i].charparam, (value ? "1" : "0"), valueBuf);
+ func(client, textclient, user, chan, event, neonspam_settings[i].intparam, neonspam_settings[i].charparam, (value ? "1" : "0"), valueBuf);
}
i++;
}
return "?";
}
-static char* neonspam_cmd_setscanvoice(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int flag, char *charparam, char *argument, char *retBuf) {
+static char* neonspam_cmd_setscanvoice(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int flag, char *charparam, char *argument, char *retBuf) {
int i = 0;
int value = -1;
int identical = 1;
} else if(!strcmp(argument, "1") || !stricmp(argument, "on") || !stricmp(argument, get_language_string(user, "NS_SET_ON"))) {
value = 1;
} else {
- reply(getTextBot(), user, "NS_SET_INVALID_BOOLEAN", argument);
+ reply(textclient, user, "NS_SET_INVALID_BOOLEAN", argument);
return NULL;
}
i = 0;
while(neonspam_settings[i].setting) {
if(neonspam_settings[i].flags & SET_SCANVOICE) {
neonspam_cmd_set_function *func = neonspam_settings[i].function;
- func(client, user, chan, event, neonspam_settings[i].intparam, neonspam_settings[i].charparam, (value ? "1" : "0"), valueBuf);
+ func(client, textclient, user, chan, event, neonspam_settings[i].intparam, neonspam_settings[i].charparam, (value ? "1" : "0"), valueBuf);
}
i++;
}
return "?";
}
-static char* neonspam_cmd_setscanexcept(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int flag, char *charparam, char *argument, char *retBuf) {
+static char* neonspam_cmd_setscanexcept(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, int flag, char *charparam, char *argument, char *retBuf) {
int i = 0;
int value = -1;
int identical = 1;
//numeric argument... (access)
int caccess = atoi(argument);
if(caccess < 0 || caccess > 501) {
- reply(getTextBot(), user, "NS_INVALID_ACCESS", caccess);
+ reply(textclient, user, "NS_INVALID_ACCESS", caccess);
return NULL;
}
int uaccess = getChannelAccess(user, chan);
if(isGodMode(user)) {
event->flags |= CMDFLAG_OPLOG;
} else {
- reply(getTextBot(), user, "NS_SET_CANNOT_SET");
+ reply(textclient, user, "NS_SET_CANNOT_SET");
return NULL;
}
}
if(isGodMode(user)) {
event->flags |= CMDFLAG_OPLOG;
} else {
- reply(getTextBot(), user, "NS_SET_BADLEVEL");
+ reply(textclient, user, "NS_SET_BADLEVEL");
return NULL;
}
}
while(neonspam_settings[i].setting) {
if(neonspam_settings[i].flags & SET_SCANEXCEPT) {
neonspam_cmd_set_function *func = neonspam_settings[i].function;
- func(client, user, chan, event, neonspam_settings[i].intparam, neonspam_settings[i].charparam, retBuf, valueBuf);
+ func(client, textclient, user, chan, event, neonspam_settings[i].intparam, neonspam_settings[i].charparam, retBuf, valueBuf);
}
i++;
}