]> jfr.im git - irc/rizon/acid.git/commitdiff
Announce winners in debug channel
authorOrillion <redacted>
Thu, 24 Aug 2017 19:56:07 +0000 (21:56 +0200)
committerOrillion <redacted>
Fri, 25 Aug 2017 21:17:10 +0000 (23:17 +0200)
vizon/src/main/java/net/rizon/acid/plugins/vizon/LotteryThread.java
vizon/src/main/java/net/rizon/acid/plugins/vizon/Vizon.java
vizon/src/main/java/net/rizon/acid/plugins/vizon/conf/VizonConfig.java
vizon/vizon.example.yml

index 92da679414963db3b05e4412c49ebf2122b6658f..a8cc0551c059b3aea20df6d72c4f335861a3c162 100644 (file)
@@ -47,7 +47,9 @@ import org.slf4j.LoggerFactory;
  */
 public class LotteryThread extends Thread
 {
+
        private static final Logger logger = LoggerFactory.getLogger(LotteryThread.class);
+       private static final String DEBUG_WINNER_ANNOUCE_FORMAT = "\00307%s\003 won \00311%s\003 in drawing No.\00313%d\003";
 
        private AcidUser vizonUser;
        private Channel channel;
@@ -286,6 +288,12 @@ public class LotteryThread extends Thread
                                                + "No.%d on %s! You are eligible to select a new vhost and "
                                                + "won a 1 letter nickname!", drawing.getId(), user.getNick()),
                                user.getNick());
+
+               privmsgDebugChannel(String.format(
+                               DEBUG_WINNER_ANNOUCE_FORMAT,
+                               user.getNick(),
+                               "jackpot",
+                               drawing.getId()));
        }
 
        private void notifyGrandPrizeWinner(VizonUser user)
@@ -298,6 +306,12 @@ public class LotteryThread extends Thread
                                                + "No.%d on %s! You are eligible to select a new vhost! Your "
                                                + "vhost will now be permanent!", drawing.getId(), user.getNick()),
                                user.getNick());
+
+               privmsgDebugChannel(String.format(
+                               DEBUG_WINNER_ANNOUCE_FORMAT,
+                               user.getNick(),
+                               "grand prize",
+                               drawing.getId()));
        }
 
        private void notifyFirstPrizeWinner(VizonUser user)
@@ -310,6 +324,12 @@ public class LotteryThread extends Thread
                                                + "No.%d on %s! You are eligible to select a new vhost! And your "
                                                + "vhost can be made bold!", drawing.getId(), user.getNick()),
                                user.getNick());
+
+               privmsgDebugChannel(String.format(
+                               DEBUG_WINNER_ANNOUCE_FORMAT,
+                               user.getNick(),
+                               "first prize",
+                               drawing.getId()));
        }
 
        private void notifySecondPrizeWinner(VizonUser user)
@@ -321,6 +341,12 @@ public class LotteryThread extends Thread
                                String.format("Congratulations, you won the second prize in VIzon "
                                                + "No.%d on %s! You are eligible to select a new vhost!", drawing.getId(), user.getNick()),
                                user.getNick());
+
+               privmsgDebugChannel(String.format(
+                               DEBUG_WINNER_ANNOUCE_FORMAT,
+                               user.getNick(),
+                               "second prize",
+                               drawing.getId()));
        }
 
        private void notifyThirdPrizeWinner(VizonUser user)
@@ -332,6 +358,12 @@ public class LotteryThread extends Thread
                                String.format("Congratulations, you won the third prize in VIzon "
                                                + "No.%d on %s! You are eligible to select a new colored vhost!", drawing.getId(), user.getNick()),
                                user.getNick());
+
+               privmsgDebugChannel(String.format(
+                               DEBUG_WINNER_ANNOUCE_FORMAT,
+                               user.getNick(),
+                               "third prize",
+                               drawing.getId()));
        }
 
        private void notifyConsolationPrizeWinner(VizonUser user)
@@ -343,6 +375,12 @@ public class LotteryThread extends Thread
                                String.format("Congratulations, you won the consolation prize in VIzon "
                                                + "No.%d on %s! You are eligible to select a new colored vhost!", drawing.getId(), user.getNick()),
                                user.getNick());
+
+               privmsgDebugChannel(String.format(
+                               DEBUG_WINNER_ANNOUCE_FORMAT,
+                               user.getNick(),
+                               "consolation prize",
+                               drawing.getId()));
        }
 
        private void notifyUser(User user, String message, String nick)
@@ -539,6 +577,14 @@ public class LotteryThread extends Thread
                database.updateUser(user);
        }
 
+       private void privmsgDebugChannel(String message)
+       {
+               Acidictive.privmsg(
+                               vizonUser.getUID(),
+                               Vizon.getVizonDebugChannel().getName(),
+                               message);
+       }
+
        private void privmsgChannel(String message)
        {
                Acidictive.privmsg(
index d9a29005f9d6651443aed26505978484d18c9fda..4789be8d6dcbfa8b4d56f0350e5c4b5459943a74 100644 (file)
@@ -25,9 +25,6 @@
  */
 package net.rizon.acid.plugins.vizon;
 
-import net.rizon.acid.plugins.vizon.db.VizonDatabase;
-import net.rizon.acid.plugins.vizon.db.VizonUser;
-import net.rizon.acid.plugins.vizon.db.VizonDrawing;
 import com.google.common.eventbus.Subscribe;
 import io.netty.util.concurrent.ScheduledFuture;
 import java.time.LocalDateTime;
@@ -45,6 +42,9 @@ import net.rizon.acid.events.EventUserMode;
 import net.rizon.acid.plugins.Plugin;
 import net.rizon.acid.plugins.vizon.commands.PendingRequestCommand;
 import net.rizon.acid.plugins.vizon.conf.VizonConfig;
+import net.rizon.acid.plugins.vizon.db.VizonDatabase;
+import net.rizon.acid.plugins.vizon.db.VizonDrawing;
+import net.rizon.acid.plugins.vizon.db.VizonUser;
 import net.rizon.acid.plugins.vizon.util.VizonTemporal;
 import net.rizon.acid.sql.SQL;
 import org.slf4j.Logger;
@@ -61,7 +61,8 @@ public class Vizon extends Plugin
        private static VizonConfig conf;
        private static AcidUser vizonBot;
        private static Channel vizonChannel;
-       
+       private static Channel vizonDebugChannel;
+
        private static SQL vizonSql;
        private static VizonDatabase vizonDatabase;
        
@@ -92,6 +93,11 @@ public class Vizon extends Plugin
                return vizonChannel;
        }
 
+       public static Channel getVizonDebugChannel()
+       {
+               return vizonDebugChannel;
+       }
+
        public static SQL getVizonSql()
        {
                return vizonSql;
@@ -329,12 +335,18 @@ public class Vizon extends Plugin
                }
 
                Channel channel = Channel.findChannel(conf.vizonChannel);
+               Channel debugChannel = Channel.findChannel(conf.vizonDebugChannel);
 
                if (channel == null)
                {
                        throw new ConfigException("VizonChannel does not exist");
                }
 
+               if (debugChannel == null)
+               {
+                       throw new ConfigException("VizonDebugChannel does not exist");
+               }
+
                vizonBot = (AcidUser) u;
 
                if (!vizonBot.isOnChan(channel))
@@ -343,5 +355,6 @@ public class Vizon extends Plugin
                }
 
                vizonChannel = channel;
+               vizonDebugChannel = debugChannel;
        }
 }
index 765e45c1b7246d3905aade09394f450c071665ad..4576b70e0c6e5f73ab343f0b1ee311f38b5c4208 100644 (file)
@@ -39,8 +39,10 @@ import net.rizon.acid.conf.Validator;
  */
 public class VizonConfig extends Configuration
 {
+
        public List<Client> clients;
        public String vizonChannel;
+       public String vizonDebugChannel;
        public String vizonBot;
        public List<Integer> days;
        public String drawingOpen;
index 8e78c1a2221cdabde8065fbcf3790a85362438bb..405646efadc7051f1d0822703483b266a0d1ec3d 100644 (file)
@@ -66,6 +66,7 @@ clients:
     clazz: net.rizon.acid.plugins.vizon.commands.DeleteCommand
 
 vizonChannel: "#opers"
+vizonDebug: "#opers"
 vizonBot: "VizonBot"
 
 days: [3, 5, 7]