Updated Music Commands with new Jar

Jar was out of date and caused errors.
This commit is contained in:
Alex Stewart
2020-07-29 21:23:39 -04:00
parent b917a3b4ee
commit 67f1e083e9
13 changed files with 104 additions and 28 deletions
+1 -1
View File
@@ -26,7 +26,7 @@
<classpathentry kind="lib" path="lib/commons-text-1.6.jar"/> <classpathentry kind="lib" path="lib/commons-text-1.6.jar"/>
<classpathentry kind="lib" path="lib/google-http-client-1.32.0.jar"/> <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/google-api-services-youtube-v3-rev212-1.25.0.jar"/>
<classpathentry kind="lib" path="lib/LavaPlayerJar-0.0.1-jar-with-dependencies.jar"/>
<classpathentry kind="lib" path="lib/nanohttpd-2.3.1.jar"/> <classpathentry kind="lib" path="lib/nanohttpd-2.3.1.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"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 50 KiB

+18 -3
View File
@@ -1,7 +1,9 @@
package commands.general; package commands.general;
import java.awt.Font; import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -64,8 +66,6 @@ public class CommandBeansShow extends Command
long calcBean = beans; long calcBean = beans;
System.out.println("BEANS: " + beans);
long thousands = beans / 1000; long thousands = beans / 1000;
calcBean = beans % 1000; calcBean = beans % 1000;
long hundreds = (calcBean / 100); long hundreds = (calcBean / 100);
@@ -76,6 +76,8 @@ public class CommandBeansShow extends Command
BufferedImage beanImage = new BufferedImage(baseWidth, baseHeight, BufferedImage.TYPE_INT_ARGB); BufferedImage beanImage = new BufferedImage(baseWidth, baseHeight, BufferedImage.TYPE_INT_ARGB);
Graphics beanGraphics = beanImage.getGraphics(); Graphics beanGraphics = beanImage.getGraphics();
Rectangle rect = new Rectangle(0, 0, baseWidth, baseHeight);
beanGraphics.drawImage(imageBase,0,0,null);
for(int i = 0; i < ones; i++) for(int i = 0; i < ones; i++)
{ {
@@ -115,9 +117,22 @@ public class CommandBeansShow extends Command
} }
Font beanFont = new Font("font", Font.BOLD, 45); Font beanFont = new Font("font", Font.BOLD, 45);
beanGraphics.setFont(beanFont); beanGraphics.setFont(beanFont);
beanGraphics.drawString("YOU GOT " + beans + " BEANS", 0, baseHeight / 2);
drawCenteredString(beanGraphics, "YOU HAVE", rect, beanFont, .25);
drawCenteredString(beanGraphics, "" + beans, rect, beanFont, .5);
drawCenteredString(beanGraphics, "BEANS!", rect, beanFont, .75);
ImageIO.write(beanImage, "PNG", new File("beanImage.png")); ImageIO.write(beanImage, "PNG", new File("beanImage.png"));
return new File("beanImage.png"); return new File("beanImage.png");
} }
private void drawCenteredString(Graphics beanGraphics, String text, Rectangle rect, Font font, double segment)
{
FontMetrics metrics = beanGraphics.getFontMetrics(font);
int x = rect.x + (rect.width - metrics.stringWidth(text)) / 2;
int y = (int)(rect.y + ((rect.height - metrics.getHeight()) * segment) + metrics.getAscent());
beanGraphics.drawString(text, x, y);
}
} }
+2 -2
View File
@@ -26,7 +26,7 @@ public class CommandE6 extends Command
{ {
if(guild.contentRating == KittyRating.Filtered) if(guild.contentRating == KittyRating.Filtered)
{ {
image = searcher.getE6(input.args + " rating:safe"); image = searcher.getE6(input.args + " rating:safe", "");
try try
{ {
response = image.output(); response = image.output();
@@ -58,7 +58,7 @@ public class CommandE6 extends Command
{ {
try try
{ {
response = searcher.getE6(input.args).output(); response = searcher.getE6(input.args, "").output();
res.send(response); res.send(response);
} }
catch(Exception e) catch(Exception e)
+8 -2
View File
@@ -23,7 +23,13 @@ public class CommandGetSauce extends Command
@Override @Override
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res) public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
{ {
res.send(sauce.getSauce(input.args).output()); try
{
res.send(sauce.getSauce(input.args).output());
}
catch(Exception e)
{
res.send("Image not found");
}
} }
} }
@@ -0,0 +1,21 @@
package commands.guildrole;
import core.SubCommand;
import core.SubCommandFormattable;
import dataStructures.KittyChannel;
import dataStructures.KittyGuild;
import dataStructures.KittyRating;
import dataStructures.KittyRole;
import dataStructures.KittyUser;
import dataStructures.UserInput;
public class SubCommandWipeRoles extends SubCommand
{
public SubCommandWipeRoles(KittyRole level, KittyRating rating) { super(level, rating); }
@Override
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
{
return null;
}
}
+4 -2
View File
@@ -44,7 +44,8 @@ public class KittyGuild extends DatabaseTrackedObject
} }
// Default content for a guild // Default content for a guild
public KittyGuild(String uniqueID, AdminControl adminControl, ArrayList <String> emoji, AudioUtils audio, HashMap<Long, KittyChannel> channels) public KittyGuild(String uniqueID, AdminControl adminControl, ArrayList <String> emoji,
AudioUtils audio, HashMap<Long, KittyChannel> channels)
{ {
super(uniqueID); super(uniqueID);
@@ -63,7 +64,8 @@ public class KittyGuild extends DatabaseTrackedObject
} }
// Explicit constructor // Explicit constructor
public KittyGuild(String commandIndicator, KittyRating contentRating, KittyUser guildOwner, String uniqueID, AudioUtils audio, HashMap<Long, KittyChannel> channels) public KittyGuild(String commandIndicator, KittyRating contentRating, KittyUser guildOwner,
String uniqueID, AudioUtils audio, HashMap<Long, KittyChannel> channels)
{ {
super(uniqueID); super(uniqueID);
this.uniqueID = uniqueID; this.uniqueID = uniqueID;
+12 -3
View File
@@ -7,7 +7,7 @@ import utils.*;
public class NetworkDerpi public class NetworkDerpi
{ {
private final String mainURL = "https://derpibooru.org/search.json?q="; private final String mainURL = "https://derpibooru.org/api/v1/json/search/images?q=";
private static final Gson jsonParser_ = new Gson(); private static final Gson jsonParser_ = new Gson();
private class DerpiResponseObject private class DerpiResponseObject
@@ -24,10 +24,20 @@ public class NetworkDerpi
public GenericImage getDerpi(String query) public GenericImage getDerpi(String query)
{ {
String res;
GenericImage image = new GenericImage(" ", " ", " "); GenericImage image = new GenericImage(" ", " ", " ");
query = query.trim(); query = query.trim();
query = query.replace(" ", ","); query = query.replace(" ", ",");
String res = HTTPUtils.sendGETRequest(mainURL + query + "&random_image=1&key=" + Ref.derpiKey); System.out.println(mainURL + query + "&sf=random&key=" + Ref.derpiKey);
if(query.startsWith("ID:"))
{
res = HTTPUtils.sendGETRequest("https://derpibooru.org/api/v1/json/images/" + query.substring(3));
}
else
{
res = HTTPUtils.sendGETRequest(mainURL + query + "&sf=random&key=" + Ref.derpiKey);
}
System.out.println(res);
if(res != null) if(res != null)
{ {
InitialRequest obj; InitialRequest obj;
@@ -43,7 +53,6 @@ public class NetworkDerpi
if(res != null) if(res != null)
{ {
String res2 = HTTPUtils.sendGETRequest("https://derpibooru.org/" + obj.id + ".json"); String res2 = HTTPUtils.sendGETRequest("https://derpibooru.org/" + obj.id + ".json");
image.editPostURL("https://derpibooru.org/" + obj.id); image.editPostURL("https://derpibooru.org/" + obj.id);
DerpiResponseObject imageObj = jsonParser_.fromJson(res2, DerpiResponseObject.class); DerpiResponseObject imageObj = jsonParser_.fromJson(res2, DerpiResponseObject.class);
+24 -8
View File
@@ -79,7 +79,7 @@ public class NetworkE6
// Static methods // // Static methods //
//////////////////// ////////////////////
// Requests a specific image, then returns a few. // Requests a specific image, then returns a few.
public GenericImage getE6(String input) public GenericImage getE6(String input, String sauceNaoDependant)
{ {
GenericImage image = new GenericImage("","",""); GenericImage image = new GenericImage("","","");
boolean blacklisted; boolean blacklisted;
@@ -92,7 +92,6 @@ public class NetworkE6
// tag by default. User-provided tags, therefore, will override it. // tag by default. User-provided tags, therefore, will override it.
// If order:score is provided, that will be honored over order:random. // If order:score is provided, that will be honored over order:random.
String res = HTTPUtils.sendGETRequest(API_ROOT + "tags=order:random%20" + input + "&limit=" + maxSearchResults_); String res = HTTPUtils.sendGETRequest(API_ROOT + "tags=order:random%20" + input + "&limit=" + maxSearchResults_);
System.out.println("LOOK HERE: " + res);
if(res != null) if(res != null)
{ {
@@ -108,7 +107,6 @@ public class NetworkE6
{ {
for(int i = 0; i < imageObj.posts.length; ++i) for(int i = 0; i < imageObj.posts.length; ++i)
{ {
System.out.println(imageObj.posts.length);
String [] TagsList = imageObj.posts[i].tags.general; String [] TagsList = imageObj.posts[i].tags.general;
blacklisted = false; blacklisted = false;
for(int j = 0; j < blacklist.length; j++) for(int j = 0; j < blacklist.length; j++)
@@ -159,12 +157,27 @@ public class NetworkE6
else else
{ {
source = source.substring(source.indexOf("/") + 2); source = source.substring(source.indexOf("/") + 2);
source = source.substring(0, source.indexOf('.')); source = "[" + source.substring(0, source.indexOf('.')) + "]";
if(source.equals("[pbs]"))
{
source = "[twitter-cdn]";
}
} }
sources += " [" + source + "](" + imageObj.posts[i].sources[k] + ") "; sources += " [" + source + "](" + imageObj.posts[i].sources[k] + ") ";
} }
} }
image.editDescriptionText("Score: " + imageObj.posts[i].score.total + "\n**Source:**" + sources); if(sources.equals(""))
{
sources = " Source not listed";
}
if(sauceNaoDependant.equals(""))
{
image.editDescriptionText("Score: " + imageObj.posts[i].score.total + "\n**Source:**" + sources);
}
else
{
image.editDescriptionText(sauceNaoDependant + "\nScore: " + imageObj.posts[i].score.total + "\n**Source:**" + sources);
}
} }
else else
{ {
@@ -183,14 +196,17 @@ public class NetworkE6
} }
else else
{ {
descTags = imageObj.posts[i].tags.general.toString(); for(int o = 0; o < imageObj.posts[i].tags.general.length - 1; o++)
{
descTags += imageObj.posts[i].tags.general[o] + ", ";
}
descTags += imageObj.posts[i].tags.general[imageObj.posts[i].tags.general.length-1] + "";
image.editFooterText("[Tags] " + descTags); image.editFooterText("[Tags] " + descTags);
} }
if(image.output().authorText != null) if(image.output().authorText != null)
{ {
System.out.println(image);
System.out.println(image.toString());
return image; return image;
} }
} }
+9 -3
View File
@@ -21,6 +21,12 @@ public class NetworkSauceNAO
private class SauceNAOResult private class SauceNAOResult
{ {
SauceNAOData data; SauceNAOData data;
SauceNAOHeader header;
}
private class SauceNAOHeader
{
double similarity;
} }
private class SauceNAOData private class SauceNAOData
@@ -30,21 +36,21 @@ public class NetworkSauceNAO
public GenericImage getSauce(String input) public GenericImage getSauce(String input)
{ {
double similarity;
input = input.trim(); input = input.trim();
input = input.replace("+", "%2B"); input = input.replace("+", "%2B");
input = input.replace(" ", "%20"); input = input.replace(" ", "%20");
String res = HTTPUtils.sendGETRequest(API_ROOT + input); String res = HTTPUtils.sendGETRequest(API_ROOT + input);
SauceNAOResponseObject sauce = jsonParser_.fromJson(res, SauceNAOResponseObject.class); SauceNAOResponseObject sauce = jsonParser_.fromJson(res, SauceNAOResponseObject.class);
String sauceUrl = sauce.results.get(0).data.ext_urls[0]; String sauceUrl = sauce.results.get(0).data.ext_urls[0];
similarity = sauce.results.get(0).header.similarity;
if(sauceUrl.startsWith("https://e621.net/post/show/")) if(sauceUrl.startsWith("https://e621.net/post/show/"))
{ {
return e6Sauce.getE6("id:" + sauceUrl.substring(27)); return e6Sauce.getE6("id:" + sauceUrl.substring(27), "Confidence: " + similarity + "%");
} }
GenericImage unknown = new GenericImage("", "",""); GenericImage unknown = new GenericImage("", "","");
return unknown; return unknown;
// return sauce.results.get(0).data.ext_urls[0];
} }
} }
+4 -3
View File
@@ -27,11 +27,11 @@ public class NetworkYoutube
public class YTInner public class YTInner
{ {
TYID id; YTID id;
YTSnippet snippet; YTSnippet snippet;
} }
public class TYID public class YTID
{ {
String videoId; String videoId;
} }
@@ -48,7 +48,8 @@ public class NetworkYoutube
input = input.replace("+", "%2B"); input = input.replace("+", "%2B");
input = input.replace(" ", "%20"); input = input.replace(" ", "%20");
String res = HTTPUtils.sendGETRequest(API_ROOT + input + "&order=viewCount&type=video&topicId=%2Fm%2F04rlf&videoDefinition=high&key=" + Ref.youtube); String res = HTTPUtils.sendGETRequest(API_ROOT + input +
"&order=viewCount&type=video&topicId=%2Fm%2F04rlf&videoDefinition=high&key=" + Ref.youtube);
YTOuter videoObj = jsonParser_.fromJson(res, YTOuter.class); YTOuter videoObj = jsonParser_.fromJson(res, YTOuter.class);
return "https://www.youtube.com/watch?v=" + videoObj.items.get(0).id.videoId; return "https://www.youtube.com/watch?v=" + videoObj.items.get(0).id.videoId;
} }