]> PatchyGit - patchyircd.git/commitdiff
improve mod message support
authorEgor <egor@patchysicp.xyz>
Sun, 22 Oct 2023 13:43:11 +0000 (16:43 +0300)
committerEgor <egor@patchysicp.xyz>
Sun, 22 Oct 2023 13:53:58 +0000 (16:53 +0300)
src/irc.c

index b623b81..dc03c14 100644 (file)
--- a/src/irc.c
+++ b/src/irc.c
@@ -549,8 +549,11 @@ int processPacket(struct client_data *client, char *source, char *command, int a
                        return err_needmoreparams(client, command), sendbuf(client), 0;
                client->lastactivity = get_time();
                (command[0] == 'P' ? msg_privmsg : msg_notice)(client, args[0], args[1]);
+               /* TODO: multiple targets */
                // TODO: extra target forms such as nick@server #hostmask $servermask
                int is_modmsg = !!strchr("@+", args[0][0]);
+               if (is_modmsg)
+                       is_modmsg += !!strchr("@+", args[0][1]);
                if (strchr("#&", args[0][is_modmsg])) {
                        struct channel *chan = findChannel(args[0]+is_modmsg);
                        if (!chan)
@@ -574,19 +577,14 @@ int processPacket(struct client_data *client, char *source, char *command, int a
                                return 1;
                        }
 
-                       switch (args[0][0]) {
-                       default:
+                       if (!is_modmsg) {
                                sendbuf_list_sans_self(client, &chan->members, 0);
-                               break;
-                       case '+': {
+                       } else if (memchr(args[0], '+', is_modmsg)) {
                                int cookie = get_cookie();
                                sendbuf_list_sans_self(client, &chan->v, cookie);
                                sendbuf_list_sans_self(client, &chan->o, cookie);
-                               break;
-                       }
-                       case '@':
+                       } else {
                                sendbuf_list_sans_self(client, &chan->o, 0);
-                               break;
                        }
                } else {
                        if (!(client->umode & UMODE_REGISTERED)) {