=More package sorting

This commit is contained in:
Alex Stewart
2020-09-29 03:02:09 -04:00
parent 2872ab8b03
commit edaf312a93
21 changed files with 520 additions and 500 deletions
@@ -1,4 +1,4 @@
package commands.general;
package commands.beans;
import java.awt.Font;
import java.awt.FontMetrics;
@@ -1,4 +1,4 @@
package commands.general;
package commands.beans;
import java.util.Random;
@@ -1,25 +1,25 @@
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()));
}
package commands.beans;
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.general;
package commands.beans;
import core.Command;
import core.LocStrings;
@@ -1,4 +1,4 @@
package commands.general;
package commands.beans;
import core.Command;
import core.LocStrings;
@@ -1,35 +1,35 @@
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);
}
}
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);
}
}
@@ -1,43 +1,43 @@
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);
}
}
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);
}
}
@@ -1,33 +1,33 @@
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"));
}
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"));
}
}
@@ -1,136 +1,136 @@
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;
}
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;
}
}
@@ -1,4 +1,4 @@
package commands.general;
package commands.dev;
import core.Command;
import core.LocStrings;
@@ -1,60 +1,60 @@
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);
}
}
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);
}
}
}
@@ -1,89 +1,89 @@
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);
}
}
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);
}
}
@@ -1,4 +1,4 @@
package commands.general;
package commands.dev;
import core.Command;
import core.LocStrings;
@@ -1,71 +1,71 @@
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);
}
}
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);
}
}
@@ -1,4 +1,4 @@
package commands.general;
package commands.network;
import core.Command;
import core.LocStrings;
@@ -1,4 +1,4 @@
package commands.general;
package commands.network;
import core.Command;
import core.LocStrings;
@@ -1,4 +1,4 @@
package commands.general;
package commands.network;
import core.Command;
import core.LocStrings;
@@ -1,4 +1,4 @@
package commands.general;
package commands.network;
import core.Command;
import core.LocStrings;
@@ -1,4 +1,4 @@
package commands.general;
package commands.network;
import core.Command;
import core.LocStrings;
@@ -1,4 +1,4 @@
package commands.general;
package commands.network;
import java.io.File;
import java.io.IOException;
+20
View File
@@ -4,17 +4,37 @@ 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.*;