diff --git a/DiscordDivaBot/saki.jar b/DiscordDivaBot/saki.jar index 344853e..386db32 100644 Binary files a/DiscordDivaBot/saki.jar and b/DiscordDivaBot/saki.jar differ diff --git a/DiscordDivaBot/src/sig/Check.java b/DiscordDivaBot/src/sig/Check.java new file mode 100644 index 0000000..b7186c9 --- /dev/null +++ b/DiscordDivaBot/src/sig/Check.java @@ -0,0 +1,25 @@ +package sig; + +import java.util.TimerTask; + +import net.dv8tion.jda.api.JDA; + +public class Check extends TimerTask{ + public boolean dead=false; + public long lastChannelMessage=System.currentTimeMillis(); + public JDA bot; + + public Check(JDA bot) { + this.bot=bot; + } + + @Override + public void run() { + if (!dead&&System.currentTimeMillis()-lastChannelMessage>=10000) { + dead=true; + bot.getTextChannelById(744692511703826462l).sendMessage("<:sakiDead1:799650259487293440><:sakiDead2:799650259746947083>") + .queue(); + } + } + +} \ No newline at end of file diff --git a/DiscordDivaBot/src/sig/DivaBot.java b/DiscordDivaBot/src/sig/DivaBot.java index f849a79..96a6fab 100644 --- a/DiscordDivaBot/src/sig/DivaBot.java +++ b/DiscordDivaBot/src/sig/DivaBot.java @@ -1,9 +1,13 @@ package sig; import java.util.ArrayList; + + import java.util.HashMap; import java.util.List; import java.util.Random; +import java.util.Timer; +import java.util.TimerTask; import javax.security.auth.login.LoginException; @@ -29,6 +33,8 @@ public class DivaBot extends ListenerAdapter{ public String[] keywordsList= new String[]{ "Apple","Apricot","Avocado","Banana","Bilberry","Blackberry","Blueberry","Currant","Cherry","Cherimoya","Clementine","Date","Damson","Fruit","Durian","Eggplant","Elderberry","Feijoa","Gooseberry","Grape","Grapefruit","Guava","Huckleberry","Jackfruit","Jambul","Kiwi","Kumquat","Legume","Lemon","Lime","Lychee","Mango","Mangostine","Melon","Cantaloupe","Cantalope","Honeydew","Watermelon","Rock","Nectarine","Orange","Peach","Pear","Williams","Bartlett","Pitaya","Physalis","Plum","prune","Pineapple","Pomegranate","Pomegranite","Raisin","Raspberry","blackcap","Rambutan","Redcurrant","Salal","Satsuma","Star","Strawberry","Tangerine","Tomato","Ugli","Watermelon","Ziziphus","mauritiana","Red","Orange","Yellow","Green","Blue","Purple","Pink","Brown","Gray","Grey","Black","White","Color","Dragon","Wyvern","Quetzalcoatl","Hydra","Cockatrice","Wyrm","Drake" }; + static Timer t; + static Check sakiCheck; public static void main(String[] args) throws LoginException, InterruptedException { String[] fileContents = FileUtils.readFromFile("clientToken.txt"); @@ -38,6 +44,9 @@ public class DivaBot extends ListenerAdapter{ bot.addEventListener(new DivaBot()); bot.awaitReady(); DivaBot.bot=bot; + t = new Timer(true); + sakiCheck = new Check(bot); + t.scheduleAtFixedRate(sakiCheck, 10000, 10000); } //https://ci.dv8tion.net/job/JDA/javadoc/net/dv8tion/jda/api/hooks/ListenerAdapter.html @@ -50,7 +59,7 @@ public class DivaBot extends ListenerAdapter{ //System.out.println(ev.getAuthor().getIdLong()); - if (ApprovedChannel(ev.getChannel(),ev.getAuthor())/*&&ev.getMessage().getContentDisplay().toLowerCase().contains("muni")*/) { + /*if (ApprovedChannel(ev.getChannel(),ev.getAuthor())) { if (lastMessageCount>0&&ev.getMessage().getContentDisplay().toLowerCase().equalsIgnoreCase(lastMessage)) { lastMessageCount++; } else { @@ -61,18 +70,28 @@ public class DivaBot extends ListenerAdapter{ ev.getChannel().sendMessage(ev.getMessage()) .queue(); } + }*/ + + if (ev.getChannel().getIdLong()==772923108997857291l) { + if (sakiCheck.dead) { + //React to next message. + sakiCheck.dead=false; + React(ev); + } else { + sakiCheck.lastChannelMessage=System.currentTimeMillis(); + } } if (ValidMessage(ev.getAuthor(),ev.getChannel(),ev.getMessage().getContentDisplay())) { - /*ev.getChannel().sendMessage(ev.getAuthor().getName()+" typed '"+ev.getMessage().getContentDisplay()+"'!") - .queue();*/ - //System.out.println(bot.getEmotes()); - ev.getChannel().addReactionById(ev.getMessageIdLong(), ChooseRandomMuniEmote(ev.getMessage().getContentDisplay().hashCode()+ - ev.getAuthor().getIdLong())) - .queue(); - //messageHistory.put(ev.getMessageIdLong(),ev.getMessage()); + React(ev); } } + + private void React(MessageReceivedEvent ev) { + ev.getChannel().addReactionById(ev.getMessageIdLong(), ChooseRandomMuniEmote(ev.getMessage().getContentDisplay().hashCode()+ + ev.getAuthor().getIdLong())) + .queue(); + } private Emote ChooseRandomMuniEmote(long seed) { List emotes = bot.getEmotes();