+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) {
+ int i = 0;
+ int value = -1;
+ int identical = 1;
+ while(neonspam_settings[i].setting) {
+ if(neonspam_settings[i].flags & SET_SCANOPS) {
+ if(value == -1)
+ value = ((chan->spam_settings->flags & neonspam_settings[i].intparam) ? 1 : 0);
+ else {
+ if(((chan->spam_settings->flags & neonspam_settings[i].intparam) ? 1 : 0) != value) {
+ identical = 0;
+ break;
+ }
+ }
+ }
+ i++;
+ }
+ if(argument) {
+ //binary argument...
+ if(!strcmp(argument, "0") || !stricmp(argument, "off") || !stricmp(argument, get_language_string(user, "NS_SET_OFF"))) {
+ value = 0;
+ } 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);
+ return NULL;
+ }
+ i = 0;
+ char valueBuf[MAXLEN];
+ 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);
+ }
+ i++;
+ }
+ identical = 1;
+ }
+ if(identical && value)
+ return "1";
+ if(identical && !value)
+ return "0";
+ 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) {
+ int i = 0;
+ int value = -1;
+ int identical = 1;
+ while(neonspam_settings[i].setting) {
+ if(neonspam_settings[i].flags & SET_SCANVOICE) {
+ if(value == -1)
+ value = ((chan->spam_settings->flags & neonspam_settings[i].intparam) ? 1 : 0);
+ else {
+ if(((chan->spam_settings->flags & neonspam_settings[i].intparam) ? 1 : 0) != value) {
+ identical = 0;
+ break;
+ }
+ }
+ }
+ i++;
+ }
+ if(argument) {
+ //binary argument...
+ if(!strcmp(argument, "0") || !stricmp(argument, "off") || !stricmp(argument, get_language_string(user, "NS_SET_OFF"))) {
+ value = 0;
+ } 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);
+ return NULL;
+ }
+ i = 0;
+ char valueBuf[MAXLEN];
+ 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);
+ }
+ i++;
+ }
+ identical = 1;
+ }
+ if(identical && value)
+ return "1";
+ if(identical && !value)
+ return "0";
+ 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) {
+ int i = 0;
+ int value = -1;
+ int identical = 1;
+ while(neonspam_settings[i].setting) {
+ if(neonspam_settings[i].flags & SET_SCANEXCEPT) {
+ if(value == -1)
+ value = chan->spam_settings->exceptlevel[neonspam_settings[i].intparam];
+ else {
+ if(chan->spam_settings->exceptlevel[neonspam_settings[i].intparam] != value) {
+ identical = 0;
+ break;
+ }
+ }
+ }
+ i++;
+ }
+ if(argument) {
+ //numeric argument... (access)
+ int caccess = atoi(argument);
+ if(caccess < 0 || caccess > 501) {
+ reply(getTextBot(), user, "NS_INVALID_ACCESS", caccess);
+ return NULL;
+ }
+ int uaccess = getChannelAccess(user, chan, 0);
+ if(uaccess == 500) uaccess++;
+ if(identical && value > uaccess) {
+ if(isGodMode(user)) {
+ event->flags |= CMDFLAG_OPLOG;
+ } else {
+ reply(getTextBot(), user, "NS_SET_CANNOT_SET");
+ return NULL;
+ }
+ }
+ if(caccess > uaccess) {
+ if(isGodMode(user)) {
+ event->flags |= CMDFLAG_OPLOG;
+ } else {
+ reply(getTextBot(), user, "NS_SET_BADLEVEL");
+ return NULL;
+ }
+ }
+ i = 0;
+ char valueBuf[MAXLEN];
+ sprintf(retBuf, "%d", caccess);
+ 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);
+ }
+ i++;
+ }
+ identical = 1;
+ value = caccess;
+ }
+ if(identical) {
+ sprintf(retBuf, "%d", value);
+ return retBuf;
+ }
+ return "?";
+}
+