Cleaned up captcha
This commit is contained in:
parent
eb3a5d2990
commit
b63ec31138
2
pom.xml
2
pom.xml
|
@ -172,7 +172,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.dv8tion</groupId>
|
<groupId>net.dv8tion</groupId>
|
||||||
<artifactId>JDA</artifactId>
|
<artifactId>JDA</artifactId>
|
||||||
<version>4.2.0_177</version>
|
<version>4.2.0_184</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.cage</groupId>
|
<groupId>com.github.cage</groupId>
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.util.Scanner;
|
||||||
import org.fusesource.jansi.AnsiConsole;
|
import org.fusesource.jansi.AnsiConsole;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.captcha.BCage;
|
||||||
import com.fpghoti.biscuit.commands.CommandManager;
|
import com.fpghoti.biscuit.commands.CommandManager;
|
||||||
import com.fpghoti.biscuit.commands.client.AddCommand;
|
import com.fpghoti.biscuit.commands.client.AddCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.ChanIDCommand;
|
import com.fpghoti.biscuit.commands.client.ChanIDCommand;
|
||||||
|
@ -55,6 +56,7 @@ import com.fpghoti.biscuit.listener.ReactionListener;
|
||||||
import com.fpghoti.biscuit.listener.RoleListener;
|
import com.fpghoti.biscuit.listener.RoleListener;
|
||||||
import com.fpghoti.biscuit.logging.BColor;
|
import com.fpghoti.biscuit.logging.BColor;
|
||||||
import com.fpghoti.biscuit.logging.BiscuitLog;
|
import com.fpghoti.biscuit.logging.BiscuitLog;
|
||||||
|
import com.github.cage.Cage;
|
||||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
||||||
import com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager;
|
import com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager;
|
||||||
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers;
|
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers;
|
||||||
|
@ -85,6 +87,7 @@ public class Main {
|
||||||
public static boolean ready = false;
|
public static boolean ready = false;
|
||||||
public static boolean isPlugin = false;
|
public static boolean isPlugin = false;
|
||||||
public static boolean shutdownStarted = false;
|
public static boolean shutdownStarted = false;
|
||||||
|
private static Cage cage;
|
||||||
|
|
||||||
private static AudioPlayerManager playerManager;
|
private static AudioPlayerManager playerManager;
|
||||||
|
|
||||||
|
@ -106,6 +109,8 @@ public class Main {
|
||||||
|
|
||||||
mainBiscuit = new Biscuit(null, null, log);
|
mainBiscuit = new Biscuit(null, null, log);
|
||||||
startJDA();
|
startJDA();
|
||||||
|
|
||||||
|
cage = new BCage();
|
||||||
|
|
||||||
jda.addEventListener(new GuildListener());
|
jda.addEventListener(new GuildListener());
|
||||||
jda.addEventListener(new MessageReceiveListener());
|
jda.addEventListener(new MessageReceiveListener());
|
||||||
|
@ -244,6 +249,10 @@ public class Main {
|
||||||
public static JDA getJDA() {
|
public static JDA getJDA() {
|
||||||
return jda;
|
return jda;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Cage getCage() {
|
||||||
|
return cage;
|
||||||
|
}
|
||||||
|
|
||||||
public static BiscuitLog getLogger() {
|
public static BiscuitLog getLogger() {
|
||||||
return log;
|
return log;
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.fpghoti.biscuit.audio;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler;
|
import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler;
|
||||||
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
|
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
|
||||||
import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
|
import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
|
||||||
|
@ -60,16 +61,16 @@ public class AudioResultHandler implements AudioLoadResultHandler {
|
||||||
biscuit.log("Exact match not found. Searching instead...");
|
biscuit.log("Exact match not found. Searching instead...");
|
||||||
Main.getPlayerManager().loadItemOrdered(biscuit.getGuild(),"ytsearch:" + searchPhrase, new AudioResultHandler(uid, channel, true, searchPhrase, first, false));
|
Main.getPlayerManager().loadItemOrdered(biscuit.getGuild(),"ytsearch:" + searchPhrase, new AudioResultHandler(uid, channel, true, searchPhrase, first, false));
|
||||||
}else {
|
}else {
|
||||||
channel.sendMessage("Song match not found.").queue();
|
MessageText.send(channel, "Song match not found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadFailed(FriendlyException exception) {
|
public void loadFailed(FriendlyException exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
channel.sendMessage("An error was encountered while attempting to load audio.").queue();
|
MessageText.send(channel, "An error was encountered while attempting to load audio.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.audio.queue.AudioQueue;
|
import com.fpghoti.biscuit.audio.queue.AudioQueue;
|
||||||
import com.fpghoti.biscuit.audio.queue.QueuedTrack;
|
import com.fpghoti.biscuit.audio.queue.QueuedTrack;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
||||||
import com.sedmelluq.discord.lavaplayer.player.event.AudioEventAdapter;
|
import com.sedmelluq.discord.lavaplayer.player.event.AudioEventAdapter;
|
||||||
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
|
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
|
||||||
|
@ -56,7 +57,7 @@ public class AudioScheduler extends AudioEventAdapter {
|
||||||
if(!qt.triedAlternative()) {
|
if(!qt.triedAlternative()) {
|
||||||
qt.useAttempt();
|
qt.useAttempt();
|
||||||
TextChannel channel = qt.getCommandChannel();
|
TextChannel channel = qt.getCommandChannel();
|
||||||
channel.sendMessage("The video selected cannot be played through the music player. An alternate track will be played if available.").queue();
|
MessageText.send(channel, "The video selected cannot be played through the music player. An alternate track will be played if available.");
|
||||||
title = title.toLowerCase().replace("vevo", "") + " lyrics";
|
title = title.toLowerCase().replace("vevo", "") + " lyrics";
|
||||||
Main.getPlayerManager().loadItemOrdered(biscuit.getGuild(),"ytsearch:" + title, new AudioResultHandler(qt.getUserId(), channel, true, title, true, !queue.isEmpty()));
|
Main.getPlayerManager().loadItemOrdered(biscuit.getGuild(),"ytsearch:" + title, new AudioResultHandler(qt.getUserId(), channel, true, title, true, !queue.isEmpty()));
|
||||||
return;
|
return;
|
||||||
|
@ -65,7 +66,7 @@ public class AudioScheduler extends AudioEventAdapter {
|
||||||
case CLEANUP:
|
case CLEANUP:
|
||||||
log("A track stopped playing due to audio player cleanup.");
|
log("A track stopped playing due to audio player cleanup.");
|
||||||
if(qt != null && qt.getCommandChannel() != null)
|
if(qt != null && qt.getCommandChannel() != null)
|
||||||
qt.getCommandChannel().sendMessage("Track **" + track.getInfo().title + "** stopped playing due to audio player cleanup.").queue();
|
MessageText.send(qt.getCommandChannel(), "Track **" + track.getInfo().title + "** stopped playing due to audio player cleanup.");
|
||||||
break;
|
break;
|
||||||
case FINISHED:
|
case FINISHED:
|
||||||
log("Finished playing track " + title + ".");
|
log("Finished playing track " + title + ".");
|
||||||
|
@ -103,7 +104,7 @@ public class AudioScheduler extends AudioEventAdapter {
|
||||||
public void onTrackStuck(AudioPlayer player, AudioTrack track, long thresholdMs) {
|
public void onTrackStuck(AudioPlayer player, AudioTrack track, long thresholdMs) {
|
||||||
QueuedTrack qt = queue.getPreviousTrack(track);
|
QueuedTrack qt = queue.getPreviousTrack(track);
|
||||||
if(qt != null && qt.getCommandChannel() != null) {
|
if(qt != null && qt.getCommandChannel() != null) {
|
||||||
qt.getCommandChannel().sendMessage("The current track has become stuck and will be skipped.").queue();
|
MessageText.send(qt.getCommandChannel(), "The current track has become stuck and will be skipped.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.fpghoti.biscuit.audio.queue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||||
|
@ -103,7 +104,7 @@ public class AudioQueue {
|
||||||
if(track.getCommandChannel() != null) {
|
if(track.getCommandChannel() != null) {
|
||||||
TextChannel c = track.getCommandChannel();
|
TextChannel c = track.getCommandChannel();
|
||||||
MessageEmbed m = track.getEmbedMessage("Queued:");
|
MessageEmbed m = track.getEmbedMessage("Queued:");
|
||||||
c.sendMessage(m).queue();
|
MessageText.send(c, m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,17 +10,17 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.PluginCore;
|
import com.fpghoti.biscuit.PluginCore;
|
||||||
import com.fpghoti.biscuit.audio.AudioScheduler;
|
import com.fpghoti.biscuit.audio.AudioScheduler;
|
||||||
import com.fpghoti.biscuit.captcha.BCage;
|
|
||||||
import com.fpghoti.biscuit.config.BiscuitConfig;
|
import com.fpghoti.biscuit.config.BiscuitConfig;
|
||||||
import com.fpghoti.biscuit.config.BiscuitProperties;
|
import com.fpghoti.biscuit.config.BiscuitProperties;
|
||||||
import com.fpghoti.biscuit.logging.BColor;
|
import com.fpghoti.biscuit.logging.BColor;
|
||||||
import com.fpghoti.biscuit.logging.BiscuitLog;
|
import com.fpghoti.biscuit.logging.BiscuitLog;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.timer.BiscuitTimer;
|
import com.fpghoti.biscuit.timer.BiscuitTimer;
|
||||||
import com.fpghoti.biscuit.timer.task.ChatCountTimer;
|
import com.fpghoti.biscuit.timer.task.ChatCountTimer;
|
||||||
import com.fpghoti.biscuit.timer.task.DecrementTimer;
|
import com.fpghoti.biscuit.timer.task.DecrementTimer;
|
||||||
import com.fpghoti.biscuit.timer.task.SoftMuteTimer;
|
import com.fpghoti.biscuit.timer.task.SoftMuteTimer;
|
||||||
|
import com.fpghoti.biscuit.user.CaptchaUser;
|
||||||
import com.fpghoti.biscuit.user.PreUser;
|
import com.fpghoti.biscuit.user.PreUser;
|
||||||
import com.github.cage.Cage;
|
|
||||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
|
@ -81,7 +81,7 @@ public class Biscuit {
|
||||||
private Timer timer;
|
private Timer timer;
|
||||||
private List<BiscuitTimer> timers;
|
private List<BiscuitTimer> timers;
|
||||||
private File captchaDir;
|
private File captchaDir;
|
||||||
private Cage cage;
|
//private Cage cage;
|
||||||
private Guild guild;
|
private Guild guild;
|
||||||
private HashMap<String, Integer> inviteUses;
|
private HashMap<String, Integer> inviteUses;
|
||||||
private BiscuitConfig config;
|
private BiscuitConfig config;
|
||||||
|
@ -104,10 +104,10 @@ public class Biscuit {
|
||||||
this.properties = new BiscuitProperties(this);
|
this.properties = new BiscuitProperties(this);
|
||||||
this.rolequeue = new HashMap<Member, Role>();
|
this.rolequeue = new HashMap<Member, Role>();
|
||||||
this.player = Main.getPlayerManager().createPlayer();
|
this.player = Main.getPlayerManager().createPlayer();
|
||||||
|
|
||||||
scheduler = new AudioScheduler(this);
|
scheduler = new AudioScheduler(this);
|
||||||
player.addListener(scheduler);
|
player.addListener(scheduler);
|
||||||
|
|
||||||
timer = new Timer();
|
timer = new Timer();
|
||||||
timers = new ArrayList<BiscuitTimer>();
|
timers = new ArrayList<BiscuitTimer>();
|
||||||
if(!Main.isPlugin) {
|
if(!Main.isPlugin) {
|
||||||
|
@ -117,7 +117,6 @@ public class Biscuit {
|
||||||
captchaDir = new File(PluginCore.plugin.getDataFolder(), "captcha");
|
captchaDir = new File(PluginCore.plugin.getDataFolder(), "captcha");
|
||||||
captchaDir.mkdir();
|
captchaDir.mkdir();
|
||||||
}
|
}
|
||||||
cage = new BCage();
|
|
||||||
if(isMain) {
|
if(isMain) {
|
||||||
wipeCaptchaDir();
|
wipeCaptchaDir();
|
||||||
}
|
}
|
||||||
|
@ -155,11 +154,11 @@ public class Biscuit {
|
||||||
public AudioPlayer getAudioPlayer() {
|
public AudioPlayer getAudioPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AudioScheduler getAudioScheduler() {
|
public AudioScheduler getAudioScheduler() {
|
||||||
return scheduler;
|
return scheduler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log(String message) {
|
public void log(String message) {
|
||||||
if(properties == null) {
|
if(properties == null) {
|
||||||
logger.info(message);
|
logger.info(message);
|
||||||
|
@ -189,7 +188,7 @@ public class Biscuit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void say(TextChannel channel, String message) {
|
public void say(TextChannel channel, String message) {
|
||||||
channel.sendMessage(message).queue();
|
MessageText.send(channel, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadTimers() {
|
public void loadTimers() {
|
||||||
|
@ -225,10 +224,6 @@ public class Biscuit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cage getCage() {
|
|
||||||
return this.cage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<TextChannel> getCaptchaLogChannels() {
|
public ArrayList<TextChannel> getCaptchaLogChannels() {
|
||||||
ArrayList<TextChannel> ch = new ArrayList<TextChannel>();
|
ArrayList<TextChannel> ch = new ArrayList<TextChannel>();
|
||||||
for(TextChannel t : guild.getTextChannels()) {
|
for(TextChannel t : guild.getTextChannels()) {
|
||||||
|
@ -242,11 +237,29 @@ public class Biscuit {
|
||||||
public void captchaLog(String msg) {
|
public void captchaLog(String msg) {
|
||||||
if(properties.logCaptcha()) {
|
if(properties.logCaptcha()) {
|
||||||
for(TextChannel t : getCaptchaLogChannels()) {
|
for(TextChannel t : getCaptchaLogChannels()) {
|
||||||
t.sendMessage(msg).queue();
|
MessageText.send(t, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Role getDefaultRole() {
|
||||||
|
for(Role r : guild.getRoles()) {
|
||||||
|
if(r.getName().toLowerCase().contains(properties.getDefaultRole().toLowerCase())) {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Role getCaptchaRewardRole() {
|
||||||
|
for(Role r : guild.getRoles()) {
|
||||||
|
if(r.getName().toLowerCase().contains(properties.getCaptchaReward().toLowerCase())) {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private void loadPreUsers() {
|
private void loadPreUsers() {
|
||||||
if(!properties.captchaEnabled()) {
|
if(!properties.captchaEnabled()) {
|
||||||
return;
|
return;
|
||||||
|
@ -258,7 +271,7 @@ public class Biscuit {
|
||||||
for(Role role : m.getRoles()){
|
for(Role role : m.getRoles()){
|
||||||
if(role.getName().equalsIgnoreCase(properties.getDefaultRole())){
|
if(role.getName().equalsIgnoreCase(properties.getDefaultRole())){
|
||||||
log(BColor.MAGENTA_BOLD + "Adding pre-join check for user " + u.getName() + " (" + u.getAsMention() + ")...");
|
log(BColor.MAGENTA_BOLD + "Adding pre-join check for user " + u.getName() + " (" + u.getAsMention() + ")...");
|
||||||
users.add(new PreUser(u,this));
|
users.add(PreUser.getPreUser(CaptchaUser.getCaptchaUser(u), this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,11 +301,21 @@ public class Biscuit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPreUser(PreUser user) {
|
public void addPreUser(PreUser user) {
|
||||||
users.add(user);
|
if(!users.contains(user)) {
|
||||||
|
users.add(user);
|
||||||
|
}else {
|
||||||
|
error("CAPTCHA ERROR: Tried to add PreUser when one already exists");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePreUser(PreUser user) {
|
public void removePreUser(PreUser user) {
|
||||||
users.remove(user);
|
ArrayList<PreUser> temp = new ArrayList<PreUser>(users);
|
||||||
|
for(PreUser u : temp) {
|
||||||
|
if(u.getUser().getId().equals(user.getUser().getId())) {
|
||||||
|
user.setDone();
|
||||||
|
users.remove(u);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CopyOnWriteArrayList<PreUser> getPreUsers(){
|
public CopyOnWriteArrayList<PreUser> getPreUsers(){
|
||||||
|
@ -332,7 +355,7 @@ public class Biscuit {
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<Member, Role> getRoleQueue() {
|
public HashMap<Member, Role> getRoleQueue() {
|
||||||
return rolequeue;
|
return rolequeue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,239 @@
|
||||||
|
package com.fpghoti.biscuit.captcha;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.PluginCore;
|
||||||
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.logging.BColor;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
|
import com.fpghoti.biscuit.user.CaptchaUser;
|
||||||
|
import com.fpghoti.biscuit.user.PreUser;
|
||||||
|
import com.github.cage.Cage;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
import net.dv8tion.jda.api.entities.PrivateChannel;
|
||||||
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
|
import net.dv8tion.jda.api.entities.User;
|
||||||
|
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
|
||||||
|
|
||||||
|
public class Captcha {
|
||||||
|
|
||||||
|
public static Captcha getUpdatedCaptcha(PrivateMessageReceivedEvent event) {
|
||||||
|
CaptchaUser c = CaptchaUser.getCaptchaUser(event.getAuthor());
|
||||||
|
if(c.getCaptcha() == null) {
|
||||||
|
Captcha captcha = new Captcha(event);
|
||||||
|
c.setCaptcha(captcha);
|
||||||
|
return captcha;
|
||||||
|
}else {
|
||||||
|
Captcha captcha = c.getCaptcha();
|
||||||
|
captcha.setEvent(event);
|
||||||
|
c.setCaptcha(captcha);
|
||||||
|
return captcha;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private CaptchaUser user;
|
||||||
|
private PrivateMessageReceivedEvent event;
|
||||||
|
private PrivateChannel channel;
|
||||||
|
private User author;
|
||||||
|
private String token;
|
||||||
|
|
||||||
|
private Captcha(PrivateMessageReceivedEvent event) {
|
||||||
|
this.user = CaptchaUser.getCaptchaUser(event.getAuthor());
|
||||||
|
this.event = event;
|
||||||
|
this.channel = event.getChannel();
|
||||||
|
this.author = event.getAuthor();
|
||||||
|
this.token = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEvent(PrivateMessageReceivedEvent event) {
|
||||||
|
this.event = event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getAuthor() {
|
||||||
|
return author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CaptchaUser getCaptchaUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrivateChannel getChannel() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToken() {
|
||||||
|
return this.token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void genToken() {
|
||||||
|
Cage cage = Main.getCage();
|
||||||
|
token = cage.getTokenGenerator().next();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleResponse() {
|
||||||
|
if(user.isEmpty() && !user.inTestMode()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String response = leeway(event.getMessage().getContentDisplay());
|
||||||
|
|
||||||
|
if(token != null && !response.equalsIgnoreCase(token)) {
|
||||||
|
respond("Sorry! That's not quite right! Please try again.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(token == null) {
|
||||||
|
|
||||||
|
log("Generating captcha challenge for user " + author.getName() + " " + author.getAsMention() + "...");
|
||||||
|
|
||||||
|
genToken();
|
||||||
|
generateImage();
|
||||||
|
File captcha = getImageFile();
|
||||||
|
|
||||||
|
respond("Respond with the exact text in this image.");
|
||||||
|
channel.sendFile(captcha).submit();
|
||||||
|
|
||||||
|
}else {
|
||||||
|
boolean disable = false;
|
||||||
|
if(user.inTestMode()) {
|
||||||
|
disable = true;
|
||||||
|
}else {
|
||||||
|
doCaptchaReward();
|
||||||
|
}
|
||||||
|
respond("Well done, " + author.getAsMention() + "!");
|
||||||
|
if(disable) {
|
||||||
|
user.disableTestMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generateImage() {
|
||||||
|
Cage cage = Main.getCage();
|
||||||
|
OutputStream os;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(!Main.isPlugin) {
|
||||||
|
//If Biscuit is running standalone output to this directory
|
||||||
|
os = new FileOutputStream("captcha/" + author.getId() + ".jpg", false);
|
||||||
|
}else {
|
||||||
|
//If Biscuit is running as a Spigot plugin output to this directory
|
||||||
|
File c = new File(PluginCore.plugin.getDataFolder(), "captcha/" + author.getId() + ".jpg");
|
||||||
|
os = new FileOutputStream(c, false);
|
||||||
|
}
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
Main.getMainBiscuit().error("Cannot retrieve captcha image directory.");
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Draw captcha image
|
||||||
|
try {
|
||||||
|
cage.draw(token, os);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
os.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getImageFile() {
|
||||||
|
if(!Main.isPlugin) {
|
||||||
|
return new File("captcha/" + author.getId() + ".jpg");
|
||||||
|
}else {
|
||||||
|
return new File(PluginCore.plugin.getDataFolder(), "captcha/" + author.getId() + ".jpg");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doCaptchaReward() {
|
||||||
|
for(PreUser p : user) {
|
||||||
|
//mark the PreUser as "done"
|
||||||
|
p.setDone();
|
||||||
|
|
||||||
|
Biscuit biscuit = p.getBiscuit();
|
||||||
|
|
||||||
|
if(biscuit == null) {
|
||||||
|
Main.getMainBiscuit().error("CAPTCHA ERROR: Null Biscuit");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Guild g = biscuit.getGuild();
|
||||||
|
|
||||||
|
if(g == null) {
|
||||||
|
biscuit.error("CAPTCHA ERROR: Null Guild");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Role newrole = biscuit.getCaptchaRewardRole();
|
||||||
|
Role defaultrole = biscuit.getDefaultRole();
|
||||||
|
|
||||||
|
if(newrole == null) {
|
||||||
|
biscuit.error("Cannot find captcha reward role!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(defaultrole == null) {
|
||||||
|
biscuit.error("Cannot find captcha default role!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Member member = g.getMemberById(author.getId());
|
||||||
|
|
||||||
|
g.addRoleToMember(member, newrole).complete();
|
||||||
|
g.removeRoleFromMember(member, defaultrole).complete();
|
||||||
|
p.remove();
|
||||||
|
token = null;
|
||||||
|
|
||||||
|
log(BColor.YELLOW_BOLD + author.getName() + " successfully completed a captcha challenge. Granting role.");
|
||||||
|
biscuit.captchaLog(" ``" + author.getName() +"`` " + author.getAsMention() + " successfully completed a captcha challenge. Granting role.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeFiles() {
|
||||||
|
File captcha;
|
||||||
|
if(!Main.isPlugin) {
|
||||||
|
//Biscuit is running standalone. Remove file from this directory
|
||||||
|
captcha = new File("captcha/" + user.getUser().getId() + ".jpg");
|
||||||
|
}else {
|
||||||
|
//Biscuit is running as Spigot plugin. Remove file from this directory
|
||||||
|
captcha = new File(PluginCore.plugin.getDataFolder(), "captcha/" + user.getUser().getId() + ".jpg");
|
||||||
|
}
|
||||||
|
captcha.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
//More characters may be replaced/removed here based on
|
||||||
|
//How many/what type of errors users commonly make
|
||||||
|
private String leeway(String s) {
|
||||||
|
s = s.replace("0", "O");
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void log(String msg) {
|
||||||
|
String prefix = "";
|
||||||
|
if(user.inTestMode()) {
|
||||||
|
prefix = "[TEST] ";
|
||||||
|
}
|
||||||
|
Main.getMainBiscuit().log(prefix + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void respond(String msg) {
|
||||||
|
String prefix = "";
|
||||||
|
if(user.inTestMode()) {
|
||||||
|
prefix = "[TEST] ";
|
||||||
|
}
|
||||||
|
MessageText.send(channel, prefix + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.commands.base.ConsoleCommand;
|
import com.fpghoti.biscuit.commands.base.ConsoleCommand;
|
||||||
import com.fpghoti.biscuit.commands.base.CustomCommand;
|
import com.fpghoti.biscuit.commands.base.CustomCommand;
|
||||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
|
@ -119,7 +120,7 @@ public class CommandManager {
|
||||||
|
|
||||||
public static void commandReply(GuildMessageReceivedEvent event, String msg) {
|
public static void commandReply(GuildMessageReceivedEvent event, String msg) {
|
||||||
if(event != null) {
|
if(event != null) {
|
||||||
event.getChannel().sendMessage(msg).queue();
|
MessageText.send(event.getChannel(), msg);
|
||||||
}else {
|
}else {
|
||||||
Main.getLogger().info(msg);
|
Main.getLogger().info(msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
@ -30,7 +31,7 @@ public class AddCommand extends ClientCommand{
|
||||||
if(end.equals(".0")) {
|
if(end.equals(".0")) {
|
||||||
sum = sum.replace(".0","");
|
sum = sum.replace(".0","");
|
||||||
}
|
}
|
||||||
event.getChannel().sendMessage(args[0] + " + " + args[1] + " is **" + sum + "**.").queue();
|
MessageText.send(event.getChannel(), args[0] + " + " + args[1] + " is **" + sum + "**.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ public class ChanIDCommand extends ClientCommand{
|
||||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||||
b.log(event.getAuthor().getName() + " issued a command: -chanid");
|
b.log(event.getAuthor().getName() + " issued a command: -chanid");
|
||||||
String id = event.getChannel().getId();
|
String id = event.getChannel().getId();
|
||||||
event.getChannel().sendMessage(id).queue();
|
MessageText.send(event.getChannel(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
@ -31,7 +32,7 @@ public class DivideCommand extends ClientCommand{
|
||||||
if(end.equals(".0")) {
|
if(end.equals(".0")) {
|
||||||
divide = divide.replace(".0","");
|
divide = divide.replace(".0","");
|
||||||
}
|
}
|
||||||
event.getChannel().sendMessage(args[0] + " / " + args[1] + " is **" + divide + "**.").queue();
|
MessageText.send(event.getChannel(), args[0] + " / " + args[1] + " is **" + divide + "**.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||||
|
@ -24,10 +25,10 @@ public class ForceSkipCommand extends MusicClientCommand{
|
||||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||||
b.log(event.getAuthor().getName() + " issued a command: -forceskip");
|
b.log(event.getAuthor().getName() + " issued a command: -forceskip");
|
||||||
if(PermUtil.isMod(event.getMember())) {
|
if(PermUtil.isMod(event.getMember())) {
|
||||||
event.getChannel().sendMessage("Force skipping current song.").queue();
|
MessageText.send(event.getChannel(), "Force skipping current song.");
|
||||||
if(b.getAudioScheduler().getQueue().getNext() != null ) {
|
if(b.getAudioScheduler().getQueue().getNext() != null ) {
|
||||||
MessageEmbed next = b.getAudioScheduler().getQueue().getNext().getEmbedMessage("Now Playing:");
|
MessageEmbed next = b.getAudioScheduler().getQueue().getNext().getEmbedMessage("Now Playing:");
|
||||||
event.getChannel().sendMessage(next).queue();
|
MessageText.send(event.getChannel(), next);
|
||||||
}
|
}
|
||||||
b.getAudioScheduler().skip();
|
b.getAudioScheduler().skip();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
package com.fpghoti.biscuit.commands.client;
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.logging.BColor;
|
import com.fpghoti.biscuit.logging.BColor;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
|
||||||
public class GetConfigCommand extends ClientCommand{
|
public class GetConfigCommand extends ClientCommand{
|
||||||
|
@ -31,14 +28,8 @@ public class GetConfigCommand extends ClientCommand{
|
||||||
event.getChannel().sendFile(b.getConfig().getFile(), "config-" + b.getProperties().getGuildCode() + ".properties").queue();
|
event.getChannel().sendFile(b.getConfig().getFile(), "config-" + b.getProperties().getGuildCode() + ".properties").queue();
|
||||||
}else {
|
}else {
|
||||||
b.log(BColor.MAGENTA_BOLD + event.getAuthor().getName() + " lacks permission to view the config!");
|
b.log(BColor.MAGENTA_BOLD + event.getAuthor().getName() + " lacks permission to view the config!");
|
||||||
event.getChannel().sendMessage(event.getAuthor().getAsMention() + " You do not have "
|
MessageText.sendTimed(event.getChannel(), event.getAuthor().getAsMention() + " You do not have "
|
||||||
+ "permission to view the config.").queue(new Consumer<Message>()
|
+ "permission to view the config.", 5);
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void accept(Message msg){
|
|
||||||
msg.delete().submitAfter(5, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
@ -24,7 +25,7 @@ public class GuildIDCommand extends ClientCommand{
|
||||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||||
b.log(event.getAuthor().getName() + " issued a command: -guildid");
|
b.log(event.getAuthor().getName() + " issued a command: -guildid");
|
||||||
if(PermUtil.isMod(event.getMember())) {
|
if(PermUtil.isMod(event.getMember())) {
|
||||||
event.getChannel().sendMessage(event.getGuild().getId()).queue();
|
MessageText.send(event.getChannel(), event.getGuild().getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.fpghoti.biscuit.commands.CommandManager;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.commands.base.CustomCommand;
|
import com.fpghoti.biscuit.commands.base.CustomCommand;
|
||||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
@ -35,7 +36,7 @@ public class HelpCommand extends ClientCommand {
|
||||||
if(Util.isDigit(args[0])) {
|
if(Util.isDigit(args[0])) {
|
||||||
pg = Integer.parseInt(args[0]);
|
pg = Integer.parseInt(args[0]);
|
||||||
}else {
|
}else {
|
||||||
event.getChannel().sendMessage("Usage: ``" + usage + "``").queue();
|
MessageText.send(event.getChannel(), "Usage: ``" + usage + "``");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<BaseCommand> commands = new ArrayList<BaseCommand>();
|
List<BaseCommand> commands = new ArrayList<BaseCommand>();
|
||||||
|
@ -72,8 +73,8 @@ public class HelpCommand extends ClientCommand {
|
||||||
pg = pageCount;
|
pg = pageCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.getChannel().sendMessage("**Use " + Main.getMainBiscuit().getProperties().getCommandSignifier() + "help [Page #] to navigate the different pages.**").queue();
|
MessageText.send(event.getChannel(), "**Use " + Main.getMainBiscuit().getProperties().getCommandSignifier() + "help [Page #] to navigate the different pages.**");
|
||||||
event.getChannel().sendMessage("[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] **Bot Commands:**").queue();
|
MessageText.send(event.getChannel(), "[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] **Bot Commands:**");
|
||||||
String msg = "";
|
String msg = "";
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
int index = (pg - 1) * 8 + i;
|
int index = (pg - 1) * 8 + i;
|
||||||
|
@ -88,8 +89,7 @@ public class HelpCommand extends ClientCommand {
|
||||||
msg = msg + line;
|
msg = msg + line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event.getChannel().sendMessage(msg).queue();
|
MessageText.send(event.getChannel(), msg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
@ -24,10 +25,10 @@ public class LoopMusicCommand extends MusicClientCommand{
|
||||||
b.log(event.getAuthor().getName() + " issued a command: -loopmusic");
|
b.log(event.getAuthor().getName() + " issued a command: -loopmusic");
|
||||||
if(PermUtil.isMod(event.getMember())) {
|
if(PermUtil.isMod(event.getMember())) {
|
||||||
if(!b.getAudioScheduler().isLooping()) {
|
if(!b.getAudioScheduler().isLooping()) {
|
||||||
event.getChannel().sendMessage("Setting all music to loop.").queue();
|
MessageText.send(event.getChannel(), "Setting all music to loop.");
|
||||||
b.getAudioScheduler().setLooping(true);
|
b.getAudioScheduler().setLooping(true);
|
||||||
}else {
|
}else {
|
||||||
event.getChannel().sendMessage("Disabling music looping.").queue();
|
MessageText.send(event.getChannel(), "Disabling music looping.");
|
||||||
b.getAudioScheduler().setLooping(false);
|
b.getAudioScheduler().setLooping(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ public class MakeInviteCommand extends ClientCommand{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(doubAge > 86400) {
|
if(doubAge > 86400) {
|
||||||
event.getChannel().sendMessage("That length is longer than what Discord allows. Please try again. (Max 24 hours)").queue();
|
MessageText.send(event.getChannel(), "That length is longer than what Discord allows. Please try again. (Max 24 hours)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final double db = doubAge;
|
final double db = doubAge;
|
||||||
|
@ -49,7 +50,7 @@ public class MakeInviteCommand extends ClientCommand{
|
||||||
if(db > 0) {
|
if(db > 0) {
|
||||||
exp = args[1] + " hour(s)";
|
exp = args[1] + " hour(s)";
|
||||||
}
|
}
|
||||||
event.getChannel().sendMessage("Created invite **" + i.getCode() + "** Expiration: **" + exp + "**.").queue();
|
MessageText.send(event.getChannel(), "Created invite **" + i.getCode() + "** Expiration: **" + exp + "**.");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
@ -31,7 +32,7 @@ public class MultiplyCommand extends ClientCommand{
|
||||||
if(end.equals(".0")) {
|
if(end.equals(".0")) {
|
||||||
prod = prod.replace(".0","");
|
prod = prod.replace(".0","");
|
||||||
}
|
}
|
||||||
event.getChannel().sendMessage(args[0] + " x " + args[1] + " is **" + prod + "**.").queue();
|
MessageText.send(event.getChannel(), args[0] + " x " + args[1] + " is **" + prod + "**.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
@ -29,7 +30,7 @@ public class NotSpammerCommand extends ClientCommand{
|
||||||
String s = u.getAsMention();
|
String s = u.getAsMention();
|
||||||
if(event.getChannel().getName().equals("public-spam-test") || (PermUtil.isMod(event.getMember()))) {
|
if(event.getChannel().getName().equals("public-spam-test") || (PermUtil.isMod(event.getMember()))) {
|
||||||
b.getMessageStore().removeSpammer(u);
|
b.getMessageStore().removeSpammer(u);
|
||||||
event.getChannel().sendMessage(s+ " is no longer flagged as spam.").queue();
|
MessageText.send(event.getChannel(), s + " is no longer flagged as spam.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
@ -24,9 +25,9 @@ public class NowPlayingCommand extends MusicClientCommand{
|
||||||
b.log(event.getAuthor().getName() + " issued a command: -nowplaying");
|
b.log(event.getAuthor().getName() + " issued a command: -nowplaying");
|
||||||
if(b.getAudioScheduler().getQueue().getLastTrack() != null ) {
|
if(b.getAudioScheduler().getQueue().getLastTrack() != null ) {
|
||||||
MessageEmbed next = b.getAudioScheduler().getQueue().getLastTrack().getEmbedMessage("Now Playing:", true);
|
MessageEmbed next = b.getAudioScheduler().getQueue().getLastTrack().getEmbedMessage("Now Playing:", true);
|
||||||
event.getChannel().sendMessage(next).queue();
|
MessageText.send(event.getChannel(), next);
|
||||||
}else {
|
}else {
|
||||||
event.getChannel().sendMessage("No song is currently playing.").queue();
|
MessageText.send(event.getChannel(), "No song is currently playing.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
@ -25,9 +26,9 @@ public class PauseCommand extends MusicClientCommand{
|
||||||
if(PermUtil.isMod(event.getMember())) {
|
if(PermUtil.isMod(event.getMember())) {
|
||||||
if(!b.getAudioPlayer().isPaused()) {
|
if(!b.getAudioPlayer().isPaused()) {
|
||||||
b.getAudioPlayer().setPaused(true);
|
b.getAudioPlayer().setPaused(true);
|
||||||
event.getChannel().sendMessage("Paused the current track.").queue();
|
MessageText.send(event.getChannel(), "Paused the current track.");
|
||||||
}else {
|
}else {
|
||||||
event.getChannel().sendMessage("The music player is already paused.").queue();
|
MessageText.send(event.getChannel(), "The music player is already paused.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ public class PingCommand extends ClientCommand{
|
||||||
public void execute(String[] args, GuildMessageReceivedEvent event) {
|
public void execute(String[] args, GuildMessageReceivedEvent event) {
|
||||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||||
b.log(event.getAuthor().getName() + " issued a command: -ping");
|
b.log(event.getAuthor().getName() + " issued a command: -ping");
|
||||||
event.getChannel().sendMessage("Pong!").queue();
|
MessageText.send(event.getChannel(), "Pong!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.fpghoti.biscuit.audio.AudioHandler;
|
||||||
import com.fpghoti.biscuit.audio.AudioResultHandler;
|
import com.fpghoti.biscuit.audio.AudioResultHandler;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
|
@ -41,7 +42,7 @@ public class PlayCommand extends MusicClientCommand{
|
||||||
|
|
||||||
String vcname = "";
|
String vcname = "";
|
||||||
if(!event.getMember().getVoiceState().inVoiceChannel()) {
|
if(!event.getMember().getVoiceState().inVoiceChannel()) {
|
||||||
tchannel.sendMessage("You must be in a voice channel to do this!").queue();
|
MessageText.send(tchannel, "You must be in a voice channel to do this!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vcname = event.getMember().getVoiceState().getChannel().getName();
|
vcname = event.getMember().getVoiceState().getChannel().getName();
|
||||||
|
@ -55,14 +56,14 @@ public class PlayCommand extends MusicClientCommand{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(found == false) {
|
if(found == false) {
|
||||||
tchannel.sendMessage("You are not in a channel that is authorized to use the music player.").queue();
|
MessageText.send(tchannel, "You are not in a channel that is authorized to use the music player.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(b.getAudioPlayer().getPlayingTrack() != null && guild.getAudioManager().isConnected() && !guild.getAudioManager().getConnectedChannel().getMembers().contains(event.getMember())) {
|
if(b.getAudioPlayer().getPlayingTrack() != null && guild.getAudioManager().isConnected() && !guild.getAudioManager().getConnectedChannel().getMembers().contains(event.getMember())) {
|
||||||
tchannel.sendMessage("Music is already playing in a voice channel. Connect to "
|
MessageText.send(tchannel, "Music is already playing in a voice channel. Connect to "
|
||||||
+ "that channel, then queue your song.").queue();
|
+ "that channel, then queue your song.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.fpghoti.biscuit.audio.AudioHandler;
|
||||||
import com.fpghoti.biscuit.audio.AudioResultHandler;
|
import com.fpghoti.biscuit.audio.AudioResultHandler;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
||||||
|
|
||||||
|
@ -43,12 +44,12 @@ public class PlayFirstCommand extends MusicClientCommand{
|
||||||
String vcname = "";
|
String vcname = "";
|
||||||
|
|
||||||
if(!PermUtil.isMod(event.getMember())) {
|
if(!PermUtil.isMod(event.getMember())) {
|
||||||
tchannel.sendMessage("You do not have permission to do this!").queue();
|
MessageText.send(tchannel, "You do not have permission to do this!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!event.getMember().getVoiceState().inVoiceChannel()) {
|
if(!event.getMember().getVoiceState().inVoiceChannel()) {
|
||||||
tchannel.sendMessage("You must be in a voice channel to do this!").queue();
|
MessageText.send(tchannel, "You must be in a voice channel to do this!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vcname = event.getMember().getVoiceState().getChannel().getName();
|
vcname = event.getMember().getVoiceState().getChannel().getName();
|
||||||
|
@ -62,14 +63,14 @@ public class PlayFirstCommand extends MusicClientCommand{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(found == false) {
|
if(found == false) {
|
||||||
tchannel.sendMessage("You are not in a channel that is authorized to use the music player.").queue();
|
MessageText.send(tchannel, "You are not in a channel that is authorized to use the music player.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(b.getAudioPlayer().getPlayingTrack() != null && guild.getAudioManager().isConnected() && !guild.getAudioManager().getConnectedChannel().getMembers().contains(event.getMember())) {
|
if(b.getAudioPlayer().getPlayingTrack() != null && guild.getAudioManager().isConnected() && !guild.getAudioManager().getConnectedChannel().getMembers().contains(event.getMember())) {
|
||||||
tchannel.sendMessage("Music is already playing in a voice channel. Connect to "
|
MessageText.send(tchannel, "Music is already playing in a voice channel. Connect to "
|
||||||
+ "that channel, then queue your song.").queue();
|
+ "that channel, then queue your song.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
@ -31,7 +32,7 @@ public class PowerCommand extends ClientCommand{
|
||||||
if(end.equals(".0")) {
|
if(end.equals(".0")) {
|
||||||
pow = pow.replace(".0","");
|
pow = pow.replace(".0","");
|
||||||
}
|
}
|
||||||
event.getChannel().sendMessage(args[0] + "^" + args[1] + " is **" + pow + "**.").queue();
|
MessageText.send(event.getChannel(), args[0] + "^" + args[1] + " is **" + pow + "**.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.fpghoti.biscuit.audio.queue.AudioQueue;
|
||||||
import com.fpghoti.biscuit.audio.queue.QueuedTrack;
|
import com.fpghoti.biscuit.audio.queue.QueuedTrack;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ public class QueueCommand extends MusicClientCommand{
|
||||||
if(Util.isDigit(args[0])) {
|
if(Util.isDigit(args[0])) {
|
||||||
pg = Integer.parseInt(args[0]);
|
pg = Integer.parseInt(args[0]);
|
||||||
}else {
|
}else {
|
||||||
event.getChannel().sendMessage("Usage: ``" + usage + "``").queue();
|
MessageText.send(event.getChannel(), "Usage: ``" + usage + "``");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,15 +46,15 @@ public class QueueCommand extends MusicClientCommand{
|
||||||
|
|
||||||
if(queue.size() == 0) {
|
if(queue.size() == 0) {
|
||||||
if(biscuit.getAudioPlayer().getPlayingTrack() == null) {
|
if(biscuit.getAudioPlayer().getPlayingTrack() == null) {
|
||||||
event.getChannel().sendMessage("There is currently no song playing.").queue();
|
MessageText.send(event.getChannel(), "There is currently no song playing.");
|
||||||
}else {
|
}else {
|
||||||
event.getChannel().sendMessage("Nothing is queued to play after the current track.").queue();
|
MessageText.send(event.getChannel(), "Nothing is queued to play after the current track.");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.getChannel().sendMessage("**Use " + Main.getMainBiscuit().getProperties().getCommandSignifier() + "queue [Page #] to navigate the different pages.**").queue();
|
MessageText.send(event.getChannel(), "**Use " + Main.getMainBiscuit().getProperties().getCommandSignifier() + "queue [Page #] to navigate the different pages.**");
|
||||||
event.getChannel().sendMessage("[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] ** Upcoming Music Tracks:**").queue();
|
MessageText.send(event.getChannel(), "[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] ** Upcoming Music Tracks:**");
|
||||||
String msg = "";
|
String msg = "";
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
int index = (pg - 1) * 8 + i;
|
int index = (pg - 1) * 8 + i;
|
||||||
|
@ -75,7 +76,7 @@ public class QueueCommand extends MusicClientCommand{
|
||||||
msg = msg + line;
|
msg = msg + line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event.getChannel().sendMessage(msg).queue();
|
MessageText.send(event.getChannel(), msg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ public class RecentSpammersCommand extends ClientCommand{
|
||||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||||
b.log(event.getAuthor().getName() + " issued a command: -recentspammers");
|
b.log(event.getAuthor().getName() + " issued a command: -recentspammers");
|
||||||
String msg = b.getMessageStore().getSpammerList();
|
String msg = b.getMessageStore().getSpammerList();
|
||||||
event.getChannel().sendMessage(msg).queue();
|
MessageText.send(event.getChannel(), msg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
package com.fpghoti.biscuit.commands.client;
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.logging.BColor;
|
import com.fpghoti.biscuit.logging.BColor;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
|
||||||
import net.dv8tion.jda.api.entities.Message.Attachment;
|
import net.dv8tion.jda.api.entities.Message.Attachment;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
|
||||||
|
@ -39,35 +37,17 @@ public class SaveConfigCommand extends ClientCommand{
|
||||||
b = Biscuit.loadGuild(event.getGuild());
|
b = Biscuit.loadGuild(event.getGuild());
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
event.getChannel().sendMessage(event.getAuthor().getAsMention() + " Too many attachments added! "
|
MessageText.sendTimed(event.getChannel(), event.getAuthor().getAsMention() + " Too many attachments added! "
|
||||||
+ "Please only include the config file you want to save.").queue(new Consumer<Message>()
|
+ "Please only include the config file you want to save.", 5);
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void accept(Message msg){
|
|
||||||
msg.delete().submitAfter(5, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
event.getChannel().sendMessage(event.getAuthor().getAsMention() + " You need to send "
|
MessageText.sendTimed(event.getChannel(), event.getAuthor().getAsMention() + " You need to send "
|
||||||
+ "a file in order to save the config.").queue(new Consumer<Message>()
|
+ "a file in order to save the config.", 5);
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void accept(Message msg){
|
|
||||||
msg.delete().submitAfter(5, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
b.log(BColor.MAGENTA_BOLD + event.getAuthor().getName() + " lacks permission to save the config!");
|
b.log(BColor.MAGENTA_BOLD + event.getAuthor().getName() + " lacks permission to save the config!");
|
||||||
event.getChannel().sendMessage(event.getAuthor().getAsMention() + " You do not have "
|
MessageText.sendTimed(event.getChannel(), event.getAuthor().getAsMention() + " You do not have "
|
||||||
+ "permission to save the config.").queue(new Consumer<Message>()
|
+ "permission to save the config.", 5);
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void accept(Message msg){
|
|
||||||
msg.delete().submitAfter(5, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
@ -27,41 +28,41 @@ public class SkipCommand extends MusicClientCommand{
|
||||||
b.log(event.getAuthor().getName() + " issued a command: -skip");
|
b.log(event.getAuthor().getName() + " issued a command: -skip");
|
||||||
|
|
||||||
if(b.getAudioPlayer().getPlayingTrack() == null) {
|
if(b.getAudioPlayer().getPlayingTrack() == null) {
|
||||||
event.getChannel().sendMessage("There is not a song playing for you to skip!").queue();
|
MessageText.send(event.getChannel(), "There is not a song playing for you to skip!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!event.getGuild().getAudioManager().getConnectedChannel().getMembers().contains(event.getMember())) {
|
if(!event.getGuild().getAudioManager().getConnectedChannel().getMembers().contains(event.getMember())) {
|
||||||
event.getChannel().sendMessage("You need to be in the same voice channel in order to skip!").queue();
|
MessageText.send(event.getChannel(), "You need to be in the same voice channel in order to skip!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(b.getAudioScheduler().getVotes() >= (event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() - 1) / 2) {
|
if(b.getAudioScheduler().getVotes() >= (event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() - 1) / 2) {
|
||||||
event.getChannel().sendMessage("Skip vote status: **[" + ( b.getAudioScheduler().getVotes() + 1) + "/"
|
MessageText.send(event.getChannel(), "Skip vote status: **[" + ( b.getAudioScheduler().getVotes() + 1) + "/"
|
||||||
+ (event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() - 1) + "]**"
|
+ (event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() - 1) + "]**"
|
||||||
+ "\nSkipping current track.").queue();
|
+ "\nSkipping current track.");
|
||||||
if(b.getAudioScheduler().getQueue().getNext() != null ) {
|
if(b.getAudioScheduler().getQueue().getNext() != null ) {
|
||||||
MessageEmbed next = b.getAudioScheduler().getQueue().getNext().getEmbedMessage("Now Playing:");
|
MessageEmbed next = b.getAudioScheduler().getQueue().getNext().getEmbedMessage("Now Playing:");
|
||||||
event.getChannel().sendMessage(next).queue();
|
MessageText.send(event.getChannel(), next);
|
||||||
}
|
}
|
||||||
b.getAudioScheduler().skip();
|
b.getAudioScheduler().skip();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(b.getAudioScheduler().voteSkip(event.getAuthor().getId())) {
|
if(b.getAudioScheduler().voteSkip(event.getAuthor().getId())) {
|
||||||
event.getChannel().sendMessage("You voted to skip the current track.").queue();
|
MessageText.send(event.getChannel(), "You voted to skip the current track.");
|
||||||
}else {
|
}else {
|
||||||
event.getChannel().sendMessage("You cannot vote to skip this track again."
|
MessageText.send(event.getChannel(), "You cannot vote to skip this track again."
|
||||||
+ "\nSkip vote status: **[" + b.getAudioScheduler().getVotes() + "/"
|
+ "\nSkip vote status: **[" + b.getAudioScheduler().getVotes() + "/"
|
||||||
+ (event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() - 1) + "]**").queue();
|
+ (event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() - 1) + "]**");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(b.getAudioScheduler().getVotes() >= (event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() - 1) / 2) {
|
if(b.getAudioScheduler().getVotes() >= (event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() - 1) / 2) {
|
||||||
event.getChannel().sendMessage("Skip vote status: **[" + b.getAudioScheduler().getVotes() + "/"
|
MessageText.send(event.getChannel(), "Skip vote status: **[" + b.getAudioScheduler().getVotes() + "/"
|
||||||
+ event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() + "]**"
|
+ event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() + "]**"
|
||||||
+ "\nSkipping current track.").queue();
|
+ "\nSkipping current track.");
|
||||||
if(b.getAudioScheduler().getQueue().getNext() != null ) {
|
if(b.getAudioScheduler().getQueue().getNext() != null ) {
|
||||||
MessageEmbed next = b.getAudioScheduler().getQueue().getNext().getEmbedMessage("Now Playing:");
|
MessageEmbed next = b.getAudioScheduler().getQueue().getNext().getEmbedMessage("Now Playing:");
|
||||||
event.getChannel().sendMessage(next).queue();
|
MessageText.send(event.getChannel(), next);
|
||||||
}
|
}
|
||||||
b.getAudioScheduler().skip();
|
b.getAudioScheduler().skip();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
package com.fpghoti.biscuit.commands.client;
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
|
||||||
import net.dv8tion.jda.api.entities.User;
|
import net.dv8tion.jda.api.entities.User;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
|
||||||
|
@ -32,19 +29,13 @@ public class SoftMuteCommand extends ClientCommand{
|
||||||
User u = m.getUser();
|
User u = m.getUser();
|
||||||
String s = u.getAsMention();
|
String s = u.getAsMention();
|
||||||
if(b.getMessageStore().isSoftmuted(u)) {
|
if(b.getMessageStore().isSoftmuted(u)) {
|
||||||
event.getChannel().sendMessage(s+ " is already softmuted.").queue(new Consumer<Message>()
|
MessageText.sendTimed(event.getChannel(), s + " is already softmuted.", 3);
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void accept(Message msg){
|
|
||||||
msg.delete().reason("Automatic bot message removal").submitAfter(3, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(event.getChannel().getName().equals("public-softmute-test") || (PermUtil.isMod(event.getMember()))) {
|
if(event.getChannel().getName().equals("public-softmute-test") || (PermUtil.isMod(event.getMember()))) {
|
||||||
b.getMessageStore().addSoftmuted(u);
|
b.getMessageStore().addSoftmuted(u);
|
||||||
u.openPrivateChannel().queue();
|
u.openPrivateChannel().queue();
|
||||||
event.getChannel().sendMessage(s+ " is now soft-muted. They will now be only able to send one message every two minutes.").queue();
|
MessageText.send(event.getChannel(), s + " is now soft-muted. They will now be only able to send one message every two minutes.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
@ -30,7 +31,7 @@ public class SquareRootCommand extends ClientCommand{
|
||||||
if(end.equals(".0")) {
|
if(end.equals(".0")) {
|
||||||
root = root.replace(".0","");
|
root = root.replace(".0","");
|
||||||
}
|
}
|
||||||
event.getChannel().sendMessage("The sqaure root of " + args[0] + " is **" + root + "**.").queue();
|
MessageText.send(event.getChannel(), "The sqaure root of " + args[0] + " is **" + root + "**.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
@ -31,7 +32,7 @@ public class SubtractCommand extends ClientCommand{
|
||||||
if(end.equals(".0")) {
|
if(end.equals(".0")) {
|
||||||
sub = sub.replace(".0","");
|
sub = sub.replace(".0","");
|
||||||
}
|
}
|
||||||
event.getChannel().sendMessage(args[0] + " - " + args[1] + " is **" + sub + "**.").queue();
|
MessageText.send(event.getChannel(), args[0] + " - " + args[1] + " is **" + sub + "**.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
@ -26,10 +27,10 @@ public class TogglePauseCommand extends MusicClientCommand{
|
||||||
if(PermUtil.isMod(event.getMember())) {
|
if(PermUtil.isMod(event.getMember())) {
|
||||||
if(b.getAudioPlayer().isPaused()) {
|
if(b.getAudioPlayer().isPaused()) {
|
||||||
b.getAudioPlayer().setPaused(false);
|
b.getAudioPlayer().setPaused(false);
|
||||||
event.getChannel().sendMessage("Unpaused the current track.").queue();
|
MessageText.send(event.getChannel(), "Unpaused the current track.");
|
||||||
}else {
|
}else {
|
||||||
b.getAudioPlayer().setPaused(true);
|
b.getAudioPlayer().setPaused(true);
|
||||||
event.getChannel().sendMessage("Paused the current track.").queue();
|
MessageText.send(event.getChannel(), "Paused the current track.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Emote;
|
import net.dv8tion.jda.api.entities.Emote;
|
||||||
|
@ -37,7 +38,7 @@ public class ToggleRoleCommand extends ClientCommand{
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rolename.equals("")) {
|
if(rolename.equals("")) {
|
||||||
event.getChannel().sendMessage("Sorry! This role either cannot be toggled or does not exist!").queue();
|
MessageText.send(event.getChannel(), "Sorry! This role either cannot be toggled or does not exist!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
@ -27,7 +28,7 @@ public class UIDCommand extends ClientCommand{
|
||||||
for(Member m : event.getMessage().getMentionedMembers()){
|
for(Member m : event.getMessage().getMentionedMembers()){
|
||||||
User u = m.getUser();
|
User u = m.getUser();
|
||||||
if(PermUtil.isMod(event.getMember())) {
|
if(PermUtil.isMod(event.getMember())) {
|
||||||
event.getChannel().sendMessage(u.getId()).queue();
|
MessageText.send(event.getChannel(), u.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
@ -29,7 +30,7 @@ public class UnSoftMuteCommand extends ClientCommand{
|
||||||
String s = u.getAsMention();
|
String s = u.getAsMention();
|
||||||
if(event.getChannel().getName().equals("public-softmute-test") || (PermUtil.isMod(event.getMember()))) {
|
if(event.getChannel().getName().equals("public-softmute-test") || (PermUtil.isMod(event.getMember()))) {
|
||||||
b.getMessageStore().removeSoftmuted(u);
|
b.getMessageStore().removeSoftmuted(u);
|
||||||
event.getChannel().sendMessage(s+ " is no longer soft-muted.").queue();
|
MessageText.send(event.getChannel(), s + " is no longer soft-muted.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
@ -25,9 +26,9 @@ public class UnpauseCommand extends ClientCommand{
|
||||||
if(PermUtil.isMod(event.getMember())) {
|
if(PermUtil.isMod(event.getMember())) {
|
||||||
if(b.getAudioPlayer().isPaused()) {
|
if(b.getAudioPlayer().isPaused()) {
|
||||||
b.getAudioPlayer().setPaused(false);
|
b.getAudioPlayer().setPaused(false);
|
||||||
event.getChannel().sendMessage("Unpaused the current track.").queue();
|
MessageText.send(event.getChannel(), "Unpaused the current track.");
|
||||||
}else {
|
}else {
|
||||||
event.getChannel().sendMessage("The music player is not paused.").queue();
|
MessageText.send(event.getChannel(), "The music player is not paused.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
@ -23,7 +24,7 @@ public class WikiCommand extends ClientCommand{
|
||||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||||
b.log(event.getAuthor().getName() + " issued a command: -wiki");
|
b.log(event.getAuthor().getName() + " issued a command: -wiki");
|
||||||
if(PermUtil.isMod(event.getMember())) {
|
if(PermUtil.isMod(event.getMember())) {
|
||||||
event.getChannel().sendMessage("https://git.fpghoti.com/thmsdy/Biscuit/wiki").queue();
|
MessageText.send(event.getChannel(), "https://git.fpghoti.com/thmsdy/Biscuit/wiki");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
@ -25,7 +26,7 @@ public class WipeQueueCommand extends MusicClientCommand{
|
||||||
b.log(event.getAuthor().getName() + " issued a command: -wipequeue");
|
b.log(event.getAuthor().getName() + " issued a command: -wipequeue");
|
||||||
if(PermUtil.isMod(event.getMember())) {
|
if(PermUtil.isMod(event.getMember())) {
|
||||||
b.getAudioScheduler().wipeQueue();
|
b.getAudioScheduler().wipeQueue();
|
||||||
event.getChannel().sendMessage("Removed upcoming songs from the music queue.").queue();
|
MessageText.send(event.getChannel(), "Removed upcoming songs from the music queue.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.console;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ConsoleCommand;
|
import com.fpghoti.biscuit.commands.base.ConsoleCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
|
@ -41,7 +42,7 @@ public class GuildSayCommand extends ConsoleCommand{
|
||||||
|
|
||||||
for(TextChannel c : guild.getTextChannels()) {
|
for(TextChannel c : guild.getTextChannels()) {
|
||||||
if(c.getName().equalsIgnoreCase(channel) || c.getName().equalsIgnoreCase("#" + channel)) {
|
if(c.getName().equalsIgnoreCase(channel) || c.getName().equalsIgnoreCase("#" + channel)) {
|
||||||
c.sendMessage(message).queue();
|
MessageText.send(c, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.console;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.base.ConsoleCommand;
|
import com.fpghoti.biscuit.commands.base.ConsoleCommand;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
|
@ -37,7 +38,7 @@ public class SayCommand extends ConsoleCommand{
|
||||||
|
|
||||||
for(TextChannel c : guild.getTextChannels()) {
|
for(TextChannel c : guild.getTextChannels()) {
|
||||||
if(c.getName().equalsIgnoreCase(target) || c.getName().equalsIgnoreCase("#" + target)) {
|
if(c.getName().equalsIgnoreCase(target) || c.getName().equalsIgnoreCase("#" + target)) {
|
||||||
c.sendMessage(message).queue();
|
MessageText.send(c, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ import org.apache.commons.configuration2.PropertiesConfigurationLayout;
|
||||||
import org.apache.commons.configuration2.ex.ConfigurationException;
|
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.jcabi.aspects.Async;
|
import com.jcabi.aspects.Async;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
|
@ -69,16 +70,16 @@ public class BiscuitConfig {
|
||||||
}
|
}
|
||||||
String name = guild.getId() + ".properties";
|
String name = guild.getId() + ".properties";
|
||||||
if(a.getSize() > 51200) {
|
if(a.getSize() > 51200) {
|
||||||
c.sendMessage("**The file is too big!**").queue();
|
MessageText.send(c, "**The file is too big!**");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
File config = new File(biscuit.getConfigDir(), name);
|
File config = new File(biscuit.getConfigDir(), name);
|
||||||
a.downloadToFile(config).thenAccept(file -> {
|
a.downloadToFile(config).thenAccept(file -> {
|
||||||
updateConfig(file, true, code);
|
updateConfig(file, true, code);
|
||||||
c.sendMessage("**The config was successfully updated.**").queue();
|
MessageText.send(c, "**The config was successfully updated.**");
|
||||||
}).exceptionally(t -> {
|
}).exceptionally(t -> {
|
||||||
biscuit.error("Could not accept config file.");
|
biscuit.error("Could not accept config file.");
|
||||||
c.sendMessage("**An Exception occurred while trying to read the file.**").queue();
|
MessageText.send(c, "**An Exception occurred while trying to read the file.**");
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,196 +1,48 @@
|
||||||
package com.fpghoti.biscuit.listener;
|
package com.fpghoti.biscuit.listener;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.PluginCore;
|
import com.fpghoti.biscuit.captcha.Captcha;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
|
||||||
import com.fpghoti.biscuit.logging.BColor;
|
import com.fpghoti.biscuit.logging.BColor;
|
||||||
import com.fpghoti.biscuit.user.PreUser;
|
import com.fpghoti.biscuit.user.CaptchaUser;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
import com.github.cage.Cage;
|
|
||||||
|
|
||||||
import net.dv8tion.jda.api.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
import net.dv8tion.jda.api.entities.ChannelType;
|
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.entities.PrivateChannel;
|
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
|
||||||
import net.dv8tion.jda.api.entities.Role;
|
|
||||||
import net.dv8tion.jda.api.entities.User;
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
|
|
||||||
public class DMListener extends ListenerAdapter{
|
public class DMListener extends ListenerAdapter{
|
||||||
|
|
||||||
private static ArrayList<User> testers = new ArrayList<User>();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessageReceived(MessageReceivedEvent event){
|
public void onPrivateMessageReceived(PrivateMessageReceivedEvent event){
|
||||||
//Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
if (!event.getAuthor().isBot()) {
|
||||||
if (event.isFromType(ChannelType.PRIVATE) && !event.getAuthor().isBot()) {
|
|
||||||
String content = event.getMessage().getContentDisplay();
|
//Log DM content to console
|
||||||
User user = event.getAuthor();
|
|
||||||
boolean isTest = false;
|
|
||||||
boolean found = false;
|
|
||||||
if(testers.size() > 0) {
|
|
||||||
for(User u : testers) {
|
|
||||||
if(user.getId().equals(u.getId())) {
|
|
||||||
isTest = true;
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(content.equalsIgnoreCase("captcha pls") || content.equalsIgnoreCase("cpls")) {
|
|
||||||
JDA jda = Main.getJDA();
|
|
||||||
for(Guild g : jda.getGuilds()) {
|
|
||||||
if(g.isMember(user)) {
|
|
||||||
Member m = g.getMember(user);
|
|
||||||
if(PermUtil.isAdmin(m)) {
|
|
||||||
isTest = true;
|
|
||||||
if(!found && !PreUser.hasTestUser(event.getAuthor())) {
|
|
||||||
PreUser.testusers.add(new PreUser(user, Main.getMainBiscuit(), true));
|
|
||||||
testers.add(user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(Main.getMainBiscuit().getProperties().logChat()) {
|
if(Main.getMainBiscuit().getProperties().logChat()) {
|
||||||
Main.getMainBiscuit().log("[" + BColor.CYAN_BOLD + "DM" + BColor.RESET + "] " + BColor.YELLOW + "ID: " + BColor.RESET +
|
Main.getMainBiscuit().log("[" + BColor.CYAN_BOLD + "DM" + BColor.RESET + "] " + BColor.YELLOW + "ID: " + BColor.RESET +
|
||||||
event.getMessageId() + BColor.YELLOW + " Sender: " + BColor.RESET + event.getAuthor().getAsMention());
|
event.getMessageId() + BColor.YELLOW + " Sender: " + BColor.RESET + event.getAuthor().getAsMention());
|
||||||
Main.getMainBiscuit().log(BColor.YELLOW + event.getAuthor().getName() + ": " + BColor.WHITE_BOLD + event.getMessage().getContentDisplay());
|
Main.getMainBiscuit().log(BColor.YELLOW + event.getAuthor().getName() + ": " + BColor.WHITE_BOLD + event.getMessage().getContentDisplay());
|
||||||
}
|
}
|
||||||
handleCaptcha(event, isTest);
|
|
||||||
|
String content = event.getMessage().getContentDisplay();
|
||||||
|
Captcha captcha = Captcha.getUpdatedCaptcha(event);
|
||||||
|
CaptchaUser capUser = captcha.getCaptchaUser();
|
||||||
|
|
||||||
|
//User is requesting a captcha test
|
||||||
|
if(content.equalsIgnoreCase("captcha pls") || content.equalsIgnoreCase("cpls")) {
|
||||||
|
JDA jda = Main.getJDA();
|
||||||
|
for(Guild g : jda.getGuilds()) {
|
||||||
|
if(g.isMember(capUser.getUser())) {
|
||||||
|
Member m = g.getMember(capUser.getUser());
|
||||||
|
if(PermUtil.isAdmin(m)) {
|
||||||
|
capUser.enableTestMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
captcha.handleResponse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleCaptcha(MessageReceivedEvent event, boolean isTest) {
|
|
||||||
PreUser preu;
|
|
||||||
PrivateChannel channel = event.getPrivateChannel();
|
|
||||||
User author = event.getAuthor();
|
|
||||||
ArrayList<PreUser> preus = Biscuit.getPreUsers(event.getAuthor());
|
|
||||||
if(!preus.isEmpty() || isTest) {
|
|
||||||
if(isTest) {
|
|
||||||
preu = PreUser.getTestUser(author);
|
|
||||||
}else {
|
|
||||||
preu = preus.get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
String response = leeway(event.getMessage().getContentDisplay());
|
|
||||||
|
|
||||||
if(preu.getToken() == null || !response.equalsIgnoreCase(preu.getToken())) {
|
|
||||||
String tlabel = "";
|
|
||||||
if(isTest) {
|
|
||||||
tlabel = "[TEST] ";
|
|
||||||
}
|
|
||||||
if(preu.getToken() != null) {
|
|
||||||
channel.sendMessage(tlabel + "Sorry! That's not quite right! Please try again.").queue();
|
|
||||||
}
|
|
||||||
Main.getMainBiscuit().log(tlabel + "Generating captcha challenge for user " + author.getName() + " " + author.getAsMention() + "...");
|
|
||||||
|
|
||||||
Cage cage = Main.getMainBiscuit().getCage();
|
|
||||||
|
|
||||||
preu.genToken();
|
|
||||||
|
|
||||||
OutputStream os;
|
|
||||||
try {
|
|
||||||
//os = new FileOutputStream("captcha/" + author.getId() + ".jpg", false);
|
|
||||||
if(!Main.isPlugin) {
|
|
||||||
os = new FileOutputStream("captcha/" + author.getId() + ".jpg", false);
|
|
||||||
}else {
|
|
||||||
File c = new File(PluginCore.plugin.getDataFolder(), "captcha/" + author.getId() + ".jpg");
|
|
||||||
os = new FileOutputStream(c, false);
|
|
||||||
}
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
cage.draw(preu.getToken() , os);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
os.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File captcha;
|
|
||||||
if(!Main.isPlugin) {
|
|
||||||
captcha = new File("captcha/" + author.getId() + ".jpg");
|
|
||||||
}else {
|
|
||||||
captcha = new File(PluginCore.plugin.getDataFolder(), "captcha/" + author.getId() + ".jpg");
|
|
||||||
}
|
|
||||||
channel.sendMessage(tlabel+ "Respond with the exact text in this image.").queue();
|
|
||||||
channel.sendFile(captcha).queue();
|
|
||||||
|
|
||||||
}else {
|
|
||||||
String tlabel = "";
|
|
||||||
if(isTest) {
|
|
||||||
tlabel = "[TEST] ";
|
|
||||||
}
|
|
||||||
|
|
||||||
Main.getMainBiscuit().log(BColor.YELLOW_BOLD + tlabel + author.getName() + " successfully completed a captcha challenge. Granting role.");
|
|
||||||
|
|
||||||
if(isTest) {
|
|
||||||
preu.setDone();
|
|
||||||
Main.getMainBiscuit().captchaLog("" + tlabel + " ``" + author.getName() +"`` " + author.getAsMention() + " successfully completed a captcha challenge. Test complete.");
|
|
||||||
testers.remove(author);
|
|
||||||
preu.remove();
|
|
||||||
}else {
|
|
||||||
for(PreUser p : preus) {
|
|
||||||
p.setDone();
|
|
||||||
Role newrole = null;
|
|
||||||
Role defaultrole = null;
|
|
||||||
|
|
||||||
Biscuit biscuit = p.getBiscuit();
|
|
||||||
|
|
||||||
biscuit.captchaLog("" + tlabel + " ``" + author.getName() +"`` " + author.getAsMention() + " successfully completed a captcha challenge. Granting role.");
|
|
||||||
|
|
||||||
Guild g = biscuit.getGuild();
|
|
||||||
for(Role r : g.getRoles()) {
|
|
||||||
if(r.getName().toLowerCase().contains(biscuit.getProperties().getCaptchaReward().toLowerCase())) {
|
|
||||||
newrole = r;
|
|
||||||
}else if(r.getName().toLowerCase().contains(biscuit.getProperties().getDefaultRole().toLowerCase())) {
|
|
||||||
defaultrole = r;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(newrole == null) {
|
|
||||||
biscuit.error("Cannot find captcha reward role!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(defaultrole == null) {
|
|
||||||
biscuit.error("Cannot find captcha default role!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Member member = g.getMemberById(author.getId());
|
|
||||||
|
|
||||||
g.addRoleToMember(member, newrole).complete();
|
|
||||||
g.removeRoleFromMember(member, defaultrole).complete();
|
|
||||||
p.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
channel.sendMessage(tlabel + "Well done, " + author.getAsMention() + "!").complete();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String leeway(String s) {
|
|
||||||
s = s.replace("0", "O");
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.logging.BColor;
|
import com.fpghoti.biscuit.logging.BColor;
|
||||||
|
import com.fpghoti.biscuit.user.CaptchaUser;
|
||||||
import com.fpghoti.biscuit.user.PreUser;
|
import com.fpghoti.biscuit.user.PreUser;
|
||||||
import com.jcabi.aspects.Async;
|
import com.jcabi.aspects.Async;
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ public class JoinListener extends ListenerAdapter {
|
||||||
|
|
||||||
if(biscuit.getProperties().captchaEnabled()) {
|
if(biscuit.getProperties().captchaEnabled()) {
|
||||||
biscuit.log(BColor.MAGENTA_BOLD + "Adding pre-join check for user " + user.getName() + " (" + user.getAsMention() + ")...");
|
biscuit.log(BColor.MAGENTA_BOLD + "Adding pre-join check for user " + user.getName() + " (" + user.getAsMention() + ")...");
|
||||||
new PreUser(event.getMember().getUser(), biscuit);
|
PreUser.getPreUser(CaptchaUser.getCaptchaUser(user), biscuit);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.getGuild().addRoleToMember(event.getMember(), role).queue();
|
event.getGuild().addRoleToMember(event.getMember(), role).queue();
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
package com.fpghoti.biscuit.listener;
|
package com.fpghoti.biscuit.listener;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.biscuit.BiscuitMessageStore;
|
import com.fpghoti.biscuit.biscuit.BiscuitMessageStore;
|
||||||
import com.fpghoti.biscuit.logging.BColor;
|
import com.fpghoti.biscuit.logging.BColor;
|
||||||
|
import com.fpghoti.biscuit.rest.MessageText;
|
||||||
import com.fpghoti.biscuit.util.ChatFilter;
|
import com.fpghoti.biscuit.util.ChatFilter;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
|
||||||
import net.dv8tion.jda.api.entities.Message.Attachment;
|
import net.dv8tion.jda.api.entities.Message.Attachment;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
|
|
||||||
public class MessageReceiveListener extends ListenerAdapter{
|
public class MessageReceiveListener extends ListenerAdapter{
|
||||||
|
|
||||||
|
/**TODO create new user class
|
||||||
|
* for keeping track of spammers
|
||||||
|
* and softmutes.
|
||||||
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGuildMessageReceived(GuildMessageReceivedEvent event){
|
public void onGuildMessageReceived(GuildMessageReceivedEvent event){
|
||||||
|
@ -75,13 +77,7 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||||
private boolean isNaughty(GuildMessageReceivedEvent event) {
|
private boolean isNaughty(GuildMessageReceivedEvent event) {
|
||||||
// TODO make staff filter configurable
|
// TODO make staff filter configurable
|
||||||
if(!event.getChannel().getName().toLowerCase().contains("staff") && ChatFilter.filter(event, false)){
|
if(!event.getChannel().getName().toLowerCase().contains("staff") && ChatFilter.filter(event, false)){
|
||||||
event.getChannel().sendMessage(event.getAuthor().getAsMention() + " This message contains words not appropriate for this channel.").queue(new Consumer<Message>()
|
MessageText.sendTimed(event.getChannel(), event.getAuthor().getAsMention() + " This message contains words not appropriate for this channel.", 3);
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void accept(Message msg){
|
|
||||||
msg.delete().submitAfter(3, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
event.getMessage().delete().submit();
|
event.getMessage().delete().submit();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -149,26 +145,14 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||||
store.addSpammer(event.getAuthor());
|
store.addSpammer(event.getAuthor());
|
||||||
store.removeSpamWarned(event.getAuthor());
|
store.removeSpamWarned(event.getAuthor());
|
||||||
event.getMessage().delete().submit();
|
event.getMessage().delete().submit();
|
||||||
event.getChannel().sendMessage("*Flagging " + mention + " as spam!*").queue(new Consumer<Message>()
|
MessageText.sendTimed(event.getChannel(), "*Flagging " + mention + " as spam!*", 3);
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void accept(Message msg){
|
|
||||||
msg.delete().reason("Automatic bot message removal").submitAfter(3, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
biscuit.log(BColor.MAGENTA_BOLD + "User " + event.getAuthor().getName() + " has been flagged as spam!");
|
biscuit.log(BColor.MAGENTA_BOLD + "User " + event.getAuthor().getName() + " has been flagged as spam!");
|
||||||
event.getMessage().delete().reason("Spam removal activated for " + mention).submit();
|
event.getMessage().delete().reason("Spam removal activated for " + mention).submit();
|
||||||
//User is spamming and has not been warned. Apply warning.
|
//User is spamming and has not been warned. Apply warning.
|
||||||
}else if(!store.isSpammer(event.getAuthor()) && !store.isSpamWarned(event.getAuthor())){
|
}else if(!store.isSpammer(event.getAuthor()) && !store.isSpamWarned(event.getAuthor())){
|
||||||
store.removeMessageCount(event.getAuthor());
|
store.removeMessageCount(event.getAuthor());
|
||||||
store.addSpamWarned(event.getAuthor());
|
store.addSpamWarned(event.getAuthor());
|
||||||
event.getChannel().sendMessage("**STOP spamming, " + mention + "! You have been warned!**").queue(new Consumer<Message>()
|
MessageText.sendTimed(event.getChannel(), "**STOP spamming, " + mention + "! You have been warned!**", 3);
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void accept(Message msg){
|
|
||||||
msg.delete().reason("Automatic bot message removal").submitAfter(3, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
biscuit.log(BColor.MAGENTA_BOLD + "User " + event.getAuthor().getName() + " has been warned for spam!");
|
biscuit.log(BColor.MAGENTA_BOLD + "User " + event.getAuthor().getName() + " has been warned for spam!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
package com.fpghoti.biscuit.rest;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||||
|
import net.dv8tion.jda.api.entities.PrivateChannel;
|
||||||
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
|
|
||||||
|
public class MessageText {
|
||||||
|
|
||||||
|
/** Sends an async message. **/
|
||||||
|
public static void send(TextChannel c, final String message) {
|
||||||
|
if(c == null) {
|
||||||
|
Main.getMainBiscuit().error("Message could not be sent to null channel: " + message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Biscuit b = Biscuit.getBiscuit(c.getGuild());
|
||||||
|
c.sendMessage(message).submit().whenComplete((msg, error) -> {
|
||||||
|
if(error != null) {
|
||||||
|
b.warn("Message did not send: " + message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sends an async private message. **/
|
||||||
|
public static void send(PrivateChannel c, final String message) {
|
||||||
|
if(c == null) {
|
||||||
|
Main.getMainBiscuit().error("Private message could not be sent to null channel: " + message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
c.sendMessage(message).submit().whenComplete((msg, error) -> {
|
||||||
|
if(error != null) {
|
||||||
|
Main.getMainBiscuit().warn("Private message did not send: " + message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sends an async message embed. **/
|
||||||
|
public static void send(TextChannel c, final MessageEmbed message) {
|
||||||
|
if(c == null) {
|
||||||
|
Main.getMainBiscuit().error("Message embed could not be sent to null channel: " + message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Biscuit b = Biscuit.getBiscuit(c.getGuild());
|
||||||
|
c.sendMessage(message).submit().whenComplete((msg, error) -> {
|
||||||
|
if(error != null) {
|
||||||
|
b.warn("Message embed did not send: " + message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sends an async message that will be deleted after a specified number of seconds. **/
|
||||||
|
public static void sendTimed(TextChannel c, final String message, final int seconds) {
|
||||||
|
if(c == null) {
|
||||||
|
Main.getMainBiscuit().error("Timed message could not be sent to null channel - Time: " + seconds + " Text: " + message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Biscuit b = Biscuit.getBiscuit(c.getGuild());
|
||||||
|
c.sendMessage(message).submit()
|
||||||
|
.whenComplete((msg, error) -> {
|
||||||
|
if(error != null) {
|
||||||
|
b.warn("Timed message did not send - Time: " + seconds + " Text: " + message);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.thenCompose((msg) -> msg.delete().submitAfter(seconds, TimeUnit.SECONDS))
|
||||||
|
.whenComplete((msg, error) -> {
|
||||||
|
if(error != null) {
|
||||||
|
b.warn("Timed message did not delete - Time: " + seconds + " Text: " + message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sends an async message embed that will be deleted after a specified number of seconds. **/
|
||||||
|
public static void sendTimed(TextChannel c, final MessageEmbed message, final int seconds) {
|
||||||
|
if(c == null) {
|
||||||
|
Main.getMainBiscuit().error("Timed message embed could not be sent to null channel - Time: " + seconds + " Text: " + message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Biscuit b = Biscuit.getBiscuit(c.getGuild());
|
||||||
|
c.sendMessage(message).submit()
|
||||||
|
.whenComplete((msg, error) -> {
|
||||||
|
if(error != null) {
|
||||||
|
b.warn("Timed message embed did not send - Time: " + seconds + " Text: " + message);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.thenCompose((msg) -> msg.delete().submitAfter(seconds, TimeUnit.SECONDS))
|
||||||
|
.whenComplete((msg, error) -> {
|
||||||
|
if(error != null) {
|
||||||
|
b.warn("Timed message embed did not delete - Time: " + seconds + " Text: " + message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,24 +0,0 @@
|
||||||
package com.fpghoti.biscuit.timer.task;
|
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
|
||||||
import com.fpghoti.biscuit.timer.BiscuitTimer;
|
|
||||||
import com.fpghoti.biscuit.user.PreUser;
|
|
||||||
|
|
||||||
public class StatusTimer extends BiscuitTimer{
|
|
||||||
|
|
||||||
public StatusTimer(Biscuit b){
|
|
||||||
biscuit = b;
|
|
||||||
delay = (long) 0;
|
|
||||||
period = (long) 60*1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
if(Main.ready) {
|
|
||||||
for(PreUser p : biscuit.getPreUsers()) {
|
|
||||||
p.decrementTime();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,217 @@
|
||||||
|
package com.fpghoti.biscuit.user;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.captcha.Captcha;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.JDA;
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
|
import net.dv8tion.jda.api.entities.User;
|
||||||
|
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
|
||||||
|
|
||||||
|
public class CaptchaUser implements Iterable<PreUser>{
|
||||||
|
|
||||||
|
private static ArrayList<CaptchaUser> captchaUsers = new ArrayList<CaptchaUser>();
|
||||||
|
|
||||||
|
public static void wipeCaptchaUsers() {
|
||||||
|
captchaUsers = new ArrayList<CaptchaUser>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean contains(User u) {
|
||||||
|
for(CaptchaUser c : captchaUsers) {
|
||||||
|
if(c.equals(u)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean contains(PreUser u) {
|
||||||
|
for(CaptchaUser c : captchaUsers) {
|
||||||
|
if(c.equals(u)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public static boolean contains(CaptchaUser u) {
|
||||||
|
for(CaptchaUser c : captchaUsers) {
|
||||||
|
if(c.equals(u)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CaptchaUser getCaptchaUser(User u) {
|
||||||
|
if(contains(u)) {
|
||||||
|
for(CaptchaUser c : captchaUsers) {
|
||||||
|
if(c.equals(u)) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
CaptchaUser c = new CaptchaUser(u);
|
||||||
|
captchaUsers.add(c);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
Main.getMainBiscuit().error("Could not get Captcha User.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void remove(CaptchaUser u) {
|
||||||
|
ArrayList<CaptchaUser> cu = new ArrayList<CaptchaUser>(captchaUsers);
|
||||||
|
for(CaptchaUser c : cu) {
|
||||||
|
if(c.equals(u)) {
|
||||||
|
captchaUsers.remove(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private User user;
|
||||||
|
private boolean testMode;
|
||||||
|
private Captcha captcha;
|
||||||
|
private ArrayList<PreUser> preUsers;
|
||||||
|
|
||||||
|
private CaptchaUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
this.testMode = false;
|
||||||
|
this.captcha = null;
|
||||||
|
this.preUsers = new ArrayList<PreUser>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<PreUser> iterator() {
|
||||||
|
return new ArrayList<PreUser>(preUsers).iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Captcha getCaptcha(PrivateMessageReceivedEvent event) {
|
||||||
|
captcha = Captcha.getUpdatedCaptcha(event);
|
||||||
|
return captcha;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCaptcha(Captcha c) {
|
||||||
|
captcha = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(User u) {
|
||||||
|
return user.getId().equals(u.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(PreUser u) {
|
||||||
|
return user.getId().equals(u.getUser().getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(CaptchaUser u) {
|
||||||
|
return user.getId().equals(u.getUser().getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean contains(Guild g) {
|
||||||
|
if(g == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for(PreUser u : preUsers) {
|
||||||
|
if(u.getBiscuit().getGuild().getId().equals(g.getId())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean contains(Biscuit b) {
|
||||||
|
return contains(b.getGuild());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return preUsers.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean inTestMode() {
|
||||||
|
return testMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enableTestMode() {
|
||||||
|
testMode = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disableTestMode() {
|
||||||
|
testMode = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shareGuild() {
|
||||||
|
JDA jda = Main.getJDA();
|
||||||
|
for(Guild g : jda.getGuilds()) {
|
||||||
|
if(g.isMember(user)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Guild> getSharedGuilds(){
|
||||||
|
ArrayList<Guild> guilds = new ArrayList<Guild>();
|
||||||
|
JDA jda = Main.getJDA();
|
||||||
|
for(Guild g : jda.getGuilds()) {
|
||||||
|
if(g.isMember(user)){
|
||||||
|
guilds.add(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return guilds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(PreUser u) {
|
||||||
|
if(u.getBiscuit() == null || u.getBiscuit().getGuild() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(contains(u.getBiscuit())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
preUsers.add(u);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(PreUser u) {
|
||||||
|
ArrayList<PreUser> ps = new ArrayList<PreUser>(preUsers);
|
||||||
|
for(PreUser p : ps) {
|
||||||
|
if(p.equals(u)) {
|
||||||
|
preUsers.remove(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PreUser get(Guild g) {
|
||||||
|
if(g == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for(PreUser u : preUsers) {
|
||||||
|
if(u.getBiscuit().getGuild().getId().equals(g.getId())) {
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PreUser get(Biscuit b) {
|
||||||
|
return get(b.getGuild());
|
||||||
|
}
|
||||||
|
|
||||||
|
// public PreUser getTestUser() {
|
||||||
|
// if(testUser == null) {
|
||||||
|
// PreUser preu = PreUser.makeTestUser(this);
|
||||||
|
// testUser = preu;
|
||||||
|
// }
|
||||||
|
// return testUser;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
public Captcha getCaptcha() {
|
||||||
|
return captcha;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,52 +1,42 @@
|
||||||
package com.fpghoti.biscuit.user;
|
package com.fpghoti.biscuit.user;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.PluginCore;
|
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
import com.github.cage.Cage;
|
|
||||||
|
|
||||||
import net.dv8tion.jda.api.JDA;
|
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.entities.User;
|
import net.dv8tion.jda.api.entities.User;
|
||||||
|
|
||||||
public class PreUser {
|
public class PreUser {
|
||||||
|
|
||||||
public static CopyOnWriteArrayList<PreUser> testusers = new CopyOnWriteArrayList<PreUser>();
|
public static PreUser getPreUser(CaptchaUser capUser, Biscuit biscuit) {
|
||||||
|
if(capUser == null) {
|
||||||
public static PreUser getTestUser(User u) {
|
Main.getMainBiscuit().error("Cannot get PreUser (Invalid Captcha User).");
|
||||||
for(PreUser pu : testusers) {
|
return null;
|
||||||
if(pu.getUser().getId().equals(u.getId())) {
|
|
||||||
return pu;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
if(biscuit == null) {
|
||||||
}
|
Main.getMainBiscuit().error("Cannot get PreUser (Invalid Biscuit Instance).");
|
||||||
|
return null;
|
||||||
public static boolean hasTestUser(User u) {
|
}
|
||||||
return getTestUser(u) != null;
|
if(capUser.contains(biscuit)) {
|
||||||
|
return capUser.get(biscuit);
|
||||||
|
}
|
||||||
|
PreUser preu = new PreUser(capUser, biscuit, false);
|
||||||
|
capUser.add(preu);
|
||||||
|
return preu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CaptchaUser capUser;
|
||||||
private User user;
|
private User user;
|
||||||
private String token;
|
|
||||||
private int timeLeft;
|
private int timeLeft;
|
||||||
private boolean done;
|
private boolean done;
|
||||||
private boolean test;
|
private boolean test;
|
||||||
private Biscuit biscuit;
|
private Biscuit biscuit;
|
||||||
|
|
||||||
public PreUser(User user, Biscuit biscuit) {
|
private PreUser(CaptchaUser capUser, Biscuit biscuit, boolean test) {
|
||||||
this(user, biscuit, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PreUser(User user, Biscuit biscuit, boolean test) {
|
|
||||||
this.test = test;
|
this.test = test;
|
||||||
this.user = user;
|
this.capUser = capUser;
|
||||||
this.token = null;
|
this.user = capUser.getUser();
|
||||||
this.biscuit = biscuit;
|
this.biscuit = biscuit;
|
||||||
this.done = false;
|
this.done = false;
|
||||||
this.timeLeft = biscuit.getProperties().noCaptchaKickTime() + 1;
|
this.timeLeft = biscuit.getProperties().noCaptchaKickTime() + 1;
|
||||||
|
@ -62,14 +52,13 @@ public class PreUser {
|
||||||
public User getUser() {
|
public User getUser() {
|
||||||
return this.user;
|
return this.user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getToken() {
|
public boolean isTestUser() {
|
||||||
return this.token;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void genToken() {
|
public CaptchaUser getCaptchaUser() {
|
||||||
Cage cage = biscuit.getCage();
|
return this.capUser;
|
||||||
token = cage.getTokenGenerator().next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDone() {
|
public void setDone() {
|
||||||
|
@ -81,7 +70,7 @@ public class PreUser {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decrementTime() {
|
public void decrementTime() {
|
||||||
if(!shareGuild()) {
|
if(!capUser.shareGuild()) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -108,52 +97,50 @@ public class PreUser {
|
||||||
msg = msg + " " + invite;
|
msg = msg + " " + invite;
|
||||||
}
|
}
|
||||||
final String fmsg = msg;
|
final String fmsg = msg;
|
||||||
user.openPrivateChannel().flatMap(channel -> channel.sendMessage(fmsg)).complete();
|
user.openPrivateChannel().flatMap(channel -> channel.sendMessage(fmsg)).submit().whenComplete((message, error) -> {
|
||||||
|
if (error != null) {
|
||||||
|
biscuit.log("Unable to private message user " + user.getName() +".");
|
||||||
|
}
|
||||||
|
kick();
|
||||||
|
});
|
||||||
|
}else {
|
||||||
|
kick();
|
||||||
}
|
}
|
||||||
biscuit.getGuild().kick(user.getId()).submit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
remove();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shareGuild() {
|
public void kick() {
|
||||||
JDA jda = biscuit.getJDA();
|
remove();
|
||||||
for(Guild g : jda.getGuilds()) {
|
biscuit.getGuild().kick(user.getId()).submit();
|
||||||
if(g.isMember(user)){
|
}
|
||||||
return true;
|
|
||||||
}
|
public boolean equals(User u) {
|
||||||
}
|
return user.getId().equals(u.getId());
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Guild> getGuilds(){
|
public boolean equals(PreUser u) {
|
||||||
ArrayList<Guild> guilds = new ArrayList<Guild>();
|
return user.getId().equals(u.getUser().getId());
|
||||||
JDA jda = biscuit.getJDA();
|
}
|
||||||
for(Guild g : jda.getGuilds()) {
|
|
||||||
if(g.isMember(user)){
|
public boolean equals(CaptchaUser u) {
|
||||||
guilds.add(g);
|
return user.getId().equals(u.getUser().getId());
|
||||||
}
|
|
||||||
}
|
|
||||||
return guilds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove() {
|
public void remove() {
|
||||||
setDone();
|
setDone();
|
||||||
biscuit.log("Removing captcha data for user " + user.getName() + " " + user.getAsMention());
|
biscuit.log("Removing captcha data for user " + user.getName() + " " + user.getAsMention());
|
||||||
File captcha;
|
if(capUser.getCaptcha() != null) {
|
||||||
if(!Main.isPlugin) {
|
capUser.getCaptcha().removeFiles();
|
||||||
captcha = new File("captcha/" + user.getId() + ".jpg");
|
|
||||||
}else {
|
|
||||||
captcha = new File(PluginCore.plugin.getDataFolder(), "captcha/" + user.getId() + ".jpg");
|
|
||||||
}
|
}
|
||||||
token = null;
|
|
||||||
captcha.delete();
|
|
||||||
biscuit.removePreUser(this);
|
biscuit.removePreUser(this);
|
||||||
testusers.remove(this);
|
if(biscuit.preUserExists(user)) {
|
||||||
|
biscuit.error("CAPTCHA ERROR: PreUser exists after removal");
|
||||||
|
}
|
||||||
|
capUser.remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue