]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/global.c
Major update to bring X3 in line with the latest SRVX commit. Please see UPGRADE...
[irc/evilnet/x3.git] / src / global.c
index ee30cd32ef0886210a4a94a2405998177571f81e..06d1237dad7e63252863ce3d56e2e1bb37732130 100644 (file)
@@ -141,7 +141,11 @@ static struct
     unsigned int announcements_default : 1;
 } global_conf;
 
-#define global_notice(target, format...) send_message(target , global , ## format)
+#if defined(GCC_VARMACROS)
+# define global_notice(target, ARGS...) send_message(target, global, ARGS)
+#elif defined(C99_VARMACROS)
+# define global_notice(target, ...) send_message(target, global, __VA_ARGS__)
+#endif
 
 void message_expire(void *data);
 
@@ -245,6 +249,8 @@ message_create(struct userNode *user, unsigned int argc, char *argv[])
 
            if(!irccasecmp(argv[i], "all")) {
                flags |= MESSAGE_RECIPIENT_ALL;
+            } else if(!irccasecmp(argv[i], "authed")) {
+                flags |= MESSAGE_RECIPIENT_AUTHED;
            } else if(!irccasecmp(argv[i], "users")) {
                flags |= MESSAGE_RECIPIENT_LUSERS;
            } else if(!irccasecmp(argv[i], "helpers")) {
@@ -255,6 +261,8 @@ message_create(struct userNode *user, unsigned int argc, char *argv[])
                flags |= MESSAGE_RECIPIENT_STAFF;
            } else if(!irccasecmp(argv[i], "channels")) {
                flags |= MESSAGE_RECIPIENT_CHANNELS;
+           } else if(!irccasecmp(argv[i], "rchannels")) {
+               flags |= MESSAGE_RECIPIENT_RCHANNELS;
             } else if(!irccasecmp(argv[i], "announcement") || !irccasecmp(argv[i], "announce")) {
                 flags |= MESSAGE_RECIPIENT_ANNOUNCE;
            } else {
@@ -311,6 +319,14 @@ messageType(const struct globalMessage *message)
     {
        return "users";
     }
+    else if(message->flags & MESSAGE_RECIPIENT_AUTHED)
+    {
+        return "authed";
+    }
+    else if(message->flags & MESSAGE_RECIPIENT_RCHANNELS)
+    {
+        return "rchannels";
+    }
     else
     {
        return "channels";
@@ -354,7 +370,25 @@ message_send(struct globalMessage *message)
 
     if(message->flags & MESSAGE_RECIPIENT_CHANNELS)
     {
-       dict_foreach(channels, notice_channel, message);
+        dict_iterator_t it;
+
+        for (it = dict_first(channels); it; it = iter_next(it)) {
+            struct chanNode *chan = iter_data(it);
+
+            notice_target(chan->name, message);
+        }
+    }
+
+    if(message->flags & MESSAGE_RECIPIENT_RCHANNELS)
+    {
+        dict_iterator_t it;
+
+        for (it = dict_first(channels); it; it = iter_next(it)) {
+            struct chanNode *chan = iter_data(it);
+
+            if (chan->channel_info)
+                notice_target(chan->name, message);
+        }
     }
 
     if(message->flags & MESSAGE_RECIPIENT_LUSERS)
@@ -400,6 +434,16 @@ message_send(struct globalMessage *message)
            notice_target(user->nick, message);
        }
     }
+
+    if(message->flags & MESSAGE_RECIPIENT_AUTHED)
+    {
+        dict_iterator_t it;
+        for (it = dict_first(clients); it; it = iter_next(it)) {
+            struct userNode *luser = iter_data(it);
+            if (luser->handle_info)
+              notice_target(luser->nick, message);
+        }
+    }
 }
 
 void
@@ -438,7 +482,8 @@ global_message_args(long targets, const char *language_entry, ...)
             if(luser->uplink != self)
                 notice_target(luser->nick, message);
 
-            if ((message->flags & MESSAGE_RECIPIENT_LUSERS) || (message->flags & MESSAGE_RECIPIENT_HELPERS))
+            if ((message->flags & MESSAGE_RECIPIENT_LUSERS) || (message->flags & MESSAGE_RECIPIENT_HELPERS) || 
+                (message->flags & MESSAGE_RECIPIENT_AUTHED))
                 continue;
         }
 
@@ -446,13 +491,23 @@ global_message_args(long targets, const char *language_entry, ...)
         if (message->flags & MESSAGE_RECIPIENT_HELPERS && IsHelper(luser)) {
            notice_target(luser->nick, message);
 
-            if (message->flags & MESSAGE_RECIPIENT_LUSERS)
+            if ((message->flags & MESSAGE_RECIPIENT_LUSERS) || (message->flags & MESSAGE_RECIPIENT_AUTHED))
                 continue;
        }
 
+        /* authed */
+        if ((message->flags & MESSAGE_RECIPIENT_AUTHED) && luser->handle_info) {
+            notice_target(luser->nick, message);
+
+            if (message->flags & MESSAGE_RECIPIENT_LUSERS)
+                continue;
+        }
+
         /* users */
-        if (message->flags & MESSAGE_RECIPIENT_LUSERS)
+        if (message->flags & MESSAGE_RECIPIENT_LUSERS) {
            notice_target(luser->nick, message);
+
+        }
     }
 
     message_del(message);
@@ -487,6 +542,8 @@ static GLOBAL_FUNC(cmd_notice)
        target = MESSAGE_RECIPIENT_ALL;
     } else if(!irccasecmp(argv[1], "users")) {
        target = MESSAGE_RECIPIENT_LUSERS;
+    } else if(!irccasecmp(argv[1], "authed")) {
+        target = MESSAGE_RECIPIENT_AUTHED;
     } else if(!irccasecmp(argv[1], "helpers")) {
        target = MESSAGE_RECIPIENT_HELPERS;
     } else if(!irccasecmp(argv[1], "opers")) {
@@ -497,6 +554,8 @@ static GLOBAL_FUNC(cmd_notice)
         target |= MESSAGE_RECIPIENT_ANNOUNCE;
     } else if(!irccasecmp(argv[1], "channels")) {
        target = MESSAGE_RECIPIENT_CHANNELS;
+    } else if(!irccasecmp(argv[1], "rchannels")) {
+       target = MESSAGE_RECIPIENT_RCHANNELS;
     } else {
        global_notice(user, "GMSG_INVALID_TARGET", argv[1]);
        return 0;
@@ -650,7 +709,7 @@ send_messages(struct userNode *user, long mask, int obstreperize)
 
 static GLOBAL_FUNC(cmd_messages)
 {
-    long mask = MESSAGE_RECIPIENT_LUSERS | MESSAGE_RECIPIENT_CHANNELS;
+    long mask = MESSAGE_RECIPIENT_AUTHED | MESSAGE_RECIPIENT_LUSERS | MESSAGE_RECIPIENT_CHANNELS | MESSAGE_RECIPIENT_RCHANNELS;
     unsigned int count;
 
     if(IsOper(user))
@@ -810,7 +869,7 @@ init_global(const char *nick)
     if(nick)
     {
         const char *modes = conf_get_data("services/global/modes", RECDB_QSTRING);
-        global = AddService(nick, modes ? modes : NULL, "Global Services", NULL);
+        global = AddLocalUser(nick, nick, NULL, "Global Services", modes);
         global_service = service_register(global);
     }