Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c67bf65d3 | ||
|
|
984a081ccf | ||
|
|
270b945408 | ||
|
|
fb0d5de6e3 |
+2
-2
@@ -12,6 +12,7 @@
|
||||
<classpathentry kind="lib" path="lib/httpclient-4.5.5.jar"/>
|
||||
<classpathentry kind="lib" path="lib/httpcore-4.4.9.jar"/>
|
||||
<classpathentry kind="lib" path="lib/WolframAlpha-1.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/JDA-3.7.1_385-withDependencies.jar"/>
|
||||
<classpathentry kind="lib" path="lib/sqlite-jdbc-3.23.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/slf4j-jdk14-1.7.25.jar"/>
|
||||
<classpathentry kind="lib" path="lib/twitter4j-core-4.0.7-javadoc.jar"/>
|
||||
@@ -26,7 +27,6 @@
|
||||
<classpathentry kind="lib" path="lib/google-http-client-1.32.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/google-api-services-youtube-v3-rev212-1.25.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/nanohttpd-2.3.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/LavaPlayerJar-1.3.50-jar-with-dependencies.jar"/>
|
||||
<classpathentry kind="lib" path="lib/JDA-4.2.0_168-withDependencies.jar"/>
|
||||
<classpathentry kind="lib" path="G:/Shared/Coding/Java/workspace/ProKitty/lib/LavaPlayerJar-1.3.50-jar-with-dependencies.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -68,5 +68,3 @@ rP\.txt
|
||||
*.log
|
||||
|
||||
cloc\.exe
|
||||
|
||||
beanImage.png
|
||||
|
||||
@@ -3,4 +3,4 @@ Fun and useful Discord bot designed to be able searching websites, playing games
|
||||
|
||||
This repo is an eclipse project, and can be opened in the IDE directly. Authentication keys will need to be placed in a file called `Ref.java` at `src/offline/`. This folder isn't present in this repository by default.
|
||||
|
||||
If you're looking to contribute, feel free to submit a pull request! Take a look at the styleguide to get some pointers on formatting for this repo!
|
||||
If you're looking to contribute, feel free to submit a pull request! Take a look at the styleguide to get some pointers on formatting for this repo!
|
||||
|
||||
+1
-5
@@ -1,6 +1,5 @@
|
||||
"Type","Key","Value"
|
||||
"Globals","mode (dev or release)","dev"
|
||||
"Globals","activity","with a laser pointer"
|
||||
"Localized Commands","beans",""
|
||||
"Localized Commands","benchmark, bench",""
|
||||
"Localized Commands","bet",""
|
||||
@@ -58,8 +57,6 @@
|
||||
"Localized Commands","work",""
|
||||
"Localized Commands","yeet",""
|
||||
"Localized Strings","AddGuildRoleFailure","Failed to add %s to %s"
|
||||
"Localized Strings","BeansImageBottomText","BEANS"
|
||||
"Localized Strings","BeansImageTopText","YOU HAVE"
|
||||
"Localized Strings","BeansShowDisplay","You have %s beans!"
|
||||
"Localized Strings","BeansShowInfo","Displays how many beans you have"
|
||||
"Localized Strings","BeansShowMentioned","I took a look and %sbeans!"
|
||||
@@ -73,8 +70,7 @@
|
||||
"Localized Strings","BetBeansNotValid","That's not a valid bet!"
|
||||
"Localized Strings","BetBeansWin","You won %s beans!"
|
||||
"Localized Strings","BetHistoryInfo","Gives how many beans I've ~~stolen~~ won from your bets!"
|
||||
"Localized Strings","BetHistoryOptionalPNGPath",""
|
||||
"Localized Strings","BetHistoryOutput","I have %s beans from betting!"
|
||||
"Localized Strings","BetHistoryOutput","I have %s treats from betting!"
|
||||
"Localized Strings","BlurryInfo","Blurs your icon or the icon of a friend you mentioned"
|
||||
"Localized Strings","BoopInfo","Kitty will react with a counter"
|
||||
"Localized Strings","BoopMultiple","%s booped several others - %s!"
|
||||
|
||||
|
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
Binary file not shown.
+3
-3
@@ -1,4 +1,4 @@
|
||||
package commands.beans;
|
||||
package commands.general;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
@@ -118,9 +118,9 @@ public class CommandBeansShow extends Command
|
||||
Font beanFont = new Font("font", Font.BOLD, 45);
|
||||
beanGraphics.setFont(beanFont);
|
||||
|
||||
drawCenteredString(beanGraphics, LocStrings.stub("BeansImageTopText"), rect, beanFont, .25);
|
||||
drawCenteredString(beanGraphics, "YOU HAVE", rect, beanFont, .25);
|
||||
drawCenteredString(beanGraphics, "" + beans, rect, beanFont, .5);
|
||||
drawCenteredString(beanGraphics, LocStrings.stub("BeansImageBottomText"), rect, beanFont, .75);
|
||||
drawCenteredString(beanGraphics, "BEANS!", rect, beanFont, .75);
|
||||
|
||||
ImageIO.write(beanImage, "PNG", new File("beanImage.png"));
|
||||
return new File("beanImage.png");
|
||||
@@ -1,4 +1,4 @@
|
||||
package commands.beans;
|
||||
package commands.general;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
+24
-44
@@ -1,45 +1,25 @@
|
||||
package commands.beans;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import utils.GlobalLog;
|
||||
import utils.LogFilter;
|
||||
|
||||
public class CommandBetHistory extends Command
|
||||
{
|
||||
public CommandBetHistory(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("BetHistoryInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
// Send primary response
|
||||
res.send(String.format(LocStrings.stub("BetHistoryOutput"), guild.beans.get()));
|
||||
|
||||
// Look up extra information to see if we ahve a flair image
|
||||
String optional = LocStrings.stub("BetHistoryOptionalPNGPath");
|
||||
if(optional != null && optional.length() > 0)
|
||||
{
|
||||
File responseImage = new File(optional);
|
||||
if(responseImage.exists())
|
||||
{
|
||||
res.sendFile(responseImage, ".png");
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalLog.warn(LogFilter.Command, "Optional PNG image for bet history was specified, but the file could not be found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandBetHistory extends Command
|
||||
{
|
||||
public CommandBetHistory(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("BetHistoryInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
res.send(String.format(LocStrings.stub("BetHistoryOutput"), guild.beans.get()));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package commands.images;
|
||||
package commands.general;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -1,71 +1,71 @@
|
||||
package commands.images;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import utils.ImageOverlayBuilder;
|
||||
import utils.ImageUtils;
|
||||
|
||||
public class CommandCatch extends Command
|
||||
{
|
||||
// Required constructor
|
||||
public CommandCatch(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
private static Long num = 0l;
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("CatchInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String name = null;
|
||||
File catchFile = null;
|
||||
File catcheeFile = null;
|
||||
|
||||
synchronized(num)
|
||||
{
|
||||
name = "catch_" + num + ".gif";
|
||||
++num;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
KittyUser person = null;
|
||||
|
||||
if(input.mentions == null)
|
||||
person = user;
|
||||
else
|
||||
person = input.mentions[0];
|
||||
|
||||
String catchFilename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||
if(catchFilename == null)
|
||||
return;
|
||||
|
||||
catcheeFile = new File(catchFilename);
|
||||
ImageOverlayBuilder builder = new ImageOverlayBuilder("assets/catch/frames/", "catch ", 92, 18);
|
||||
builder.overlay(ImageIO.read(catcheeFile), name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
catchFile = new File (name);
|
||||
res.sendFile(catchFile, "gif");
|
||||
|
||||
// Thread cleanup...
|
||||
ImageUtils.blockingFileDelete(catchFile);
|
||||
ImageUtils.blockingFileDelete(catcheeFile);
|
||||
}
|
||||
}
|
||||
package commands.general;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import utils.ImageOverlayBuilder;
|
||||
import utils.ImageUtils;
|
||||
|
||||
public class CommandCatch extends Command
|
||||
{
|
||||
// Required constructor
|
||||
public CommandCatch(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
private static Long num = 0l;
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("CatchInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String name = null;
|
||||
File catchFile = null;
|
||||
File catcheeFile = null;
|
||||
|
||||
synchronized(num)
|
||||
{
|
||||
name = "catch_" + num + ".gif";
|
||||
++num;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
KittyUser person = null;
|
||||
|
||||
if(input.mentions == null)
|
||||
person = user;
|
||||
else
|
||||
person = input.mentions[0];
|
||||
|
||||
String catchFilename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||
if(catchFilename == null)
|
||||
return;
|
||||
|
||||
catcheeFile = new File(catchFilename);
|
||||
ImageOverlayBuilder builder = new ImageOverlayBuilder("assets/catch/frames/", "catch ", 92, 18);
|
||||
builder.overlay(ImageIO.read(catcheeFile), name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
catchFile = new File (name);
|
||||
res.sendFile(catchFile, "gif");
|
||||
|
||||
// Thread cleanup...
|
||||
ImageUtils.blockingFileDelete(catchFile);
|
||||
ImageUtils.blockingFileDelete(catcheeFile);
|
||||
}
|
||||
}
|
||||
@@ -43,4 +43,4 @@ public class CommandChoose extends Command
|
||||
|
||||
res.send(String.format(LocStrings.stub("ChooseChoice"), (choices[(int) (Math.random()*choices.length)]).toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package commands.network;
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
@@ -1,35 +1,35 @@
|
||||
package commands.dev;
|
||||
|
||||
import core.Command;
|
||||
import core.Constants;
|
||||
import core.DatabaseManager;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyEmbed;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandDBFlush extends Command
|
||||
{
|
||||
public CommandDBFlush(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("DBFlushInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
int numUpdated = DatabaseManager.instance.upkeep();
|
||||
|
||||
KittyEmbed embed = new KittyEmbed();
|
||||
embed.title = "Database queue flushed";
|
||||
embed.descriptionText = "**Dirty:** " + numUpdated;
|
||||
embed.color = Constants.ColorDefault;
|
||||
|
||||
res.send(embed);
|
||||
}
|
||||
}
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.Constants;
|
||||
import core.DatabaseManager;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyEmbed;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandDBFlush extends Command
|
||||
{
|
||||
public CommandDBFlush(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("DBFlushInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
int numUpdated = DatabaseManager.instance.upkeep();
|
||||
|
||||
KittyEmbed embed = new KittyEmbed();
|
||||
embed.title = "Database queue flushed";
|
||||
embed.descriptionText = "**Dirty:** " + numUpdated;
|
||||
embed.color = Constants.ColorDefault;
|
||||
|
||||
res.send(embed);
|
||||
}
|
||||
}
|
||||
@@ -1,43 +1,43 @@
|
||||
package commands.dev;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import core.Command;
|
||||
import core.Constants;
|
||||
import core.DatabaseManager;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyEmbed;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandDBStats extends Command
|
||||
{
|
||||
DateFormat dateFormat;
|
||||
public CommandDBStats(KittyRole level, KittyRating rating)
|
||||
{
|
||||
super(level, rating);
|
||||
dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("DBStatsInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
KittyEmbed embed = new KittyEmbed();
|
||||
embed.title = "Database Info";
|
||||
embed.descriptionText = "**Tracked Items:** " + DatabaseManager.instance.getTrackedObjectsSize();
|
||||
embed.descriptionText += "\n";
|
||||
embed.descriptionText += "**Last Upkeep:** " + dateFormat.format(DatabaseManager.instance.getLastUpkeep()) + " UTC-7";
|
||||
embed.color = Constants.ColorDefault;
|
||||
|
||||
res.send(embed);
|
||||
}
|
||||
}
|
||||
package commands.general;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import core.Command;
|
||||
import core.Constants;
|
||||
import core.DatabaseManager;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyEmbed;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandDBStats extends Command
|
||||
{
|
||||
DateFormat dateFormat;
|
||||
public CommandDBStats(KittyRole level, KittyRating rating)
|
||||
{
|
||||
super(level, rating);
|
||||
dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("DBStatsInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
KittyEmbed embed = new KittyEmbed();
|
||||
embed.title = "Database Info";
|
||||
embed.descriptionText = "**Tracked Items:** " + DatabaseManager.instance.getTrackedObjectsSize();
|
||||
embed.descriptionText += "\n";
|
||||
embed.descriptionText += "**Last Upkeep:** " + dateFormat.format(DatabaseManager.instance.getLastUpkeep()) + " UTC-7";
|
||||
embed.color = Constants.ColorDefault;
|
||||
|
||||
res.send(embed);
|
||||
}
|
||||
}
|
||||
+71
-71
@@ -1,71 +1,71 @@
|
||||
package commands.images;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import utils.ImageOverlayBuilder;
|
||||
import utils.ImageUtils;
|
||||
|
||||
public class CommandDefaultDance extends Command
|
||||
{
|
||||
// Required constructor
|
||||
public CommandDefaultDance(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
private static Long num = 0l;
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("DefaultDanceInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String name = null;
|
||||
File dancerFile = null;
|
||||
File danceeFile = null;
|
||||
|
||||
synchronized(num)
|
||||
{
|
||||
name = "defaultDance_" + num + ".gif";
|
||||
++num;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
KittyUser person = null;
|
||||
|
||||
if(input.mentions == null)
|
||||
person = user;
|
||||
else
|
||||
person = input.mentions[0];
|
||||
|
||||
String yeeteeFilename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||
if(yeeteeFilename == null)
|
||||
return;
|
||||
|
||||
danceeFile = new File(yeeteeFilename);
|
||||
ImageOverlayBuilder builder = new ImageOverlayBuilder("assets/dance/default/", "defaultDance ", 118, 18);
|
||||
builder.overlay(ImageIO.read(danceeFile), name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
dancerFile = new File (name);
|
||||
res.sendFile(dancerFile, "gif");
|
||||
|
||||
// Thread cleanup...
|
||||
ImageUtils.blockingFileDelete(dancerFile);
|
||||
ImageUtils.blockingFileDelete(danceeFile);
|
||||
}
|
||||
}
|
||||
package commands.general;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import utils.ImageOverlayBuilder;
|
||||
import utils.ImageUtils;
|
||||
|
||||
public class CommandDefaultDance extends Command
|
||||
{
|
||||
// Required constructor
|
||||
public CommandDefaultDance(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
private static Long num = 0l;
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("DefaultDanceInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String name = null;
|
||||
File dancerFile = null;
|
||||
File danceeFile = null;
|
||||
|
||||
synchronized(num)
|
||||
{
|
||||
name = "defaultDance_" + num + ".gif";
|
||||
++num;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
KittyUser person = null;
|
||||
|
||||
if(input.mentions == null)
|
||||
person = user;
|
||||
else
|
||||
person = input.mentions[0];
|
||||
|
||||
String yeeteeFilename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||
if(yeeteeFilename == null)
|
||||
return;
|
||||
|
||||
danceeFile = new File(yeeteeFilename);
|
||||
ImageOverlayBuilder builder = new ImageOverlayBuilder("assets/dance/default/", "defaultDance ", 118, 18);
|
||||
builder.overlay(ImageIO.read(danceeFile), name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
dancerFile = new File (name);
|
||||
res.sendFile(dancerFile, "gif");
|
||||
|
||||
// Thread cleanup...
|
||||
ImageUtils.blockingFileDelete(dancerFile);
|
||||
ImageUtils.blockingFileDelete(danceeFile);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package commands.network;
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
@@ -1,33 +1,33 @@
|
||||
package commands.dev;
|
||||
|
||||
import core.*;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandDoWork extends Command
|
||||
{
|
||||
// Required constructor
|
||||
public CommandDoWork(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("DoWorkInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
long thispieceofshit = 0;
|
||||
for(int i = 0; i < 200000000 + Math.random() * 30; i ++)
|
||||
{
|
||||
thispieceofshit += Math.log((double)i);
|
||||
}
|
||||
|
||||
res.send(LocStrings.stub("DoWorkFinished"));
|
||||
}
|
||||
package commands.general;
|
||||
|
||||
import core.*;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandDoWork extends Command
|
||||
{
|
||||
// Required constructor
|
||||
public CommandDoWork(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("DoWorkInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
long thispieceofshit = 0;
|
||||
for(int i = 0; i < 200000000 + Math.random() * 30; i ++)
|
||||
{
|
||||
thispieceofshit += Math.log((double)i);
|
||||
}
|
||||
|
||||
res.send(LocStrings.stub("DoWorkFinished"));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package commands.network;
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package commands.network;
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package commands.beans;
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
+135
-135
@@ -1,136 +1,136 @@
|
||||
package commands.dev;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import core.Stats;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import utils.GlobalLog;
|
||||
import utils.ImageUtils;
|
||||
|
||||
public class CommandHelpBuilder extends Command {
|
||||
|
||||
public CommandHelpBuilder(KittyRole role, KittyRating rating) {
|
||||
super(role, rating);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("HelpBuilderInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
// Holds command groups
|
||||
HashMap<KittyRole, ArrayList<Command>> commandsByRole = new HashMap<KittyRole, ArrayList<Command>>();
|
||||
|
||||
// Populate w/ empty array lists
|
||||
for(int i = 0; i < KittyRole.values().length; ++i)
|
||||
commandsByRole.put(KittyRole.values()[i], new ArrayList<Command>());
|
||||
|
||||
// Sort commands out
|
||||
ArrayList<Command> commands = Stats.instance.getAllCommands();
|
||||
for(int i = 0; i < commands.size(); ++i)
|
||||
{
|
||||
Command current = commands.get(i);
|
||||
commandsByRole.get(current.requiredRole()).add(current);
|
||||
}
|
||||
|
||||
// Format outstring and send it back for now
|
||||
String out = "";
|
||||
out += populateSection(KittyRole.Admin, commandsByRole, true) + "\n";
|
||||
out += populateSection(KittyRole.Mod, commandsByRole, true) + "\n";
|
||||
out += populateSection(KittyRole.General, commandsByRole, false) + "\n";
|
||||
|
||||
// Write out file
|
||||
String filename = "buildhelp_out.txt";
|
||||
|
||||
try {
|
||||
PrintWriter writer = new PrintWriter(filename);
|
||||
writer.println(out);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
GlobalLog.error(e.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
File file = new File(filename);
|
||||
res.sendFile(file, "txt");
|
||||
ImageUtils.blockingFileDelete(file);
|
||||
}
|
||||
|
||||
// Generates the section for a specific role, optionally adding spacing after for another section
|
||||
private String populateSection(KittyRole role, HashMap<KittyRole, ArrayList<Command>> commandsByRole, boolean delimitSection)
|
||||
{
|
||||
// Formatting variables
|
||||
final String headerStart = "<h2>";
|
||||
final String headerEnd = "</h2>\n";
|
||||
final String sectionStart = "<p>\n";
|
||||
final String sectionEnd = "</p>";
|
||||
final String indent = " ";
|
||||
final String leadStart = "<code>";
|
||||
final String leadEnd = "</code>";
|
||||
final String leadFollow = ": ";
|
||||
final String lineDelimiter = "<br/>\n";
|
||||
final String sectionDelimiter = "\n\n";
|
||||
|
||||
String accumulated = "";
|
||||
ArrayList<Command> commands = commandsByRole.get(role);
|
||||
ArrayList<Command> commandsSoFar = new ArrayList<Command>();
|
||||
if(commands.size() > 0)
|
||||
{
|
||||
String roleStr = role.toString();
|
||||
roleStr = roleStr.substring(0, 1).toUpperCase() + roleStr.toLowerCase().substring(1);
|
||||
|
||||
// Section header
|
||||
accumulated += headerStart + roleStr + " commands" + headerEnd;
|
||||
accumulated += sectionStart;
|
||||
|
||||
// Section content
|
||||
for(int i = 0; i < commands.size(); ++i)
|
||||
{
|
||||
accumulated += indent;
|
||||
Command command = commands.get(i);
|
||||
|
||||
// Skip multiples
|
||||
if(commandsSoFar.contains(command))
|
||||
continue;
|
||||
else
|
||||
commandsSoFar.add(command);
|
||||
|
||||
// Write out all the keys and the help text
|
||||
ArrayList<String> keys = command.registeredNames();
|
||||
for(int j = 0; j < keys.size(); ++j)
|
||||
{
|
||||
if(j != 0)
|
||||
accumulated += ", ";
|
||||
|
||||
accumulated += leadStart + keys.get(j) + leadEnd;
|
||||
}
|
||||
|
||||
accumulated += leadFollow + commands.get(i).getHelpText() + lineDelimiter;;
|
||||
}
|
||||
|
||||
accumulated += sectionEnd;
|
||||
|
||||
// Add spaces after if needed
|
||||
if(delimitSection)
|
||||
accumulated += sectionDelimiter;
|
||||
}
|
||||
|
||||
return accumulated;
|
||||
}
|
||||
package commands.general;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import core.Stats;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import utils.GlobalLog;
|
||||
import utils.ImageUtils;
|
||||
|
||||
public class CommandHelpBuilder extends Command {
|
||||
|
||||
public CommandHelpBuilder(KittyRole role, KittyRating rating) {
|
||||
super(role, rating);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("HelpBuilderInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
// Holds command groups
|
||||
HashMap<KittyRole, ArrayList<Command>> commandsByRole = new HashMap<KittyRole, ArrayList<Command>>();
|
||||
|
||||
// Populate w/ empty array lists
|
||||
for(int i = 0; i < KittyRole.values().length; ++i)
|
||||
commandsByRole.put(KittyRole.values()[i], new ArrayList<Command>());
|
||||
|
||||
// Sort commands out
|
||||
ArrayList<Command> commands = Stats.instance.getAllCommands();
|
||||
for(int i = 0; i < commands.size(); ++i)
|
||||
{
|
||||
Command current = commands.get(i);
|
||||
commandsByRole.get(current.requiredRole()).add(current);
|
||||
}
|
||||
|
||||
// Format outstring and send it back for now
|
||||
String out = "";
|
||||
out += populateSection(KittyRole.Admin, commandsByRole, true) + "\n";
|
||||
out += populateSection(KittyRole.Mod, commandsByRole, true) + "\n";
|
||||
out += populateSection(KittyRole.General, commandsByRole, false) + "\n";
|
||||
|
||||
// Write out file
|
||||
String filename = "buildhelp_out.txt";
|
||||
|
||||
try {
|
||||
PrintWriter writer = new PrintWriter(filename);
|
||||
writer.println(out);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
GlobalLog.error(e.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
File file = new File(filename);
|
||||
res.sendFile(file, "txt");
|
||||
ImageUtils.blockingFileDelete(file);
|
||||
}
|
||||
|
||||
// Generates the section for a specific role, optionally adding spacing after for another section
|
||||
private String populateSection(KittyRole role, HashMap<KittyRole, ArrayList<Command>> commandsByRole, boolean delimitSection)
|
||||
{
|
||||
// Formatting variables
|
||||
final String headerStart = "<h2>";
|
||||
final String headerEnd = "</h2>\n";
|
||||
final String sectionStart = "<p>\n";
|
||||
final String sectionEnd = "</p>";
|
||||
final String indent = " ";
|
||||
final String leadStart = "<code>";
|
||||
final String leadEnd = "</code>";
|
||||
final String leadFollow = ": ";
|
||||
final String lineDelimiter = "<br/>\n";
|
||||
final String sectionDelimiter = "\n\n";
|
||||
|
||||
String accumulated = "";
|
||||
ArrayList<Command> commands = commandsByRole.get(role);
|
||||
ArrayList<Command> commandsSoFar = new ArrayList<Command>();
|
||||
if(commands.size() > 0)
|
||||
{
|
||||
String roleStr = role.toString();
|
||||
roleStr = roleStr.substring(0, 1).toUpperCase() + roleStr.toLowerCase().substring(1);
|
||||
|
||||
// Section header
|
||||
accumulated += headerStart + roleStr + " commands" + headerEnd;
|
||||
accumulated += sectionStart;
|
||||
|
||||
// Section content
|
||||
for(int i = 0; i < commands.size(); ++i)
|
||||
{
|
||||
accumulated += indent;
|
||||
Command command = commands.get(i);
|
||||
|
||||
// Skip multiples
|
||||
if(commandsSoFar.contains(command))
|
||||
continue;
|
||||
else
|
||||
commandsSoFar.add(command);
|
||||
|
||||
// Write out all the keys and the help text
|
||||
ArrayList<String> keys = command.registeredNames();
|
||||
for(int j = 0; j < keys.size(); ++j)
|
||||
{
|
||||
if(j != 0)
|
||||
accumulated += ", ";
|
||||
|
||||
accumulated += leadStart + keys.get(j) + leadEnd;
|
||||
}
|
||||
|
||||
accumulated += leadFollow + commands.get(i).getHelpText() + lineDelimiter;;
|
||||
}
|
||||
|
||||
accumulated += sectionEnd;
|
||||
|
||||
// Add spaces after if needed
|
||||
if(delimitSection)
|
||||
accumulated += sectionDelimiter;
|
||||
}
|
||||
|
||||
return accumulated;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package commands.dev;
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
@@ -1,4 +1,4 @@
|
||||
package commands.network;
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
@@ -7,7 +7,7 @@ import core.Command;
|
||||
import core.Constants;
|
||||
import core.DatabaseManager;
|
||||
import core.LocStrings;
|
||||
import core.ObjectBuilder;
|
||||
import core.ObjectBuilderFactory;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyEmbed;
|
||||
import dataStructures.KittyGuild;
|
||||
@@ -98,7 +98,7 @@ public class CommandLeaderboard extends Command
|
||||
{
|
||||
// Only now that we've sorted do we do the full construction and caching of users
|
||||
Pair<Long, String> userPair = users.get(i);
|
||||
KittyUser cachedUser = ObjectBuilder.getKittyUser(guildID, userPair.Second);
|
||||
KittyUser cachedUser = ObjectBuilderFactory.getKittyUser(guildID, userPair.Second);
|
||||
|
||||
if(cachedUser == null)
|
||||
continue;
|
||||
|
||||
+105
-105
@@ -1,105 +1,105 @@
|
||||
package commands.images;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import utils.ImageUtils;
|
||||
|
||||
public class CommandPerish extends Command
|
||||
{
|
||||
public CommandPerish(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("PerishInfo"); };
|
||||
|
||||
private static Long num = 0l;
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String name = null;
|
||||
String filename = null;
|
||||
File preProcessed = null;
|
||||
File postProcessed = null;
|
||||
|
||||
synchronized(num)
|
||||
{
|
||||
name = "perish_" + num + ".png";
|
||||
++num;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
filename = ImageUtils.downloadFromURL(input.args.split(" ")[0], ".png");
|
||||
preProcessed = new File(filename);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
KittyUser person = user;
|
||||
if(input.mentions != null)
|
||||
person = input.mentions[0];
|
||||
|
||||
filename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||
if(filename == null)
|
||||
return;
|
||||
}
|
||||
preProcessed = new File(filename);
|
||||
applyTintEffect(ImageIO.read(preProcessed), name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
postProcessed = new File(name);
|
||||
res.sendFile(postProcessed, "png");
|
||||
|
||||
ImageUtils.blockingFileDelete(preProcessed);
|
||||
ImageUtils.blockingFileDelete(postProcessed);
|
||||
}
|
||||
|
||||
private static void applyTintEffect(BufferedImage image, String name) throws IOException
|
||||
{
|
||||
// Iterate over each column left to right and touch up each pixel
|
||||
for(int x = 0; x < image.getWidth(); ++x)
|
||||
{
|
||||
for(int y = 0; y < image.getHeight(); ++y)
|
||||
{
|
||||
Color c = new Color(image.getRGB(x, y), true);
|
||||
|
||||
int red = c.getRed();
|
||||
red += 100;
|
||||
if(red > 255)
|
||||
red = 255;
|
||||
|
||||
int green = c.getGreen();
|
||||
|
||||
int blue = c.getBlue();
|
||||
blue += 20;
|
||||
if(blue > 255)
|
||||
blue = 255;
|
||||
|
||||
Color tinted = new Color(red, green, blue, c.getAlpha());
|
||||
image.setRGB(x, y, tinted.getRGB());
|
||||
}
|
||||
}
|
||||
|
||||
File outputfile = new File(name);
|
||||
ImageIO.write(image, "png", outputfile);
|
||||
}
|
||||
}
|
||||
package commands.general;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import utils.ImageUtils;
|
||||
|
||||
public class CommandPerish extends Command
|
||||
{
|
||||
public CommandPerish(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("PerishInfo"); };
|
||||
|
||||
private static Long num = 0l;
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String name = null;
|
||||
String filename = null;
|
||||
File preProcessed = null;
|
||||
File postProcessed = null;
|
||||
|
||||
synchronized(num)
|
||||
{
|
||||
name = "perish_" + num + ".png";
|
||||
++num;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
filename = ImageUtils.downloadFromURL(input.args.split(" ")[0], ".png");
|
||||
preProcessed = new File(filename);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
KittyUser person = user;
|
||||
if(input.mentions != null)
|
||||
person = input.mentions[0];
|
||||
|
||||
filename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||
if(filename == null)
|
||||
return;
|
||||
}
|
||||
preProcessed = new File(filename);
|
||||
applyTintEffect(ImageIO.read(preProcessed), name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
postProcessed = new File(name);
|
||||
res.sendFile(postProcessed, "png");
|
||||
|
||||
ImageUtils.blockingFileDelete(preProcessed);
|
||||
ImageUtils.blockingFileDelete(postProcessed);
|
||||
}
|
||||
|
||||
private static void applyTintEffect(BufferedImage image, String name) throws IOException
|
||||
{
|
||||
// Iterate over each column left to right and touch up each pixel
|
||||
for(int x = 0; x < image.getWidth(); ++x)
|
||||
{
|
||||
for(int y = 0; y < image.getHeight(); ++y)
|
||||
{
|
||||
Color c = new Color(image.getRGB(x, y), true);
|
||||
|
||||
int red = c.getRed();
|
||||
red += 100;
|
||||
if(red > 255)
|
||||
red = 255;
|
||||
|
||||
int green = c.getGreen();
|
||||
|
||||
int blue = c.getBlue();
|
||||
blue += 20;
|
||||
if(blue > 255)
|
||||
blue = 255;
|
||||
|
||||
Color tinted = new Color(red, green, blue, c.getAlpha());
|
||||
image.setRGB(x, y, tinted.getRGB());
|
||||
}
|
||||
}
|
||||
|
||||
File outputfile = new File(name);
|
||||
ImageIO.write(image, "png", outputfile);
|
||||
}
|
||||
}
|
||||
@@ -1,60 +1,60 @@
|
||||
package commands.dev;
|
||||
|
||||
import core.Command;
|
||||
import core.DatabaseManager;
|
||||
import core.LocStrings;
|
||||
import core.Stats;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import utils.GlobalLog;
|
||||
import utils.LogFilter;
|
||||
|
||||
// NOTE(wisp): This is a sort of special command.
|
||||
public class CommandShutdown extends Command
|
||||
{
|
||||
public CommandShutdown(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("ShutdownInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
// Flag the shutdown immediately.
|
||||
Stats.instance.indicateShutdown();
|
||||
|
||||
boolean isSafe = false;
|
||||
switch(input.args.toLowerCase().trim())
|
||||
{
|
||||
case "s":
|
||||
case "safe":
|
||||
case "-s":
|
||||
case "-safe":
|
||||
case "snafe":
|
||||
isSafe = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(isSafe)
|
||||
{
|
||||
// Force upkeep, this works so long as upkeep is on the main thread.
|
||||
res.sendImmediate(LocStrings.stub("ShutdownSafe"));
|
||||
DatabaseManager.instance.upkeep();
|
||||
GlobalLog.warn(LogFilter.Command, LocStrings.lookup("ShutdownSafe"));
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
res.sendImmediate(LocStrings.stub("ShutdownUnsafe"));// "``");
|
||||
GlobalLog.warn(LogFilter.Command, LocStrings.lookup("ShutdownSafe"));
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.DatabaseManager;
|
||||
import core.LocStrings;
|
||||
import core.Stats;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import utils.GlobalLog;
|
||||
import utils.LogFilter;
|
||||
|
||||
// NOTE(wisp): This is a sort of special command.
|
||||
public class CommandShutdown extends Command
|
||||
{
|
||||
public CommandShutdown(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("ShutdownInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
// Flag the shutdown immediately.
|
||||
Stats.instance.indicateShutdown();
|
||||
|
||||
boolean isSafe = false;
|
||||
switch(input.args.toLowerCase().trim())
|
||||
{
|
||||
case "s":
|
||||
case "safe":
|
||||
case "-s":
|
||||
case "-safe":
|
||||
case "snafe":
|
||||
isSafe = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(isSafe)
|
||||
{
|
||||
// Force upkeep, this works so long as upkeep is on the main thread.
|
||||
res.sendImmediate(LocStrings.stub("ShutdownSafe"));
|
||||
DatabaseManager.instance.upkeep();
|
||||
GlobalLog.warn(LogFilter.Command, LocStrings.lookup("ShutdownSafe"));
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
res.sendImmediate(LocStrings.stub("ShutdownUnsafe"));// "``");
|
||||
GlobalLog.warn(LogFilter.Command, LocStrings.lookup("ShutdownSafe"));
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package commands.images;
|
||||
package commands.general;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -1,89 +1,89 @@
|
||||
package commands.dev;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import core.CommandManager.ThreadData;
|
||||
import core.Constants;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyEmbed;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import core.Stats;
|
||||
|
||||
public class CommandStats extends Command
|
||||
{
|
||||
public CommandStats(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("StatsInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
// Variables
|
||||
Stats stats = Stats.instance;
|
||||
String out = "";
|
||||
long seen = stats.getMessagesSeen();
|
||||
long processed = stats.getCommandsProcessed();
|
||||
|
||||
// General
|
||||
out += "General";
|
||||
out += "```\n";
|
||||
out += " Messages observed: " + seen + "\n";
|
||||
out += "Commands processed: " + processed + "\n";
|
||||
out += " Command invoke %: " + ((int)((processed / (float)seen) * 1000)) / 10.0f + "%\n";
|
||||
out += " Bot uptime: " + stats.getFormattedUptime() + "\n";
|
||||
out += "```\n";
|
||||
|
||||
// Health
|
||||
out += "Health";
|
||||
out += "```\n";
|
||||
out += " SMT cores: " + stats.getCPUAvailable() + "\n";
|
||||
|
||||
// If CPU load works on this OS, list it. -1.0 is the error state
|
||||
double CPULoad = stats.getSystemCPULoad();
|
||||
out += CPULoad > -0.9
|
||||
? " CPU Load: " + (CPULoad * 100) + "%\n" : "";
|
||||
|
||||
ThreadData data = stats.getThreadData();
|
||||
Integer terminated = data.states.get(Thread.State.TERMINATED);
|
||||
Integer runnable = data.states.get(Thread.State.RUNNABLE);
|
||||
Integer blocked = data.states.get(Thread.State.BLOCKED);
|
||||
Integer timed_waiting = data.states.get(Thread.State.TIMED_WAITING);
|
||||
Integer waiting = data.states.get(Thread.State.WAITING);
|
||||
|
||||
out += " Threads:"
|
||||
+ " run-" + (runnable == null ? 0 : runnable)
|
||||
+ " block-" + (blocked == null ? 0 : blocked)
|
||||
+ " sleep-" + (timed_waiting == null ? 0 : timed_waiting)
|
||||
+ " wait-" + (waiting == null ? 0 : waiting)
|
||||
+ " term-" + (terminated == null ? 0 : terminated)
|
||||
+ "\n";
|
||||
|
||||
out += "```\n";
|
||||
|
||||
|
||||
// Cache
|
||||
Integer guildCount = stats.getGuildCount();
|
||||
Integer userCount = stats.getUserCount();
|
||||
|
||||
out += "Cache";
|
||||
out += "```\n"
|
||||
+ "Cached Guilds: " + guildCount + "\n"
|
||||
+ " Cached Users: " + userCount;
|
||||
|
||||
out += "\n```";
|
||||
|
||||
KittyEmbed embed = new KittyEmbed();
|
||||
embed.title = "Bot Stats";
|
||||
embed.descriptionText = out;
|
||||
embed.color = Constants.ColorDefault;
|
||||
|
||||
res.send(embed);
|
||||
}
|
||||
}
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import core.CommandManager.ThreadData;
|
||||
import core.Constants;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyEmbed;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import core.Stats;
|
||||
|
||||
public class CommandStats extends Command
|
||||
{
|
||||
public CommandStats(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("StatsInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
// Variables
|
||||
Stats stats = Stats.instance;
|
||||
String out = "";
|
||||
long seen = stats.getMessagesSeen();
|
||||
long processed = stats.getCommandsProcessed();
|
||||
|
||||
// General
|
||||
out += "General";
|
||||
out += "```\n";
|
||||
out += " Messages observed: " + seen + "\n";
|
||||
out += "Commands processed: " + processed + "\n";
|
||||
out += " Command invoke %: " + ((int)((processed / (float)seen) * 1000)) / 10.0f + "%\n";
|
||||
out += " Bot uptime: " + stats.getFormattedUptime() + "\n";
|
||||
out += "```\n";
|
||||
|
||||
// Health
|
||||
out += "Health";
|
||||
out += "```\n";
|
||||
out += " SMT cores: " + stats.getCPUAvailable() + "\n";
|
||||
|
||||
// If CPU load works on this OS, list it. -1.0 is the error state
|
||||
double CPULoad = stats.getSystemCPULoad();
|
||||
out += CPULoad > -0.9
|
||||
? " CPU Load: " + (CPULoad * 100) + "%\n" : "";
|
||||
|
||||
ThreadData data = stats.getThreadData();
|
||||
Integer terminated = data.states.get(Thread.State.TERMINATED);
|
||||
Integer runnable = data.states.get(Thread.State.RUNNABLE);
|
||||
Integer blocked = data.states.get(Thread.State.BLOCKED);
|
||||
Integer timed_waiting = data.states.get(Thread.State.TIMED_WAITING);
|
||||
Integer waiting = data.states.get(Thread.State.WAITING);
|
||||
|
||||
out += " Threads:"
|
||||
+ " run-" + (runnable == null ? 0 : runnable)
|
||||
+ " block-" + (blocked == null ? 0 : blocked)
|
||||
+ " sleep-" + (timed_waiting == null ? 0 : timed_waiting)
|
||||
+ " wait-" + (waiting == null ? 0 : waiting)
|
||||
+ " term-" + (terminated == null ? 0 : terminated)
|
||||
+ "\n";
|
||||
|
||||
out += "```\n";
|
||||
|
||||
|
||||
// Cache
|
||||
Integer guildCount = stats.getGuildCount();
|
||||
Integer userCount = stats.getUserCount();
|
||||
|
||||
out += "Cache";
|
||||
out += "```\n"
|
||||
+ "Cached Guilds: " + guildCount + "\n"
|
||||
+ " Cached Users: " + userCount;
|
||||
|
||||
out += "\n```";
|
||||
|
||||
KittyEmbed embed = new KittyEmbed();
|
||||
embed.title = "Bot Stats";
|
||||
embed.descriptionText = out;
|
||||
embed.color = Constants.ColorDefault;
|
||||
|
||||
res.send(embed);
|
||||
}
|
||||
}
|
||||
@@ -1,72 +1,72 @@
|
||||
package commands.images;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import core.Command;
|
||||
import core.Constants;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import utils.ImageOverlayBuilder;
|
||||
import utils.ImageUtils;
|
||||
|
||||
public class CommandTeey extends Command
|
||||
{
|
||||
// Required constructor
|
||||
public CommandTeey(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
private static Long num = 0l;
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("TeeyInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String name = null;
|
||||
File teeyFile = null;
|
||||
File teeyeeFile = null;
|
||||
|
||||
synchronized(num)
|
||||
{
|
||||
name = "teey_" + num + ".gif";
|
||||
++num;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
KittyUser person = null;
|
||||
|
||||
if(input.mentions == null)
|
||||
person = user;
|
||||
else
|
||||
person = input.mentions[0];
|
||||
|
||||
String yeeteeFilename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||
if(yeeteeFilename == null)
|
||||
return;
|
||||
|
||||
teeyeeFile = new File(yeeteeFilename);
|
||||
ImageOverlayBuilder builder = new ImageOverlayBuilder(Constants.AssetDirectory + "teey/frames/", "teey ", 24, 18);
|
||||
builder.overlay(ImageIO.read(teeyeeFile), name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
teeyFile = new File (name);
|
||||
res.sendFile(teeyFile, "gif");
|
||||
|
||||
// Thread cleanup...
|
||||
ImageUtils.blockingFileDelete(teeyFile);
|
||||
ImageUtils.blockingFileDelete(teeyeeFile);
|
||||
}
|
||||
}
|
||||
package commands.general;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import core.Command;
|
||||
import core.Constants;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import utils.ImageOverlayBuilder;
|
||||
import utils.ImageUtils;
|
||||
|
||||
public class CommandTeey extends Command
|
||||
{
|
||||
// Required constructor
|
||||
public CommandTeey(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
private static Long num = 0l;
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("TeeyInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String name = null;
|
||||
File teeyFile = null;
|
||||
File teeyeeFile = null;
|
||||
|
||||
synchronized(num)
|
||||
{
|
||||
name = "teey_" + num + ".gif";
|
||||
++num;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
KittyUser person = null;
|
||||
|
||||
if(input.mentions == null)
|
||||
person = user;
|
||||
else
|
||||
person = input.mentions[0];
|
||||
|
||||
String yeeteeFilename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||
if(yeeteeFilename == null)
|
||||
return;
|
||||
|
||||
teeyeeFile = new File(yeeteeFilename);
|
||||
ImageOverlayBuilder builder = new ImageOverlayBuilder(Constants.AssetDirectory + "teey/frames/", "teey ", 24, 18);
|
||||
builder.overlay(ImageIO.read(teeyeeFile), name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
teeyFile = new File (name);
|
||||
res.sendFile(teeyFile, "gif");
|
||||
|
||||
// Thread cleanup...
|
||||
ImageUtils.blockingFileDelete(teeyFile);
|
||||
ImageUtils.blockingFileDelete(teeyeeFile);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package commands.beans;
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
@@ -1,4 +1,4 @@
|
||||
package commands.dev;
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
@@ -1,4 +1,4 @@
|
||||
package commands.network;
|
||||
package commands.general;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -1,72 +1,72 @@
|
||||
package commands.images;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import core.Command;
|
||||
import core.Constants;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import utils.ImageOverlayBuilder;
|
||||
import utils.ImageUtils;
|
||||
|
||||
public class CommandYeet extends Command
|
||||
{
|
||||
// Required constructor
|
||||
public CommandYeet(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
private static Long num = 0l;
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("YeetInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String name = null;
|
||||
File yeetFile = null;
|
||||
File yeeteeFile = null;
|
||||
|
||||
synchronized(num)
|
||||
{
|
||||
name = "yeet_" + num + ".gif";
|
||||
++num;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
KittyUser person = null;
|
||||
|
||||
if(input.mentions == null)
|
||||
person = user;
|
||||
else
|
||||
person = input.mentions[0];
|
||||
|
||||
String yeeteeFilename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||
if(yeeteeFilename == null)
|
||||
return;
|
||||
|
||||
yeeteeFile = new File(yeeteeFilename);
|
||||
ImageOverlayBuilder builder = new ImageOverlayBuilder(Constants.AssetDirectory + "yeet/frames/", "yeet ", 24, 18);
|
||||
builder.overlay(ImageIO.read(yeeteeFile), name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
yeetFile = new File (name);
|
||||
res.sendFile(yeetFile, "gif");
|
||||
|
||||
// Thread cleanup...
|
||||
ImageUtils.blockingFileDelete(yeetFile);
|
||||
ImageUtils.blockingFileDelete(yeeteeFile);
|
||||
}
|
||||
}
|
||||
package commands.general;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import core.Command;
|
||||
import core.Constants;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import utils.ImageOverlayBuilder;
|
||||
import utils.ImageUtils;
|
||||
|
||||
public class CommandYeet extends Command
|
||||
{
|
||||
// Required constructor
|
||||
public CommandYeet(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
private static Long num = 0l;
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("YeetInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String name = null;
|
||||
File yeetFile = null;
|
||||
File yeeteeFile = null;
|
||||
|
||||
synchronized(num)
|
||||
{
|
||||
name = "yeet_" + num + ".gif";
|
||||
++num;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
KittyUser person = null;
|
||||
|
||||
if(input.mentions == null)
|
||||
person = user;
|
||||
else
|
||||
person = input.mentions[0];
|
||||
|
||||
String yeeteeFilename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||
if(yeeteeFilename == null)
|
||||
return;
|
||||
|
||||
yeeteeFile = new File(yeeteeFilename);
|
||||
ImageOverlayBuilder builder = new ImageOverlayBuilder(Constants.AssetDirectory + "yeet/frames/", "yeet ", 24, 18);
|
||||
builder.overlay(ImageIO.read(yeeteeFile), name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
yeetFile = new File (name);
|
||||
res.sendFile(yeetFile, "gif");
|
||||
|
||||
// Thread cleanup...
|
||||
ImageUtils.blockingFileDelete(yeetFile);
|
||||
ImageUtils.blockingFileDelete(yeeteeFile);
|
||||
}
|
||||
}
|
||||
@@ -4,37 +4,11 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import commands.beans.CommandBeansShow;
|
||||
import commands.beans.CommandBetBeans;
|
||||
import commands.beans.CommandBetHistory;
|
||||
import commands.beans.CommandGiveBeans;
|
||||
import commands.beans.CommandTradeBeans;
|
||||
import commands.characters.CommandCharacterMain;
|
||||
import commands.dev.CommandDBFlush;
|
||||
import commands.dev.CommandDBStats;
|
||||
import commands.dev.CommandDoWork;
|
||||
import commands.dev.CommandHelpBuilder;
|
||||
import commands.dev.CommandInvite;
|
||||
import commands.dev.CommandShutdown;
|
||||
import commands.dev.CommandStats;
|
||||
import commands.dev.CommandTweet;
|
||||
import commands.general.*;
|
||||
import commands.guildrole.CommandGuildRoleMain;
|
||||
import commands.images.CommandBlurry;
|
||||
import commands.images.CommandCatch;
|
||||
import commands.images.CommandDefaultDance;
|
||||
import commands.images.CommandPerish;
|
||||
import commands.images.CommandStark;
|
||||
import commands.images.CommandTeey;
|
||||
import commands.images.CommandYeet;
|
||||
import commands.mod.CommandModMain;
|
||||
import commands.music.CommandMusicMain;
|
||||
import commands.network.CommandColiru;
|
||||
import commands.network.CommandDerpi;
|
||||
import commands.network.CommandE6;
|
||||
import commands.network.CommandGetSauce;
|
||||
import commands.network.CommandJDoodle;
|
||||
import commands.network.CommandWolfram;
|
||||
import commands.poll.CommandPollMain;
|
||||
import commands.raffle.CommandRaffleMain;
|
||||
import dataStructures.*;
|
||||
|
||||
@@ -18,20 +18,13 @@ public class ConfigGlobals implements IConfigSection
|
||||
private static final String startupStyleKey = "mode (dev or release)";
|
||||
private KittyStartupMode startupStyleValue = KittyStartupMode.Dev;
|
||||
|
||||
private static final String activityKey = "activity";
|
||||
private String activityValue = "with a laser pointer"; // Appears as "Playing with a laser pointer"
|
||||
|
||||
// Singleton Constructor - explode if there's a problem.
|
||||
// Constructor
|
||||
public ConfigGlobals()
|
||||
{
|
||||
if(instance == null)
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalLog.error("Attempted to initialize a second config globals! Probably don't do this!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,11 +38,6 @@ public class ConfigGlobals implements IConfigSection
|
||||
return instance.startupStyleValue;
|
||||
}
|
||||
|
||||
public static String getActivity()
|
||||
{
|
||||
return instance.activityValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consume(List<ConfigItem> pairs)
|
||||
{
|
||||
@@ -64,29 +52,8 @@ public class ConfigGlobals implements IConfigSection
|
||||
startupStyleValue = KittyStartupMode.Dev;
|
||||
|
||||
if(value.equalsIgnoreCase(KittyStartupMode.Release.name()))
|
||||
{
|
||||
startupStyleValue = KittyStartupMode.Release;
|
||||
}
|
||||
|
||||
if(value.equalsIgnoreCase(KittyStartupMode.PoguRelease.name()))
|
||||
{
|
||||
startupStyleValue = KittyStartupMode.PoguRelease;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Parse text for 'playing'
|
||||
if(key.equalsIgnoreCase(activityKey))
|
||||
{
|
||||
activityValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
// If we change any globals, update anything we need to.
|
||||
if(ObjectBuilder.getHasInitialized())
|
||||
{
|
||||
ObjectBuilder.updateActivity();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +62,6 @@ public class ConfigGlobals implements IConfigSection
|
||||
{
|
||||
List<ConfigItem> items = new ArrayList<ConfigItem>();
|
||||
items.add(new ConfigItem(getSectionTitle(), startupStyleKey, startupStyleValue.name().toLowerCase()));
|
||||
items.add(new ConfigItem(getSectionTitle(), activityKey, activityValue));
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -23,15 +23,15 @@ import dataStructures.KittyRole;
|
||||
import dataStructures.KittyStartupMode;
|
||||
import dataStructures.KittyUser;
|
||||
import main.Main;
|
||||
import net.dv8tion.jda.api.AccountType;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.JDABuilder;
|
||||
import net.dv8tion.jda.api.entities.Activity;
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.core.AccountType;
|
||||
import net.dv8tion.jda.core.JDA;
|
||||
import net.dv8tion.jda.core.JDABuilder;
|
||||
import net.dv8tion.jda.core.entities.Emote;
|
||||
import net.dv8tion.jda.core.entities.Game;
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
import net.dv8tion.jda.core.entities.User;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
import offline.Ref;
|
||||
import utils.AdminControl;
|
||||
//import utils.AudioUtils;
|
||||
@@ -39,11 +39,11 @@ import utils.GlobalLog;
|
||||
import utils.LogFilter;
|
||||
import utils.audio.AudioUtils;
|
||||
|
||||
// NOTE: Isolated factory to assist with storage and caching if needed.
|
||||
// NOTE(wisp): Isolated factory to assist with storage and caching if needed.
|
||||
// This also minimizes the number of places JDA interacts with our codebase.
|
||||
// As it stands, if the object name begins with Kitty, it's constructed here.
|
||||
// TODO: Make all methods ID based instead of event based
|
||||
public class ObjectBuilder
|
||||
public class ObjectBuilderFactory
|
||||
{
|
||||
// Key: guild string id, Value: guild information
|
||||
private static HashMap<String, KittyGuild> guildCache;
|
||||
@@ -82,20 +82,15 @@ public class ObjectBuilder
|
||||
|
||||
// Lazy initialization multithreaded mutex stuff to prevent explosions.
|
||||
// TODO: Investigate using 'synchronized' instead potentially
|
||||
private static Boolean hasInitialized = false;
|
||||
private static boolean hasInitialized;
|
||||
private static Semaphore initMutex = new Semaphore(1);
|
||||
private static JDA kitty;
|
||||
|
||||
// This is it, this is how the lazy init starts!
|
||||
private static void lazyInit()
|
||||
{
|
||||
synchronized(hasInitialized)
|
||||
{
|
||||
if(hasInitialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(hasInitialized)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -114,17 +109,14 @@ public class ObjectBuilder
|
||||
AudioSourceManagers.registerLocalSource(playerManager);
|
||||
|
||||
// Start by reading from things that are external. Because
|
||||
// we require these things to be resolved before the rest of
|
||||
// the application, we place them here.
|
||||
// we require these things to be resolved before the rest of the application,
|
||||
// we place them here.
|
||||
config = new Config();
|
||||
}
|
||||
finally
|
||||
{
|
||||
initMutex.release();
|
||||
synchronized(hasInitialized)
|
||||
{
|
||||
hasInitialized = true;
|
||||
}
|
||||
hasInitialized = true;
|
||||
}
|
||||
}
|
||||
catch(InterruptedException ie)
|
||||
@@ -134,14 +126,6 @@ public class ObjectBuilder
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getHasInitialized()
|
||||
{
|
||||
synchronized(hasInitialized)
|
||||
{
|
||||
return hasInitialized;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
// Extraction Methods //
|
||||
////////////////////////
|
||||
@@ -183,7 +167,7 @@ public class ObjectBuilder
|
||||
else
|
||||
{
|
||||
// Construct a new guild with defaults
|
||||
guild = new KittyGuild(uid, new AdminControl(event.getGuild()), emotesString,
|
||||
guild = new KittyGuild(uid, new AdminControl(event.getGuild()), emotesString,
|
||||
new AudioUtils(event.getGuild(), playerManager), channels);
|
||||
DatabaseManager.instance.globalRegister(guild);
|
||||
guildCache.put(uid, guild);
|
||||
@@ -204,8 +188,8 @@ public class ObjectBuilder
|
||||
// the guild if not, they're assumed to be
|
||||
// allowed to use the bot at a general level.
|
||||
KittyRole role = KittyRole.General;
|
||||
|
||||
if(event.getAuthor().getId() == event.getGuild().getOwnerId())
|
||||
|
||||
if(event.getAuthor().getId() == event.getGuild().getOwner().getUser().getId())
|
||||
{
|
||||
role = KittyRole.Admin;
|
||||
}
|
||||
@@ -405,32 +389,21 @@ public class ObjectBuilder
|
||||
|
||||
// Determine token based on config. Default to test token.
|
||||
String tokenToUse = Ref.TestToken;
|
||||
switch(ConfigGlobals.getStartupMode())
|
||||
{
|
||||
case Release: tokenToUse = Ref.Token; break;
|
||||
case PoguRelease: tokenToUse = Ref.PoguToken; break;
|
||||
default: tokenToUse = Ref.TestToken; break;
|
||||
}
|
||||
|
||||
// Construct bot based on token using the JDA Builder
|
||||
JDABuilder builder = JDABuilder.createDefault(tokenToUse);
|
||||
kitty = builder.build();
|
||||
if(ConfigGlobals.getStartupMode() == KittyStartupMode.Release)
|
||||
tokenToUse = Ref.Token;
|
||||
if(ConfigGlobals.getStartupMode() == KittyStartupMode.PoguRelease)
|
||||
tokenToUse = Ref.PoguToken;
|
||||
|
||||
|
||||
// Set activity, and add primariy event listener.
|
||||
updateActivity();
|
||||
// Construct bot based on token
|
||||
kitty = new JDABuilder(AccountType.BOT)
|
||||
.setToken(tokenToUse).buildBlocking();
|
||||
kitty.getPresence().setGame(Game.playing("with a laser pointer"));
|
||||
kitty.addEventListener(new Main());
|
||||
|
||||
return new KittyCore(kitty);
|
||||
}
|
||||
|
||||
// Updates the bots current activity based on the globals value.
|
||||
public static void updateActivity()
|
||||
{
|
||||
String activity = ConfigGlobals.getActivity();
|
||||
GlobalLog.log(LogFilter.Core, "Updating activity to " + activity);
|
||||
kitty.getPresence().setActivity(Activity.playing(activity));
|
||||
}
|
||||
|
||||
// Default construction of the command manager. In order to remotely resolve command enabling
|
||||
// and disabling, what we do is construct the commands with a localized pair that is checked against
|
||||
// the CommandEnabler object passed in. In theory, we could have multiple CommandManagers, tho we can
|
||||
+2
-2
@@ -107,12 +107,12 @@ public class Stats
|
||||
|
||||
public int getGuildCount()
|
||||
{
|
||||
return ObjectBuilder.getGuildCount();
|
||||
return ObjectBuilderFactory.getGuildCount();
|
||||
}
|
||||
|
||||
public int getUserCount()
|
||||
{
|
||||
return ObjectBuilder.getUserCount();
|
||||
return ObjectBuilderFactory.getUserCount();
|
||||
}
|
||||
|
||||
public ArrayList<Command> getAllCommands()
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package dataStructures;
|
||||
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
|
||||
public class KittyCore
|
||||
{
|
||||
public final JDA jda;
|
||||
|
||||
public KittyCore(JDA kitty)
|
||||
{
|
||||
this.jda = kitty;
|
||||
}
|
||||
}
|
||||
package dataStructures;
|
||||
|
||||
import net.dv8tion.jda.core.JDA;
|
||||
|
||||
public class KittyCore
|
||||
{
|
||||
public final JDA jda;
|
||||
|
||||
public KittyCore(JDA kitty)
|
||||
{
|
||||
this.jda = kitty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,11 @@ package dataStructures;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.utils.AttachmentOption;
|
||||
import net.dv8tion.jda.core.JDA;
|
||||
import net.dv8tion.jda.core.MessageBuilder;
|
||||
import net.dv8tion.jda.core.entities.TextChannel;
|
||||
import net.dv8tion.jda.core.events.message.guild.*;
|
||||
import net.dv8tion.jda.core.EmbedBuilder;
|
||||
import utils.GlobalLog;
|
||||
import utils.LogFilter;
|
||||
|
||||
@@ -73,14 +72,10 @@ public class Response
|
||||
embed.setThumbnail(thumbPath);
|
||||
message.setEmbed(embed.build());
|
||||
|
||||
GlobalLog.log("We're trying to send a response that has a locally defined thumbnail file...");
|
||||
|
||||
File thumbImage = new File(thumbName);
|
||||
if(thumbImage.exists())
|
||||
{
|
||||
// Used to eb as follows:
|
||||
//event.getChannel().sendFile(thumbImage, thumbName, message.build()).queue();
|
||||
event.getChannel().sendMessage(message.build()).queue();
|
||||
event.getChannel().sendFile(thumbImage, thumbName, message.build()).queue();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
+100
-100
@@ -1,100 +1,100 @@
|
||||
package dataStructures;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import core.ObjectBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
public class UserInput
|
||||
{
|
||||
// Variables
|
||||
public String key;
|
||||
public String args;
|
||||
public KittyUser [] mentions;
|
||||
private boolean isValid;
|
||||
public String message;
|
||||
|
||||
// NOTE(wisp): Designed to parse a string as it's constructed.
|
||||
// If a user enters the command "!ping some stuff here :D"
|
||||
// and if the command indicator is !, then...
|
||||
//
|
||||
// key=ping
|
||||
// args=some stuff here :D
|
||||
//
|
||||
// The CommandIndicator and spaces between the key and args are dropped.
|
||||
public UserInput(GuildMessageReceivedEvent event, KittyGuild guildContext)
|
||||
{
|
||||
String toParse = event.getMessage().getContentRaw();
|
||||
message = toParse;
|
||||
|
||||
key = "";
|
||||
args = "";
|
||||
|
||||
if(toParse.length() <= 0)
|
||||
return;
|
||||
|
||||
if(!event.getMessage().getMentionedMembers().isEmpty())
|
||||
mentions = findMentionedUsers(event);
|
||||
|
||||
toParse = toParse.trim();
|
||||
String commandIndicator = guildContext.getCommandIndicator();
|
||||
if(toParse.startsWith(commandIndicator))
|
||||
{
|
||||
int loc = findFirstWhitespace(toParse);
|
||||
|
||||
if(loc <= 0)
|
||||
{
|
||||
key = toParse.substring(commandIndicator.length()).trim().toLowerCase();
|
||||
}
|
||||
else
|
||||
{
|
||||
key = toParse.substring(commandIndicator.length(), loc).trim().toLowerCase();
|
||||
args = toParse.substring(loc).trim();
|
||||
}
|
||||
|
||||
isValid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Used for injecting direct commands from plugins
|
||||
public UserInput(String input, KittyGuild contextGuild)
|
||||
{
|
||||
int loc = findFirstWhitespace(input);
|
||||
key = input.substring(0, loc);
|
||||
args = input.substring(loc);
|
||||
isValid = true;
|
||||
}
|
||||
|
||||
public boolean isValid()
|
||||
{
|
||||
return isValid;
|
||||
}
|
||||
|
||||
// Finds first whitespace in the string
|
||||
private int findFirstWhitespace(String str)
|
||||
{
|
||||
for (int i = 0; i < str.length(); ++i)
|
||||
{
|
||||
if (Character.isWhitespace(str.charAt(i)))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private KittyUser[] findMentionedUsers(GuildMessageReceivedEvent event)
|
||||
{
|
||||
List <Member> JDAMentions = event.getMessage().getMentionedMembers();
|
||||
KittyUser [] KittyMentions = new KittyUser[JDAMentions.size()];
|
||||
for(int i = 0; i < KittyMentions.length; i ++)
|
||||
{
|
||||
KittyMentions [i] = ObjectBuilder.getKittyUser(event.getGuild().getId(), JDAMentions.get(i).getUser().getId());
|
||||
}
|
||||
return KittyMentions;
|
||||
}
|
||||
}
|
||||
package dataStructures;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import core.ObjectBuilderFactory;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
public class UserInput
|
||||
{
|
||||
// Variables
|
||||
public String key;
|
||||
public String args;
|
||||
public KittyUser [] mentions;
|
||||
private boolean isValid;
|
||||
public String message;
|
||||
|
||||
// NOTE(wisp): Designed to parse a string as it's constructed.
|
||||
// If a user enters the command "!ping some stuff here :D"
|
||||
// and if the command indicator is !, then...
|
||||
//
|
||||
// key=ping
|
||||
// args=some stuff here :D
|
||||
//
|
||||
// The CommandIndicator and spaces between the key and args are dropped.
|
||||
public UserInput(GuildMessageReceivedEvent event, KittyGuild guildContext)
|
||||
{
|
||||
String toParse = event.getMessage().getContentRaw();
|
||||
message = toParse;
|
||||
|
||||
key = "";
|
||||
args = "";
|
||||
|
||||
if(toParse.length() <= 0)
|
||||
return;
|
||||
|
||||
if(!event.getMessage().getMentionedMembers().isEmpty())
|
||||
mentions = findMentionedUsers(event);
|
||||
|
||||
toParse = toParse.trim();
|
||||
String commandIndicator = guildContext.getCommandIndicator();
|
||||
if(toParse.startsWith(commandIndicator))
|
||||
{
|
||||
int loc = findFirstWhitespace(toParse);
|
||||
|
||||
if(loc <= 0)
|
||||
{
|
||||
key = toParse.substring(commandIndicator.length()).trim().toLowerCase();
|
||||
}
|
||||
else
|
||||
{
|
||||
key = toParse.substring(commandIndicator.length(), loc).trim().toLowerCase();
|
||||
args = toParse.substring(loc).trim();
|
||||
}
|
||||
|
||||
isValid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Used for injecting direct commands from plugins
|
||||
public UserInput(String input, KittyGuild contextGuild)
|
||||
{
|
||||
int loc = findFirstWhitespace(input);
|
||||
key = input.substring(0, loc);
|
||||
args = input.substring(loc);
|
||||
isValid = true;
|
||||
}
|
||||
|
||||
public boolean isValid()
|
||||
{
|
||||
return isValid;
|
||||
}
|
||||
|
||||
// Finds first whitespace in the string
|
||||
private int findFirstWhitespace(String str)
|
||||
{
|
||||
for (int i = 0; i < str.length(); ++i)
|
||||
{
|
||||
if (Character.isWhitespace(str.charAt(i)))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private KittyUser[] findMentionedUsers(GuildMessageReceivedEvent event)
|
||||
{
|
||||
List <Member> JDAMentions = event.getMessage().getMentionedMembers();
|
||||
KittyUser [] KittyMentions = new KittyUser[JDAMentions.size()];
|
||||
for(int i = 0; i < KittyMentions.length; i ++)
|
||||
{
|
||||
KittyMentions [i] = ObjectBuilderFactory.getKittyUser(event.getGuild().getId(), JDAMentions.get(i).getUser().getId());
|
||||
}
|
||||
return KittyMentions;
|
||||
}
|
||||
}
|
||||
|
||||
+33
-12
@@ -1,14 +1,26 @@
|
||||
package main;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.security.auth.login.LoginException;
|
||||
|
||||
import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler;
|
||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
||||
import com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager;
|
||||
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers;
|
||||
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
|
||||
import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
|
||||
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||
import com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame;
|
||||
|
||||
import core.CharacterManager;
|
||||
import core.CommandEnabler;
|
||||
import core.CommandManager;
|
||||
import core.DatabaseManager;
|
||||
import core.ObjectBuilder;
|
||||
import core.ObjectBuilderFactory;
|
||||
import core.RPManager;
|
||||
import core.Stats;
|
||||
import core.lua.PluginManager;
|
||||
@@ -18,8 +30,17 @@ import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import net.dv8tion.jda.core.AccountType;
|
||||
import net.dv8tion.jda.core.JDA;
|
||||
import net.dv8tion.jda.core.JDABuilder;
|
||||
import net.dv8tion.jda.core.audio.AudioSendHandler;
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
import net.dv8tion.jda.core.entities.TextChannel;
|
||||
import net.dv8tion.jda.core.entities.VoiceChannel;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.core.hooks.ListenerAdapter;
|
||||
import net.dv8tion.jda.core.managers.AudioManager;
|
||||
import offline.Ref;
|
||||
import utils.GlobalLog;
|
||||
|
||||
// http://www.slf4j.org/ - this JDA logging tool has been disabled by specifying NOP implementation.
|
||||
@@ -43,15 +64,15 @@ public class Main extends ListenerAdapter
|
||||
{
|
||||
// Factory startup. The ordering is intentional.
|
||||
GlobalLog.initialize();
|
||||
databaseManager = ObjectBuilder.constructDatabaseManager();
|
||||
commandManager = ObjectBuilder.constructCommandManager(CommandEnabler.instance); // TODO: Untangle this singleton
|
||||
stats = ObjectBuilder.constructStats(commandManager);
|
||||
databaseManager = ObjectBuilderFactory.constructDatabaseManager();
|
||||
commandManager = ObjectBuilderFactory.constructCommandManager(CommandEnabler.instance); // TODO: Untangle this singleton
|
||||
stats = ObjectBuilderFactory.constructStats(commandManager);
|
||||
charManager = new CharacterManager();
|
||||
rpManager = ObjectBuilder.constructRPManager();
|
||||
pluginManager = ObjectBuilder.constructPluginManager();
|
||||
rpManager = ObjectBuilderFactory.constructRPManager();
|
||||
pluginManager = ObjectBuilderFactory.constructPluginManager();
|
||||
|
||||
// Bot startup
|
||||
kittyCore = ObjectBuilder.constructKittyCore();
|
||||
kittyCore = ObjectBuilderFactory.constructKittyCore();
|
||||
}
|
||||
|
||||
// When a message is sent in a server that kitty is in, this is what's called.
|
||||
@@ -63,9 +84,9 @@ public class Main extends ListenerAdapter
|
||||
return;
|
||||
|
||||
// Factory objects
|
||||
KittyUser user = ObjectBuilder.extractUser(event);
|
||||
KittyGuild guild = ObjectBuilder.extractGuild(event);
|
||||
KittyChannel channel = ObjectBuilder.extractChannel(event);
|
||||
KittyUser user = ObjectBuilderFactory.extractUser(event);
|
||||
KittyGuild guild = ObjectBuilderFactory.extractGuild(event);
|
||||
KittyChannel channel = ObjectBuilderFactory.extractChannel(event);
|
||||
|
||||
// Specialized uncached objects
|
||||
Response response = new Response(event, kittyCore);
|
||||
|
||||
@@ -14,7 +14,7 @@ import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
import offline.Ref;
|
||||
|
||||
// Manages the fiddly bits and upkeep of the bot - while not
|
||||
|
||||
+10
-21
@@ -1,30 +1,24 @@
|
||||
package utils;
|
||||
|
||||
import java.util.*;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.dv8tion.jda.internal.handle.GuildSetupController;
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
import net.dv8tion.jda.core.managers.GuildController;
|
||||
|
||||
public class AdminControl
|
||||
{
|
||||
{
|
||||
private GuildController guildCon;
|
||||
private Guild guild;
|
||||
|
||||
public AdminControl(Guild guild)
|
||||
{
|
||||
this.guild = guild;
|
||||
guildCon = guild.getController();
|
||||
}
|
||||
|
||||
public boolean addRole(String memberID, String roleName)
|
||||
{
|
||||
try
|
||||
{
|
||||
Member member = guild.getMemberById(memberID);
|
||||
List<Role> roles = guild.getRolesByName(roleName, true);
|
||||
for(Role role : roles)
|
||||
{
|
||||
guild.addRoleToMember(member, role).complete();// submit instead? We need to queue.
|
||||
}
|
||||
guildCon.addRolesToMember(guild.getMemberById(memberID), guild.getRolesByName(roleName, true)).complete();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
@@ -37,12 +31,7 @@ public class AdminControl
|
||||
{
|
||||
try
|
||||
{
|
||||
Member member = guild.getMemberById(memberID);
|
||||
List<Role> roles = guild.getRolesByName(roleName, true);
|
||||
for(Role role : roles)
|
||||
{
|
||||
guild.removeRoleFromMember(member, role).complete();
|
||||
}
|
||||
guildCon.removeRolesFromMember(guild.getMemberById(memberID), guild.getRolesByName(roleName, true)).complete();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
@@ -55,7 +44,7 @@ public class AdminControl
|
||||
{
|
||||
try
|
||||
{
|
||||
guild.kick(guild.getMemberById(memberID)).complete();
|
||||
guildCon.kick(guild.getMemberById(memberID)).complete();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
@@ -68,7 +57,7 @@ public class AdminControl
|
||||
{
|
||||
try
|
||||
{
|
||||
guild.mute(guild.getMemberById(memberID), true);
|
||||
guildCon.setMute(guild.getMemberById(memberID), true);
|
||||
return true;
|
||||
}
|
||||
catch(Exception e)
|
||||
@@ -81,7 +70,7 @@ public class AdminControl
|
||||
{
|
||||
try
|
||||
{
|
||||
guild.ban(guild.getMemberById(memberID), 0).complete();
|
||||
guildCon.ban(guild.getMemberById(memberID), 0).complete();
|
||||
return true;
|
||||
}
|
||||
catch(Exception e)
|
||||
|
||||
@@ -36,13 +36,11 @@ public class GlobalLog
|
||||
System.out.println(logLine);
|
||||
}
|
||||
|
||||
public static void log(LogFilter filter, Object obj) { write(log, filter, obj.toString()); }
|
||||
public static void log(LogFilter filter, String msg) { write(log, filter, msg); }
|
||||
public static void warn(LogFilter filter, String msg) { write(warn, filter, msg); }
|
||||
public static void error(LogFilter filter, String msg) { write(error, filter, msg); System.err.println(msg); System.err.flush(); }
|
||||
public static void fatal(LogFilter filter, String msg) throws Exception { write(fatal, filter, msg); throw new Exception(msg); }
|
||||
|
||||
public static void log(Object obj) { log(LogFilter.Debug, obj); }
|
||||
public static void log(String msg) { log(LogFilter.Debug, msg); }
|
||||
public static void warn(String msg) { warn(LogFilter.Debug, msg); }
|
||||
public static void error(String msg) { error(LogFilter.Debug, msg); }
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
package utils.audio;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler;
|
||||
@@ -10,11 +9,10 @@ import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
|
||||
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||
import com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame;
|
||||
|
||||
import net.dv8tion.jda.api.audio.AudioSendHandler;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||
import net.dv8tion.jda.api.managers.AudioManager;
|
||||
|
||||
import net.dv8tion.jda.core.audio.AudioSendHandler;
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
import net.dv8tion.jda.core.entities.VoiceChannel;
|
||||
import net.dv8tion.jda.core.managers.AudioManager;
|
||||
|
||||
public class AudioUtils
|
||||
{
|
||||
@@ -74,11 +72,9 @@ public class AudioUtils
|
||||
return lastFrame != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer provide20MsAudio()
|
||||
@Override public byte[] provide20MsAudio()
|
||||
{
|
||||
ByteBuffer outputBuffer = ByteBuffer.wrap(lastFrame.getData());
|
||||
return outputBuffer;
|
||||
return lastFrame.getData();
|
||||
}
|
||||
|
||||
@Override public boolean isOpus()
|
||||
|
||||
Reference in New Issue
Block a user