]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/opserv.c
Fix for "whats the color" 8ball question formats
[irc/evilnet/x3.git] / src / opserv.c
index 2a461fbb5f26af7e051dee0c79af9955eb11ae2d..69fff832f0ad23fec57c1f4b24f7868e46a3f2b0 100644 (file)
@@ -217,8 +217,8 @@ static const struct message_entry msgtab[] = {
     { "OSMSG_WHOIS_PRIVS",      "IRCd Privs   : %s" },
     { "OSMSG_WHOIS_CHANNELS",   "Channels     : %s" },
     { "OSMSG_WHOIS_HIDECHANS",  "Channel list omitted for your sanity." },
-    { "OSMSG_WHOIS_VERSION",    "Version      : %s" },  
-    { "OSMSG_WHOIS_SSLFP",      "SSL f/print  : %s" },
+    { "OSMSG_WHOIS_VERSION",    "Version      : %s" },
+    { "OSMSG_WHOIS_SSLFP",      "Cert f/print : %s" },
     { "OSMSG_WHOIS_MARK",       "Mark         : %s" },
     { "OSMSG_WHOIS_MARKS",      "Marks        : %s" },
     { "OSMSG_WHOIS_NO_NOTICE",  "No_notices   : %s" },
@@ -586,6 +586,7 @@ typedef enum {
     REACT_GLINE,
     REACT_TRACK,
     REACT_SHUN,
+    REACT_TEMPSHUN,
     REACT_SVSJOIN,
     REACT_SVSPART,
     REACT_VERSION,
@@ -1531,6 +1532,12 @@ opserv_shun(struct userNode *target, char *src_handle, char *reason, unsigned lo
     return shun_add(src_handle, mask, duration, reason, now, 1);
 }
 
+static void
+opserv_tempshun(struct userNode *target, UNUSED_ARG(char *src_handle), char *reason)
+{
+    irc_tempshun(opserv, target, 0, reason);
+}
+
 static MODCMD_FUNC(cmd_sblock)
 {
     struct userNode *target;
@@ -1574,7 +1581,7 @@ static MODCMD_FUNC(cmd_sblock)
         if(!svccmd_can_invoke(user, cmd->parent->bot, shun_cmd, channel, SVCCMD_NOISY))
             return 0;
     }
-    reason = (argc > 2) ? unsplit_string(argv+2, argc-2, NULL) : NULL;
+    reason = (argc > offset) ? unsplit_string(argv+offset, argc-offset, NULL) : NULL;
     shun = opserv_shun(target, user->handle_info->handle, reason, duration);
     reply("OSMSG_SHUN_ISSUED", shun->target);
     return 1;
@@ -2587,6 +2594,7 @@ static MODCMD_FUNC(cmd_stats_alerts) {
         case REACT_GLINE: reaction = "gline"; break;
         case REACT_TRACK: reaction = "track"; break;
         case REACT_SHUN: reaction = "shun"; break;
+        case REACT_TEMPSHUN: reaction = "tempshun"; break;
         case REACT_SVSJOIN: reaction = "svsjoin"; break;
         case REACT_SVSPART: reaction = "svspart"; break;
         case REACT_VERSION: reaction = "version"; break;
@@ -4919,6 +4927,8 @@ add_user_alert(const char *key, void *data, UNUSED_ARG(void *extra))
         reaction = REACT_TRACK;
     else if (!irccasecmp(react, "shun"))
         reaction = REACT_SHUN;
+    else if (!irccasecmp(react, "tempshun"))
+        reaction = REACT_TEMPSHUN;
     else if (!irccasecmp(react, "svsjoin"))
         reaction = REACT_SVSJOIN;
     else if (!irccasecmp(react, "svspart"))
@@ -5214,6 +5224,7 @@ opserv_saxdb_write(struct saxdb_context *ctx)
             case REACT_GLINE: reaction = "gline"; break;
             case REACT_TRACK: reaction = "track"; break;
             case REACT_SHUN: reaction = "shun"; break;
+            case REACT_TEMPSHUN: reaction = "tempshun"; break;
             case REACT_SVSJOIN: reaction = "svsjoin"; break;
             case REACT_SVSPART: reaction = "svspart"; break;
             case REACT_VERSION: reaction = "version"; break;
@@ -5802,70 +5813,80 @@ discrim_match(discrim_t discrim, struct userNode *user)
 
     if (discrim->modes) {
            unsigned int ii, matches = 0;
+        unsigned int negate = 0;
         for (ii = 0; ii < strlen(discrim->modes); ii++) {
             switch(discrim->modes[ii]) {
+                case '+':
+                    negate = 0;
+                    matches++;
+                    break;
+                case '-':
+                    negate = 1;
+                    matches++;
+                    break;
                 case 'O':
-                    if(IsOper(user)) matches++;
+                    if((IsOper(user) != 0) != negate) matches++;
                     break;
                 case 'o':
-                    if(IsOper(user)) matches++;
+                    if((IsOper(user) != 0) != negate) matches++;
                     break;
                 case 'i':
-                    if(IsInvisible(user)) matches++;
+                    if((IsInvisible(user) != 0) != negate) matches++;
                     break;
                 case 'w':
-                    if(IsWallOp(user)) matches++;
+                    if((IsWallOp(user) != 0) != negate) matches++;
                     break;
                 case 'd':
-                    if(IsDeaf(user)) matches++;
+                    if((IsDeaf(user) != 0) != negate) matches++;
                     break;
                 case 'k':
-                    if(IsService(user)) matches++;
+                    if((IsService(user) != 0) != negate) matches++;
                     break;
                 case 'g':
-                    if(IsGlobal(user)) matches++;
+                    if((IsGlobal(user) != 0) != negate) matches++;
                     break;
                 case 'h':
-                    if(IsSetHost(user)) matches++;
+                    if((IsSetHost(user) != 0) != negate) matches++;
                     break;
                 case 'B':
-                    if(IsBotM(user)) matches++;
+                    if((IsBotM(user) != 0) != negate) matches++;
                     break;
+                case 'p':
                 case 'n':
-                    if(IsHideChans(user)) matches++;
+                    if((IsHideChans(user) != 0) != negate) matches++;
                     break;
                 case 'I':
-                    if(IsHideIdle(user)) matches++;
+                    if((IsHideIdle(user) != 0) != negate) matches++;
                     break;
                 case 'X':
-                    if(IsXtraOp(user)) matches++;
+                    if((IsXtraOp(user) != 0) != negate) matches++;
                     break;
                 case 'x':
-                    if(IsHiddenHost(user)) matches++;
+                    if((IsHiddenHost(user) != 0) != negate) matches++;
                     break;
                 case 'a':
-                    if(IsAdmin(user)) matches++;
+                    if((IsAdmin(user) != 0) != negate) matches++;
                     break;
                 case 'z':
-                    if(IsSSL(user)) matches++;
+                    if((IsSSL(user) != 0) != negate) matches++;
                     break;
                 case 'D':
-                    if(IsPrivDeaf(user)) matches++;
+                    if((IsPrivDeaf(user) != 0) != negate) matches++;
                     break;
                 case 'R':
-                    if(IsAccountOnly(user)) matches++;
+                    if((IsAccountOnly(user) != 0) != negate) matches++;
                     break;
                 case 'W':
-                    if(IsWhoisNotice(user)) matches++;
+                    if((IsWhoisNotice(user) != 0) != negate) matches++;
                     break;
                 case 'H':
-                    if(IsHideOper(user)) matches++;
+                    if((IsHideOper(user) != 0) != negate) matches++;
                     break;
                 case 'L':
-                    if(IsHideOper(user)) matches++;
+                    if((IsHideOper(user) != 0) != negate) matches++;
                     break;
                 case 'q':
-                    if(IsCommonChansOnly(user)) matches++;
+                    if((IsCommonChansOnly(user) != 0) != negate) matches++;
                     break;
             }
         }
@@ -6065,6 +6086,18 @@ trace_shun_func(struct userNode *match, void *extra)
     return 0;
 }
 
+static int
+trace_tempshun_func(struct userNode *match, void *extra)
+{
+  struct discrim_and_source *das = extra;
+
+  if (is_oper_victim(das->source, match, das->discrim->match_opers, 1) && is_trust_victim(match, das->discrim->match_trusted)) {
+    opserv_tempshun(match, das->source->handle_info->handle, das->discrim->reason);
+  }
+
+  return 0;
+}
+
 static int
 trace_kill_func(struct userNode *match, void *extra)
 {
@@ -6302,6 +6335,8 @@ static MODCMD_FUNC(cmd_trace)
         action = trace_gline_func;
     else if (!irccasecmp(argv[1], "shun"))
         action = trace_shun_func;
+    else if (!irccasecmp(argv[1], "tempshun"))
+        action = trace_tempshun_func;
     else if (!irccasecmp(argv[1], "kill"))
         action = trace_kill_func;
     else if (!irccasecmp(argv[1], "gag"))
@@ -6865,6 +6900,9 @@ alert_check_user(const char *key, void *data, void *extra)
     case REACT_SHUN:
         opserv_shun(user, alert->owner, alert->discrim->reason, alert->discrim->duration);
         return 1;
+    case REACT_TEMPSHUN:
+        opserv_tempshun(user, alert->owner, alert->discrim->reason);
+        return 1;
     case REACT_SVSJOIN:
         opserv_svsjoin(user, alert->owner, alert->discrim->reason, alert->discrim->chantarget, alert->discrim->checkrestrictions);
         break;
@@ -7078,6 +7116,8 @@ static MODCMD_FUNC(cmd_addalert)
 #endif
     } else if (!irccasecmp(argv[2], "shun"))
         reaction = REACT_SHUN;
+    else if(!irccasecmp(argv[2], "tempshun"))
+        reaction = REACT_TEMPSHUN;
     else if(!irccasecmp(argv[2], "svsjoin")) 
         reaction = REACT_SVSJOIN;
     else if(!irccasecmp(argv[2], "svspart")) 
@@ -7379,6 +7419,7 @@ init_opserv(const char *nick)
     opserv_define_func("ADDALERT SILENT", NULL, 900, 0, 0);
     opserv_define_func("ADDALERT GLINE", NULL, 900, 0, 0);
     opserv_define_func("ADDALERT SHUN", NULL, 900, 0, 0);
+    opserv_define_func("ADDALERT TEMPSHUN", NULL, 900, 0, 0);
     opserv_define_func("ADDALERT TRACK", NULL, 900, 0, 0);
     opserv_define_func("ADDALERT KILL", NULL, 900, 0, 0);
     opserv_define_func("ADDALERT SVSJOIN", NULL, 999, 0, 0);
@@ -7492,6 +7533,7 @@ init_opserv(const char *nick)
     opserv_define_func("TRACE DOMAINS", NULL, 0, 0, 0);
     opserv_define_func("TRACE GLINE", NULL, 600, 0, 0);
     opserv_define_func("TRACE SHUN", NULL, 600, 0, 0);
+    opserv_define_func("TRACE TEMPSHUN", NULL, 600, 0, 0);
     opserv_define_func("TRACE GAG", NULL, 600, 0, 0);
     opserv_define_func("TRACE KILL", NULL, 600, 0, 0);
     opserv_define_func("TRACE VERSION", NULL, 999, 0, 0);