]> jfr.im git - irc/rizon/acid.git/commitdiff
BMASK server command handler for handling ban-like modes during burst
authorchristinaa <redacted>
Tue, 29 Aug 2017 08:36:15 +0000 (01:36 -0700)
committerchristinaa <redacted>
Tue, 29 Aug 2017 08:36:15 +0000 (01:36 -0700)
acid/src/main/java/net/rizon/acid/core/Message.java
acid/src/main/java/net/rizon/acid/messages/BMask.java [new file with mode: 0644]

index 994ef076d9d1dd08681b298ced949d2987dc0599..f6fb4da5cb9c49a4ac42beb61ba65a0f739bb835 100644 (file)
@@ -16,6 +16,7 @@ public abstract class Message
                "Encap", "EOB", "Error", "Join", "Kick", "Kill", "Mode", "Nick",
                "Notice", "Part", "Pass", "Ping", "Privmsg", "Quit", "Server", "SID",
                "SJoin", "SQuit", "Stats", "TMode", "UID", "Whois", "Operwall", "Invite",
+               "BMask"
        };
 
        static
diff --git a/acid/src/main/java/net/rizon/acid/messages/BMask.java b/acid/src/main/java/net/rizon/acid/messages/BMask.java
new file mode 100644 (file)
index 0000000..7cfd570
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2017 Kristina Brooks. All rights reserved.
+ *
+ * Support for TS6 BMASK
+ * Message format: chanTS, chan, type, space separated masks
+ * Plexus only supports +b, +e and +I.
+ */
+
+package net.rizon.acid.messages;
+
+import net.rizon.acid.core.Acidictive;
+import net.rizon.acid.core.Channel;
+import net.rizon.acid.core.Message;
+import net.rizon.acid.core.Server;
+import net.rizon.acid.core.User;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BMask extends Message
+{
+       private static final Logger log = LoggerFactory.getLogger(BMask.class);
+
+       public BMask()
+       {
+               super("BMASK");
+       }
+
+       /*
+        * TS6 spec says that if the TS in the BMASK is greater, the message
+        * should be dropped. do that check here.
+        */
+       private boolean shouldDropMessage(Channel chan, String newTS) {
+               try
+               {
+                       return (Integer.parseInt(newTS) > chan.getTS());
+               }
+               catch (NumberFormatException ex)
+               {
+                       ex.printStackTrace();
+                       return true;
+               }
+       }
+
+       @Override
+       public void onServer(Server server, String[] params)
+       {
+               Channel chan = Channel.findChannel(params[1]);
+               if (chan == null || shouldDropMessage(chan, params[0]))
+                       return;
+
+               char mode = params[2].charAt(0);
+
+               String[] splitMasks = params[3].split(" ");
+               for (String mask : splitMasks)
+               {
+                       chan.changeMaskMode(mode, true, mask);
+               }
+       }
+}
\ No newline at end of file