local image fetch
|
@ -147,6 +147,7 @@ public class Responder extends ListenerAdapter {
|
|||
Response response = (Response)temp;
|
||||
reply(response, event.getHook());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
EmbedBuilder builder = Ken.getInstance().getDefaultEmbed()
|
||||
.setColor(Color.RED)
|
||||
.setTitle(":x: **Error**")
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.dv8tion.jda.api.entities.Member;
|
|||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
import net.tylermurphy.ken.Ken;
|
||||
import net.tylermurphy.ken.api.Request;
|
||||
import net.tylermurphy.ken.command.Response;
|
||||
import net.tylermurphy.ken.command.annotation.Command;
|
||||
import net.tylermurphy.ken.command.annotation.Option;
|
||||
|
@ -33,8 +32,8 @@ public class CrabRave {
|
|||
}
|
||||
|
||||
private byte[] generateGif(User u) throws IOException, NullPointerException {
|
||||
BufferedImage crab = Ken.getInstance().getImageFetcher().getImage("https://cdn.tylermurphy.net/ken/crab.png", true);
|
||||
BufferedImage avatar = Ken.getInstance().getImageFetcher().getImage(u.getAvatarUrl(), false);
|
||||
BufferedImage crab = Ken.getInstance().getImageFetcher().getCdnImage("crab.png", true);
|
||||
BufferedImage avatar = Ken.getInstance().getImageFetcher().getRawImage(u.getAvatarUrl(), false);
|
||||
BufferedImage[] frames = new BufferedImage[26];
|
||||
for(int i = 0; i < frames.length; i++) {
|
||||
frames[i] = generateFrame(i, avatar, crab);
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.dv8tion.jda.api.entities.Member;
|
|||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
import net.tylermurphy.ken.Ken;
|
||||
import net.tylermurphy.ken.api.Request;
|
||||
import net.tylermurphy.ken.command.annotation.Command;
|
||||
import net.tylermurphy.ken.command.annotation.Option;
|
||||
import net.tylermurphy.ken.command.Response;
|
||||
|
@ -28,6 +27,7 @@ public class Eject {
|
|||
byte[] data = generateGif(ejected.getUser());
|
||||
return Response.success(ejected.getEffectiveName() +" was ejected by "+sender.getEffectiveName()).setFile(data, "eject.gif");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return Response.error("Failed to generate gif");
|
||||
}
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ public class Eject {
|
|||
else
|
||||
message = u.getName() + " was not An Impostor";
|
||||
|
||||
BufferedImage space = Ken.getInstance().getImageFetcher().getImage("https://cdn.tylermurphy.net/ken/space.jpg", true);
|
||||
BufferedImage avatar = Ken.getInstance().getImageFetcher().getImage(u.getAvatarUrl(), false);
|
||||
BufferedImage space = Ken.getInstance().getImageFetcher().getCdnImage("space.jpg", true);
|
||||
BufferedImage avatar = Ken.getInstance().getImageFetcher().getRawImage(u.getAvatarUrl(), false);
|
||||
|
||||
BufferedImage[] frames = new BufferedImage[30];
|
||||
for (int i = 0; i < frames.length; i++) {
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.dv8tion.jda.api.entities.Member;
|
|||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
import net.tylermurphy.ken.Ken;
|
||||
import net.tylermurphy.ken.api.Request;
|
||||
import net.tylermurphy.ken.command.Response;
|
||||
import net.tylermurphy.ken.command.annotation.Command;
|
||||
import net.tylermurphy.ken.command.annotation.Option;
|
||||
|
@ -12,7 +11,6 @@ import net.tylermurphy.ken.util.GifSequenceWriter;
|
|||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.stream.ImageOutputStream;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
@ -34,9 +32,9 @@ public class GayMeme {
|
|||
}
|
||||
|
||||
private byte[] generateGif(User u) throws IOException, NullPointerException {
|
||||
BufferedImage avatar = Ken.getInstance().getImageFetcher().getImage(u.getAvatarUrl(), false);
|
||||
BufferedImage background = Ken.getInstance().getImageFetcher().getImage("https://cdn.tylermurphy.net/ken/theMoreYouKnow.png", true);
|
||||
BufferedImage gay = Ken.getInstance().getImageFetcher().getImage("https://cdn.tylermurphy.net/ken/gay.png", true);
|
||||
BufferedImage avatar = Ken.getInstance().getImageFetcher().getRawImage(u.getAvatarUrl(), false);
|
||||
BufferedImage background = Ken.getInstance().getImageFetcher().getCdnImage("theMoreYouKnow.png", true);
|
||||
BufferedImage gay = Ken.getInstance().getImageFetcher().getCdnImage("gay.png", true);
|
||||
|
||||
BufferedImage[] frames = new BufferedImage[40];
|
||||
for(int i = 0; i < frames.length; i++) {
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.dv8tion.jda.api.entities.Member;
|
|||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
import net.tylermurphy.ken.Ken;
|
||||
import net.tylermurphy.ken.api.Request;
|
||||
import net.tylermurphy.ken.command.Response;
|
||||
import net.tylermurphy.ken.command.annotation.Command;
|
||||
import net.tylermurphy.ken.command.annotation.Option;
|
||||
|
@ -33,8 +32,8 @@ public class Headpat {
|
|||
}
|
||||
|
||||
private byte[] generateGif(User u) throws IOException, NullPointerException {
|
||||
BufferedImage hand = Ken.getInstance().getImageFetcher().getImage("https://cdn.tylermurphy.net/ken/headpat.png", true);
|
||||
BufferedImage avatar = Ken.getInstance().getImageFetcher().getImage(u.getAvatarUrl(), false);
|
||||
BufferedImage hand = Ken.getInstance().getImageFetcher().getCdnImage("headpat.png", true);
|
||||
BufferedImage avatar = Ken.getInstance().getImageFetcher().getRawImage(u.getAvatarUrl(), false);
|
||||
|
||||
BufferedImage[] frames = new BufferedImage[5];
|
||||
for(int i = 0; i < frames.length; i++) {
|
||||
|
|
|
@ -32,8 +32,8 @@ public class Wank {
|
|||
}
|
||||
|
||||
private byte[] generateGif(User u) throws IOException {
|
||||
BufferedImage wank = Ken.getInstance().getImageFetcher().getImage("https://cdn.tylermurphy.net/ken/laptop.png", true);
|
||||
BufferedImage avatar = Ken.getInstance().getImageFetcher().getImage(u.getAvatarUrl(), false);
|
||||
BufferedImage wank = Ken.getInstance().getImageFetcher().getCdnImage("laptop.png", true);
|
||||
BufferedImage avatar = Ken.getInstance().getImageFetcher().getRawImage(u.getAvatarUrl(), false);
|
||||
|
||||
BufferedImage[] frames = new BufferedImage[4];
|
||||
for (int i = 0; i < frames.length; i++) {
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package net.tylermurphy.ken.util;
|
||||
|
||||
import net.tylermurphy.ken.Ken;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
|
@ -12,7 +15,21 @@ public class ImageFetcher {
|
|||
|
||||
private final Map<String,BufferedImage> CACHE = new HashMap<>();
|
||||
|
||||
public BufferedImage getImage(String url, boolean cache) throws IOException {
|
||||
public BufferedImage getCdnImage(String name, boolean cache) throws IOException {
|
||||
if(Ken.getInstance().getConfig().getBoolean("fetchLocal")) {
|
||||
if(CACHE.containsKey(name)) return CACHE.get(name);
|
||||
InputStream in = Ken.getInstance().getResource("cdn/"+name);
|
||||
if(in == null) return null;
|
||||
BufferedImage image = ImageIO.read(in);
|
||||
if(cache && image != null) CACHE.put(name, image);
|
||||
return image;
|
||||
} else {
|
||||
String url = Ken.getInstance().getConfig().getString("cdn") + name;
|
||||
return getRawImage(url, cache);
|
||||
}
|
||||
}
|
||||
|
||||
public BufferedImage getRawImage(String url, boolean cache) throws IOException {
|
||||
if(CACHE.containsKey(url)) return CACHE.get(url);
|
||||
HttpURLConnection connection = getConnection(url);
|
||||
BufferedImage image = ImageIO.read(connection.getInputStream());
|
||||
|
|
BIN
src/main/resources/cdn/coin_heads.png
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
src/main/resources/cdn/coin_tails.png
Normal file
After Width: | Height: | Size: 51 KiB |
BIN
src/main/resources/cdn/crab.png
Normal file
After Width: | Height: | Size: 2.1 MiB |
BIN
src/main/resources/cdn/d12_1.png
Normal file
After Width: | Height: | Size: 8.3 KiB |
BIN
src/main/resources/cdn/d12_10.png
Normal file
After Width: | Height: | Size: 9.4 KiB |
BIN
src/main/resources/cdn/d12_11.png
Normal file
After Width: | Height: | Size: 8.6 KiB |
BIN
src/main/resources/cdn/d12_12.png
Normal file
After Width: | Height: | Size: 9.6 KiB |
BIN
src/main/resources/cdn/d12_2.png
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
src/main/resources/cdn/d12_3.png
Normal file
After Width: | Height: | Size: 9 KiB |
BIN
src/main/resources/cdn/d12_4.png
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
src/main/resources/cdn/d12_5.png
Normal file
After Width: | Height: | Size: 9.3 KiB |
BIN
src/main/resources/cdn/d12_6.png
Normal file
After Width: | Height: | Size: 9 KiB |
BIN
src/main/resources/cdn/d12_7.png
Normal file
After Width: | Height: | Size: 8.5 KiB |
BIN
src/main/resources/cdn/d12_8.png
Normal file
After Width: | Height: | Size: 9.5 KiB |
BIN
src/main/resources/cdn/d12_9.png
Normal file
After Width: | Height: | Size: 9.3 KiB |
BIN
src/main/resources/cdn/d20_1.png
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
src/main/resources/cdn/d20_10.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
src/main/resources/cdn/d20_11.png
Normal file
After Width: | Height: | Size: 9.3 KiB |
BIN
src/main/resources/cdn/d20_12.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
src/main/resources/cdn/d20_13.png
Normal file
After Width: | Height: | Size: 9.9 KiB |
BIN
src/main/resources/cdn/d20_14.png
Normal file
After Width: | Height: | Size: 9.9 KiB |
BIN
src/main/resources/cdn/d20_15.png
Normal file
After Width: | Height: | Size: 9.8 KiB |
BIN
src/main/resources/cdn/d20_16.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
src/main/resources/cdn/d20_17.png
Normal file
After Width: | Height: | Size: 9.7 KiB |
BIN
src/main/resources/cdn/d20_18.png
Normal file
After Width: | Height: | Size: 9.8 KiB |
BIN
src/main/resources/cdn/d20_19.png
Normal file
After Width: | Height: | Size: 9.8 KiB |
BIN
src/main/resources/cdn/d20_2.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
src/main/resources/cdn/d20_20.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
src/main/resources/cdn/d20_3.png
Normal file
After Width: | Height: | Size: 9.6 KiB |
BIN
src/main/resources/cdn/d20_4.png
Normal file
After Width: | Height: | Size: 9.6 KiB |
BIN
src/main/resources/cdn/d20_5.png
Normal file
After Width: | Height: | Size: 9.7 KiB |
BIN
src/main/resources/cdn/d20_6.png
Normal file
After Width: | Height: | Size: 9.6 KiB |
BIN
src/main/resources/cdn/d20_7.png
Normal file
After Width: | Height: | Size: 9.3 KiB |
BIN
src/main/resources/cdn/d20_8.png
Normal file
After Width: | Height: | Size: 9.7 KiB |
BIN
src/main/resources/cdn/d20_9.png
Normal file
After Width: | Height: | Size: 9.8 KiB |
BIN
src/main/resources/cdn/d6_1.png
Normal file
After Width: | Height: | Size: 5 KiB |
BIN
src/main/resources/cdn/d6_2.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
src/main/resources/cdn/d6_3.png
Normal file
After Width: | Height: | Size: 6 KiB |
BIN
src/main/resources/cdn/d6_4.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
BIN
src/main/resources/cdn/d6_5.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
src/main/resources/cdn/d6_6.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
src/main/resources/cdn/d8_1.png
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
src/main/resources/cdn/d8_2.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
src/main/resources/cdn/d8_3.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
src/main/resources/cdn/d8_4.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
src/main/resources/cdn/d8_5.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
src/main/resources/cdn/d8_6.png
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
src/main/resources/cdn/d8_7.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
src/main/resources/cdn/d8_8.png
Normal file
After Width: | Height: | Size: 8.2 KiB |
BIN
src/main/resources/cdn/gay.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
src/main/resources/cdn/headpat.png
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
src/main/resources/cdn/laptop.png
Normal file
After Width: | Height: | Size: 210 KiB |
BIN
src/main/resources/cdn/space.jpg
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
src/main/resources/cdn/theMoreYouKnow.png
Normal file
After Width: | Height: | Size: 406 KiB |
|
@ -45,11 +45,15 @@ botName: "Ken"
|
|||
# Example: "ChFRPDF"
|
||||
supportServer: ""
|
||||
|
||||
# Send welcome messages when a player joins the server
|
||||
welcomeMessages: true
|
||||
# This is the cdn that will contain all KenBoReborn images, I host one myself so there is no
|
||||
# need for you to use your own. If you want, you can use your own. A cdn is required because discord
|
||||
# requires a url for embeds instead of just uploading an image.
|
||||
cdn: "https://cdn.tylermurphy.net/ken/"
|
||||
|
||||
# Send level up messages when a player levels up
|
||||
levelMessages: true
|
||||
# Fetch image url. For the gif generation commands, instead of sending discord a url to a cdn, Ken has to
|
||||
# manually pull images to work on them to create the gifs. For most people, you can just keep it as the cdn, and
|
||||
# have images automatically update. But if you want, you can set images to locally fetch instead from inside the jar.
|
||||
fetchLocal: false
|
||||
|
||||
# The RGB color value of the discord bot. Used for bot theming.
|
||||
colors:
|
||||
|
|