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/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/LavaPlayerJar-0.0.1-jar-with-dependencies.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"/>
</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;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
@@ -64,8 +66,6 @@ public class CommandBeansShow extends Command
long calcBean = beans;
System.out.println("BEANS: " + beans);
long thousands = beans / 1000;
calcBean = beans % 1000;
long hundreds = (calcBean / 100);
@@ -76,6 +76,8 @@ public class CommandBeansShow extends Command
BufferedImage beanImage = new BufferedImage(baseWidth, baseHeight, BufferedImage.TYPE_INT_ARGB);
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++)
{
@@ -115,9 +117,22 @@ public class CommandBeansShow extends Command
}
Font beanFont = new Font("font", Font.BOLD, 45);
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"));
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)
{
image = searcher.getE6(input.args + " rating:safe");
image = searcher.getE6(input.args + " rating:safe", "");
try
{
response = image.output();
@@ -58,7 +58,7 @@ public class CommandE6 extends Command
{
try
{
response = searcher.getE6(input.args).output();
response = searcher.getE6(input.args, "").output();
res.send(response);
}
catch(Exception e)
+8 -2
View File
@@ -23,7 +23,13 @@ public class CommandGetSauce extends Command
@Override
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
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);
@@ -63,7 +64,8 @@ public class KittyGuild extends DatabaseTrackedObject
}
// 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);
this.uniqueID = uniqueID;
+12 -3
View File
@@ -7,7 +7,7 @@ import utils.*;
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 class DerpiResponseObject
@@ -24,10 +24,20 @@ public class NetworkDerpi
public GenericImage getDerpi(String query)
{
String res;
GenericImage image = new GenericImage(" ", " ", " ");
query = query.trim();
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)
{
InitialRequest obj;
@@ -43,7 +53,6 @@ public class NetworkDerpi
if(res != null)
{
String res2 = HTTPUtils.sendGETRequest("https://derpibooru.org/" + obj.id + ".json");
image.editPostURL("https://derpibooru.org/" + obj.id);
DerpiResponseObject imageObj = jsonParser_.fromJson(res2, DerpiResponseObject.class);
+24 -8
View File
@@ -79,7 +79,7 @@ public class NetworkE6
// Static methods //
////////////////////
// Requests a specific image, then returns a few.
public GenericImage getE6(String input)
public GenericImage getE6(String input, String sauceNaoDependant)
{
GenericImage image = new GenericImage("","","");
boolean blacklisted;
@@ -92,7 +92,6 @@ public class NetworkE6
// tag by default. User-provided tags, therefore, will override it.
// 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_);
System.out.println("LOOK HERE: " + res);
if(res != null)
{
@@ -108,7 +107,6 @@ public class NetworkE6
{
for(int i = 0; i < imageObj.posts.length; ++i)
{
System.out.println(imageObj.posts.length);
String [] TagsList = imageObj.posts[i].tags.general;
blacklisted = false;
for(int j = 0; j < blacklist.length; j++)
@@ -159,12 +157,27 @@ public class NetworkE6
else
{
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] + ") ";
}
}
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
{
@@ -183,14 +196,17 @@ public class NetworkE6
}
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);
}
if(image.output().authorText != null)
{
System.out.println(image);
System.out.println(image.toString());
return image;
}
}
+9 -3
View File
@@ -21,6 +21,12 @@ public class NetworkSauceNAO
private class SauceNAOResult
{
SauceNAOData data;
SauceNAOHeader header;
}
private class SauceNAOHeader
{
double similarity;
}
private class SauceNAOData
@@ -30,21 +36,21 @@ public class NetworkSauceNAO
public GenericImage getSauce(String input)
{
double similarity;
input = input.trim();
input = input.replace("+", "%2B");
input = input.replace(" ", "%20");
String res = HTTPUtils.sendGETRequest(API_ROOT + input);
SauceNAOResponseObject sauce = jsonParser_.fromJson(res, SauceNAOResponseObject.class);
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/"))
{
return e6Sauce.getE6("id:" + sauceUrl.substring(27));
return e6Sauce.getE6("id:" + sauceUrl.substring(27), "Confidence: " + similarity + "%");
}
GenericImage unknown = new GenericImage("", "","");
return unknown;
// return sauce.results.get(0).data.ext_urls[0];
}
}
+5 -4
View File
@@ -27,11 +27,11 @@ public class NetworkYoutube
public class YTInner
{
TYID id;
YTID id;
YTSnippet snippet;
}
public class TYID
public class YTID
{
String videoId;
}
@@ -48,8 +48,9 @@ public class NetworkYoutube
input = input.replace("+", "%2B");
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);
return "https://www.youtube.com/watch?v=" + videoObj.items.get(0).id.videoId;
}
}
}