Added mute support, fixed chat msg removal, added a bit more support for mentions, fixes etc. #28
1 changed files with 34 additions and 0 deletions
|
@ -1,5 +1,8 @@
|
|||
package buttondevteam.discordplugin.listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import buttondevteam.discordplugin.DiscordPlugin;
|
||||
import buttondevteam.discordplugin.commands.DiscordCommandBase;
|
||||
import sx.blah.discord.api.events.IListener;
|
||||
|
@ -10,6 +13,25 @@ import sx.blah.discord.handle.obj.IMessage;
|
|||
|
||||
public class CommandListener {
|
||||
|
||||
private static final String[] serverReadyStrings = new String[] { "In one week from now", // Ali
|
||||
"Between now and the heat-death of the universe.", // Ghostise
|
||||
"Soon™", "Ask again this time next month", // Ghostise
|
||||
"In about 3 seconds", // Nicolai
|
||||
};
|
||||
|
||||
private static final Random serverReadyRandom = new Random();
|
||||
private static final ArrayList<Short> usableServerReadyStrings = new ArrayList<Short>(serverReadyStrings.length) {
|
||||
private static final long serialVersionUID = 2213771460909848770L;
|
||||
{
|
||||
createUsableServerReadyStrings();
|
||||
}
|
||||
};
|
||||
|
||||
private static void createUsableServerReadyStrings() {
|
||||
for (short i = 0; i < serverReadyStrings.length; i++)
|
||||
usableServerReadyStrings.add(i);
|
||||
}
|
||||
|
||||
public static IListener<?>[] getListeners() {
|
||||
return new IListener[] { new IListener<MentionEvent>() {
|
||||
@Override
|
||||
|
@ -30,6 +52,18 @@ public class CommandListener {
|
|||
public void handle(MessageReceivedEvent event) {
|
||||
if (DiscordPlugin.SafeMode)
|
||||
return;
|
||||
if (event.getMessage().getContent().toLowerCase().contains("when will the server be open?")) {
|
||||
int next;
|
||||
/*
|
||||
* if (serverReadyStrings.length <= lastServerReadyStrings.size()) { next = lastServerReadyStrings.get(0); lastServerReadyStrings.clear(); } else { next = (short) serverReadyRandom
|
||||
* .nextInt(serverReadyStrings.length - lastServerReadyStrings.size()); for (short i = 0; i < lastServerReadyStrings.size(); i++) { short j = lastServerReadyStrings.get(i); if
|
||||
* (next == j) next++; if (next >= serverReadyStrings.length) next = 0; } lastServerReadyStrings.add(next); }
|
||||
*/
|
||||
if (usableServerReadyStrings.size() == 0)
|
||||
createUsableServerReadyStrings();
|
||||
next = usableServerReadyStrings.remove(serverReadyRandom.nextInt(usableServerReadyStrings.size()));
|
||||
DiscordPlugin.sendMessageToChannel(event.getMessage().getChannel(), serverReadyStrings[next]);
|
||||
}
|
||||
if (!event.getMessage().getChannel().isPrivate())
|
||||
return;
|
||||
if (event.getMessage().getAuthor().isBot())
|
||||
|
|
Loading…
Reference in a new issue