Check account-based alerts for all users, not just staff.
[srvx.git] / src / opserv.c
index 10c6c4512025e591eee4c504f6e14fb37f157b1b..43cbb73adbeb604e410df0de26137698ffeb0b15 100644 (file)
@@ -380,9 +380,15 @@ opserv_free_user_alert(void *data)
     free(alert);
 }
 
-#define opserv_debug(format...) do { if (opserv_conf.debug_channel) send_channel_notice(opserv_conf.debug_channel , opserv , ## format); } while (0)
-#define opserv_alert(format...) do { if (opserv_conf.alert_channel) send_channel_notice(opserv_conf.alert_channel , opserv , ## format); } while (0)
-#define opserv_custom_alert(chan, format...) do { if (chan) send_target_message(4 , chan , opserv , ## format); else if (opserv_conf.alert_channel) send_channel_notice(opserv_conf.alert_channel , opserv , ## format); } while (0)
+#if defined(GCC_VARMACROS)
+# define opserv_debug(ARGS...) do { if (opserv_conf.debug_channel) send_channel_notice(opserv_conf.debug_channel, opserv, ARGS); } while (0)
+# define opserv_alert(ARGS...) do { if (opserv_conf.alert_channel) send_channel_notice(opserv_conf.alert_channel, opserv, ARGS); } while (0)
+# define opserv_custom_alert(CHAN, ARGS...) do { if (CHAN) send_target_message(4, (CHAN), opserv, ARGS); else if (opserv_conf.alert_channel) send_channel_notice(opserv_conf.alert_channel, opserv, ARGS); } while (0)
+#elif defined(C99_VARMACROS)
+# define opserv_debug(...) do { if (opserv_conf.debug_channel) send_channel_notice(opserv_conf.debug_channel, opserv, __VA_ARGS__); } while (0)
+# define opserv_alert(...) do { if (opserv_conf.alert_channel) send_channel_notice(opserv_conf.alert_channel, opserv, __VA_ARGS__); } while (0)
+# define opserv_custom_alert(chan, ...) do { if (chan) send_target_message(4, chan, opserv, __VA_ARGS__); else if (opserv_conf.alert_channel) send_channel_notice(opserv_conf.alert_channel, opserv, __VA_ARGS__); } while (0)
+#endif
 
 /* A lot of these commands are very similar to what ChanServ can do,
  * but OpServ can do them even on channels that aren't registered.
@@ -1809,7 +1815,7 @@ opserv_part_channel(void *data)
 
 static int alert_check_user(const char *key, void *data, void *extra);
 
-static int
+static void
 opserv_new_user_check(struct userNode *user)
 {
     struct opserv_hostinfo *ohi;
@@ -1818,11 +1824,11 @@ opserv_new_user_check(struct userNode *user)
 
     /* Check to see if we should ignore them entirely. */
     if (IsLocal(user) || IsService(user))
-        return 0;
+        return;
 
     /* Check for alerts, and stop if we find one that kills them. */
     if (dict_foreach(opserv_user_alerts, alert_check_user, user))
-        return 1;
+        return;
 
     /* Gag them if appropriate. */
     for (gag = gagList; gag; gag = gag->next) {
@@ -1871,8 +1877,6 @@ opserv_new_user_check(struct userNode *user)
             gline_add(opserv->nick, target, opserv_conf.clone_gline_duration, "AUTO Excessive connections from a single host.", now, now, 1);
         }
     }
-
-    return 0;
 }
 
 static void
@@ -1976,7 +1980,7 @@ opserv_join_check(struct modeNode *mNode)
 
     dict_foreach(opserv_channel_alerts, alert_check_user, user);
 
-    if (channel->bad_channel) {
+    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);
         if (channel->name[0] != '#')
             DelUser(user, opserv, 1, "OSMSG_ILLEGAL_KILL_REASON");
@@ -2045,7 +2049,6 @@ opserv_add_bad_word(struct svccmd *cmd, struct userNode *user, const char *new_b
                     reply("OSMSG_BAD_NUKING", orig_bad);
                 string_list_delete(opserv_bad_words, bad_idx);
                 bad_idx--;
-                free(orig_bad);
             }
             return 1;
         }
@@ -3965,8 +3968,13 @@ opserv_staff_alert(struct userNode *user, UNUSED_ARG(struct handle_info *old_han
         send_channel_notice(opserv_conf.staff_auth_channel, opserv, IDENT_FORMAT" authed to %s account %s", IDENT_DATA(user), type, user->handle_info->handle);
     else
         send_channel_notice(opserv_conf.staff_auth_channel, opserv, "%s [%s@%s] authed to %s account %s", user->nick, user->ident, user->hostname, type, user->handle_info->handle);
+}
 
-    dict_foreach(opserv_account_alerts, alert_check_user, user);
+static void
+opserv_auth_alert(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle))
+{
+    if (!user->uplink->burst && user->handle_info)
+        dict_foreach(opserv_account_alerts, alert_check_user, user);
 }
 
 static MODCMD_FUNC(cmd_log)
@@ -4367,6 +4375,7 @@ init_opserv(const char *nick)
     reg_del_channel_func(opserv_channel_delete);
     reg_join_func(opserv_join_check);
     reg_auth_func(opserv_staff_alert);
+    reg_auth_func(opserv_auth_alert);
 
     opserv_db_init();
     saxdb_register("OpServ", opserv_saxdb_read, opserv_saxdb_write);