ignore users with access > channel_getop/getvoice if ScanChanOps/ScanVoiced is off...
authorpk910 <philipp@zoelle1.de>
Thu, 20 Oct 2011 22:38:42 +0000 (00:38 +0200)
committerpk910 <philipp@zoelle1.de>
Thu, 20 Oct 2011 22:38:42 +0000 (00:38 +0200)
src/event_neonspam_join.c

index b443ef33187d5a914886862c10286b065b34747a..f2af828578d2c710bb406788fff12f16c61223bd 100644 (file)
@@ -95,24 +95,27 @@ static void neonspam_event_join_punish(struct ClientSocket *client, struct ChanU
     if(chanuser->user->flags & USERFLAG_ISAUTHED)
         uaccess = getChannelAccess(chanuser->user, chanuser->chan, 0);
     if(uaccess >= settings->exceptlevel) return;
+    //scanops / scanvoiced
+    MYSQL_RES *res;
+    MYSQL_ROW row, defaults;
+    loadChannelSettings(chanuser->chan);
+    printf_mysql_query("SELECT `%s`, `channel_getop`, `channel_getvoice` FROM `channels` WHERE `channel_id` = '%d'", reaction, chanuser->chan->channel_id);
+    res = mysql_use();
+    row = mysql_fetch_row(res);
+    if(!row[0] || !row[1] || !row[2]) {
+        printf_mysql_query("SELECT `%s`, `channel_getop`, `channel_getvoice` FROM `channels` WHERE `channel_name` = 'defaults'", reaction);
+        res = mysql_use();
+        defaults = mysql_fetch_row(res);
+    }
+    if(!(settings->flags & SPAMSETTINGS_SCANOPS) && uaccess >= atoi((row[1] ? row[1] : defaults[1]))) return;
+    if(!(settings->flags & SPAMSETTINGS_SCANVOICE) && uaccess >= atoi((row[2] ? row[2] : defaults[2]))) return;
     if(action == SPAMSERV_CHECK_WARN) {
         reply(client, chanuser->user, "%s", reason);
     } else if(action == SPAMSERV_CHECK_PUNISH) {
-        MYSQL_RES *res;
-        MYSQL_ROW row;
-        loadChannelSettings(chanuser->chan);
-        printf_mysql_query("SELECT `%s` FROM `channels` WHERE `channel_id` = '%d'", reaction, chanuser->chan->channel_id);
-        res = mysql_use();
-        row = mysql_fetch_row(res);
-        if(!row[0]) {
-            printf_mysql_query("SELECT `%s` FROM `channels` WHERE `channel_name` = 'defaults'", reaction);
-            res = mysql_use();
-            row = mysql_fetch_row(res);
-        }
         int duration = 0;
         char banmaskBuf[NICKLEN+USERLEN+HOSTLEN+3];
         char *banmask = NULL;
-        switch (atoi(row[0])) {
+        switch (atoi((row[0] ? row[0] : defaults[0]))) {
             case 2: //TIMEBAN: 3min
                 duration = 180;
             case 3: //TIMEBAN: 1h