]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/opserv.c
Minor typo in previous commit where returning 0 when it should have been 1 from opser...
[irc/evilnet/x3.git] / src / opserv.c
index 571879300ea1777133859174f0a7df48392e8336..ced02ef569cc677b3131bb3d49fd8dfee8cbb0b2 100644 (file)
@@ -586,7 +586,9 @@ typedef enum {
     REACT_SVSJOIN,
     REACT_SVSPART,
     REACT_VERSION,
-    REACT_MARK
+    REACT_MARK,
+    REACT_NOTICEUSER,
+    REACT_MSGUSER
 } opserv_alert_reaction;
 
 struct opserv_user_alert {
@@ -2532,6 +2534,8 @@ static MODCMD_FUNC(cmd_stats_alerts) {
         case REACT_SVSPART: reaction = "svspart"; break;
         case REACT_VERSION: reaction = "version"; break;
         case REACT_MARK: reaction = "mark"; break;
+        case REACT_NOTICEUSER: reaction = "noticeuser"; break;
+        case REACT_MSGUSER: reaction = "msguser"; break;
         default: reaction = "<unknown>"; break;
         }
         reply("OSMSG_ALERT_IS", iter_key(it), reaction, alert->owner);
@@ -2915,7 +2919,7 @@ opserv_channel_check(struct chanNode *newchan, UNUSED_ARG(void *extra))
 }
 
 static void
-opserv_channel_delete(struct chanNode *chan)
+opserv_channel_delete(struct chanNode *chan, UNUSED_ARG(void *extra))
 {
     timeq_del(0, opserv_part_channel, chan, TIMEQ_IGNORE_WHEN);
 }
@@ -2955,7 +2959,9 @@ opserv_join_check(struct modeNode *mNode, UNUSED_ARG(void *extra))
     if (IsService(user))
         return 0;
 
-    dict_foreach(opserv_channel_alerts, alert_check_user, user);
+    /* Check for alerts, and stop if we find one that kills them. */
+    if (dict_foreach(opserv_user_alerts, alert_check_user, user))
+        return 1;
 
     if (opserv && channel->bad_channel) {
         opserv_debug("Found $b%s$b in bad-word channel $b%s$b; removing the user.", user->nick, channel->name);
@@ -4864,6 +4870,10 @@ add_user_alert(const char *key, void *data, UNUSED_ARG(void *extra))
         reaction = REACT_VERSION;
     else if (!irccasecmp(react, "mark"))
         reaction = REACT_MARK;
+    else if (!irccasecmp(react, "noticeuser"))
+        reaction = REACT_NOTICEUSER;
+    else if (!irccasecmp(react, "msguser"))
+        reaction = REACT_MSGUSER;
     else {
         log_module(OS_LOG, LOG_ERROR, "Invalid reaction %s for alert %s.", react, key);
         return 0;
@@ -5151,6 +5161,8 @@ opserv_saxdb_write(struct saxdb_context *ctx)
             case REACT_SVSPART: reaction = "svspart"; break;
             case REACT_VERSION: reaction = "version"; break;
             case REACT_MARK: reaction = "mark"; break;
+            case REACT_NOTICEUSER: reaction = "noticeuser"; break;
+            case REACT_MSGUSER: reaction = "msguser"; break;
             default:
                 reaction = NULL;
                 log_module(OS_LOG, LOG_ERROR, "Invalid reaction type %d for alert %s (while writing database).", alert->reaction, iter_key(it));
@@ -6784,12 +6796,18 @@ alert_check_user(const char *key, void *data, void *extra)
        add_track_user(user);
 #endif
        break;
+    case REACT_NOTICEUSER:
+        irc_notice_user(opserv, user, alert->discrim->reason);
+        break;
+    case REACT_MSGUSER:
+        irc_privmsg_user(opserv, user, alert->discrim->reason);
+        break;
     }
     return 0;
 }
 
 static void
-opserv_alert_check_account(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle))
+opserv_alert_check_account(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle), UNUSED_ARG(void *extra))
 {
     dict_foreach(opserv_account_based_alerts, alert_check_user, user);
 }
@@ -6812,7 +6830,7 @@ opserv_alert_check_nick(struct userNode *user, UNUSED_ARG(const char *old_nick),
 }
 
 static void
-opserv_staff_alert(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle))
+opserv_staff_alert(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle), UNUSED_ARG(void *extra))
 {
     const char *type;
 
@@ -6969,6 +6987,10 @@ static MODCMD_FUNC(cmd_addalert)
         reaction = REACT_VERSION;
     else if(!irccasecmp(argv[2], "mark"))
         reaction = REACT_MARK;
+    else if(!irccasecmp(argv[2], "noticeuser"))
+        reaction = REACT_NOTICEUSER;
+    else if(!irccasecmp(argv[2], "msguser"))
+        reaction = REACT_MSGUSER;
     else {
         reply("OSMSG_UNKNOWN_REACTION", argv[2]);
         return 0;
@@ -7215,7 +7237,7 @@ opserv_db_init(void) {
 }
 
 static void
-opserv_db_cleanup(void)
+opserv_db_cleanup(UNUSED_ARG(void* extra))
 {
     unsigned int nn;
 
@@ -7253,6 +7275,8 @@ init_opserv(const char *nick)
     opserv_define_func("ACCESS", cmd_access, 0, 0, 0);
     opserv_define_func("ADDALERT", cmd_addalert, 800, 0, 4);
     opserv_define_func("ADDALERT NOTICE", NULL, 0, 0, 0);
+    opserv_define_func("ADDALERT NOTICEUSER", NULL, 0, 0, 0);
+    opserv_define_func("ADDALERT MSGUSER", NULL, 0, 0, 0);
     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);
@@ -7401,10 +7425,10 @@ init_opserv(const char *nick)
     reg_nick_change_func(opserv_alert_check_nick, NULL);
     reg_del_user_func(opserv_user_cleanup, NULL);
     reg_new_channel_func(opserv_channel_check, NULL); 
-    reg_del_channel_func(opserv_channel_delete);
+    reg_del_channel_func(opserv_channel_delete, NULL);
     reg_join_func(opserv_join_check, NULL);
-    reg_auth_func(opserv_staff_alert);
-    reg_auth_func(opserv_alert_check_account);
+    reg_auth_func(opserv_staff_alert, NULL);
+    reg_auth_func(opserv_alert_check_account, NULL);
     reg_notice_func(opserv, opserv_notice_handler);
 
     opserv_db_init();
@@ -7422,6 +7446,6 @@ init_opserv(const char *nick)
     /* start the karma timer, using the saved one if available */
     routing_karma_timer(dict_find(opserv_routing_plan_options, "KARMA_TIMER", NULL));
 
-    reg_exit_func(opserv_db_cleanup);
+    reg_exit_func(opserv_db_cleanup, NULL);
     message_register_table(msgtab);
 }