]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/spamserv.c
$! helpfile syntax for trigger, some cleanup
[irc/evilnet/x3.git] / src / spamserv.c
index 09079297c94219ec4e16f2db2a0f92c5ef58acfb..c31d3341987d6b02b5d7a57003bd0a05dbfdbfa1 100644 (file)
@@ -1803,35 +1803,51 @@ spamserv_punish(struct chanNode *channel, struct userNode *user, time_t expires,
 void
 spamserv_channel_message(struct chanNode *channel, struct userNode *user, char *text)
 {
+       struct chanData *cData;
        struct chanInfo *cInfo;
        struct userInfo *uInfo;
+       struct userData *uData;
        struct spamNode *sNode;
        struct floodNode *fNode;
        unsigned int violation = 0;
        char reason[MAXLEN];
 
        /* make sure: spamserv is not disabled; x3 is running; spamserv is in the chan; chan is regged, user does exist */
-       if(!spamserv || quit_services || !GetUserMode(channel, spamserv) || !(cInfo = get_chanInfo(channel->name)) || !(uInfo = get_userInfo(user->nick)))
+       if(!spamserv || quit_services || !GetUserMode(channel, spamserv) || IsOper(user) || !(cInfo = get_chanInfo(channel->name)) || !(uInfo = get_userInfo(user->nick)))
                return;
 
+       cData = channel->channel_info;
+       uData = GetChannelUser(cData, user->handle_info);
+
        if(!CHECK_CHANOPS(cInfo))
        {
                struct modeNode *mn = GetUserMode(channel, user);
-               if(mn->modes & MODE_CHANOP)
+               if (mn && (mn->modes & MODE_CHANOP))
+                       return;
+
+               /* Chan Ops covers all levels except peon and half op */
+               if(uData && ((uData->access < UL_OP) || (uData->access < UL_MANAGER) || 
+                 (uData->access < UL_COOWNER) || (uData->access < UL_OWNER)))
                        return;
        }
 
        if(!CHECK_HALFOPS(cInfo))
        {
                struct modeNode *mn = GetUserMode(channel, user);
-               if(mn->modes & MODE_HALFOP)
+               if (mn && (mn->modes & MODE_HALFOP))
+                       return;
+
+               if(uData && (uData->access < UL_HALFOP))
                        return;
        }
        
        if(!CHECK_VOICED(cInfo))
        {
                struct modeNode *mn = GetUserMode(channel, user);
-               if((mn->modes & MODE_VOICE) && !(mn->modes & MODE_CHANOP) && !(mn->modes & MODE_HALFOP))
+               if (mn && ((mn->modes & MODE_VOICE) && !(mn->modes & MODE_CHANOP) && !(mn->modes & MODE_HALFOP)))
+                       return;
+
+               if(uData && (uData->access < UL_PEON))
                        return;
        }