From 0912034c2f1656a76c709f563ae297589a1cb701 Mon Sep 17 00:00:00 2001 From: Matthew Cech Date: Sat, 13 Apr 2019 12:34:35 -0700 Subject: [PATCH] = Cleaning up edge cases --- localization.config | 9 ++++++--- src/commands/CommandColiru.java | 6 ++++++ src/commands/CommandEightBall.java | 3 +++ src/commands/CommandInfo.java | 5 ++--- src/commands/CommandJDoodle.java | 6 ++++++ src/commands/CommandPollVote.java | 3 ++- src/commands/CommandRPG.java | 4 +++- src/core/Localizer.java | 2 +- src/core/ObjectBuilderFactory.java | 2 +- 9 files changed, 30 insertions(+), 10 deletions(-) diff --git a/localization.config b/localization.config index 436b248..8970ef7 100644 --- a/localization.config +++ b/localization.config @@ -28,9 +28,11 @@ Your role is= Changed %s to role `%s`!= [CommandColiru] +Please provide some c++ code to attempt to compile!= Will try to compile any c++ code you put in! Supports up to C++14 standard, uses g++.= [CommandJDoodle] +Please provide some java code to get it compiled!= Will compile any java code you put in! Supports Java 1.8= [CommandChangeIndicator] @@ -48,10 +50,10 @@ Yeet yourself or yeet a friend with @!= [CommandPollVote] There is no poll running!= -You already voted= %s That's not a vaild vote!= That's not a vaild number!= Vote in a poll with the choice number, won't work if no poll is running, you can't change your vote once you have cast it! Be careful!= +You already voted!= You successfully voted for= [CommandShutdown] @@ -118,8 +120,8 @@ Woah! %s booped me! That's %s total!= %s booped several others - %s!= [CommandInfo] -Provides author info and a link to Kitty's website= -I'm made by `Rin#8904` and `Reverie Wisp#3703`!\nYou can find more info about me along with a Patreon link to support us and GitHub link for filing bugs https://www.rinsnowmew.com/bot/= +I'm a Java application written with JDA! Check out my repo at = +Provides some extra info about KittyBot= [CommandPing] Pong!= @@ -140,6 +142,7 @@ Concentrate and ask again.= Signs point to yes.= Don't count on it.= Yes.= +Hmm? You'll need to ask a question!= My reply is no.= Most likely.= Reply hazy, try again.= diff --git a/src/commands/CommandColiru.java b/src/commands/CommandColiru.java index d16e066..047f5cc 100644 --- a/src/commands/CommandColiru.java +++ b/src/commands/CommandColiru.java @@ -17,6 +17,12 @@ public class CommandColiru extends Command @Override public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res) { + if(input.args.trim().length() < 1) + { + res.Call(Localizer.Stub("Please provide some c++ code to attempt to compile!")); + return; + } + res.Call(compiler.compileCPlus(input.args)); } diff --git a/src/commands/CommandEightBall.java b/src/commands/CommandEightBall.java index 9ec450f..81dd865 100644 --- a/src/commands/CommandEightBall.java +++ b/src/commands/CommandEightBall.java @@ -40,6 +40,9 @@ public class CommandEightBall extends Command @Override public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res) { + if(input.args.trim().length() < 1) + res.Call(Localizer.Stub("Hmm? You'll need to ask a question!")); + res.Call(answers[(int) (Math.random()*answers.length)]); } } diff --git a/src/commands/CommandInfo.java b/src/commands/CommandInfo.java index 568ad14..0de7bc5 100644 --- a/src/commands/CommandInfo.java +++ b/src/commands/CommandInfo.java @@ -15,12 +15,11 @@ public class CommandInfo extends Command public CommandInfo(KittyRole level, KittyRating rating) { super(level, rating); } @Override - public String HelpText() { return Localizer.Stub("Provides author info and a link to Kitty's website"); } + public String HelpText() { return Localizer.Stub("Provides some extra info about KittyBot"); } @Override public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res) { - String info = Localizer.Stub("I'm made by `Rin#8904` and `Reverie Wisp#3703`!\nYou can find more info about me along with a Patreon link to support us and GitHub link for filing bugs https://www.rinsnowmew.com/bot/"); - res.Call(info); + res.Call(Localizer.Stub("I'm a Java application written with JDA! Check out my repo at ")); } } \ No newline at end of file diff --git a/src/commands/CommandJDoodle.java b/src/commands/CommandJDoodle.java index 9d7b146..0873c7f 100644 --- a/src/commands/CommandJDoodle.java +++ b/src/commands/CommandJDoodle.java @@ -17,6 +17,12 @@ public class CommandJDoodle extends Command @Override public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res) { + if(input.args.trim().length() < 1) + { + res.Call(Localizer.Stub("Please provide some java code to get it compiled!")); + return; + } + res.Call(compiler.compileJava(input.args)); } } diff --git a/src/commands/CommandPollVote.java b/src/commands/CommandPollVote.java index 761ff67..6ddde95 100644 --- a/src/commands/CommandPollVote.java +++ b/src/commands/CommandPollVote.java @@ -17,7 +17,7 @@ public class CommandPollVote extends Command { if(guild.hasVoted.contains(user.uniqueID)) { - res.Call(Localizer.Stub("You already voted")); + res.Call(Localizer.Stub("You already voted!")); return; } try @@ -41,6 +41,7 @@ public class CommandPollVote extends Command return; } } + res.Call(Localizer.Stub("There is no poll running!")); } } diff --git a/src/commands/CommandRPG.java b/src/commands/CommandRPG.java index 255d460..7821812 100644 --- a/src/commands/CommandRPG.java +++ b/src/commands/CommandRPG.java @@ -31,7 +31,9 @@ public class CommandRPG extends Command { if(input.args == null || input.args.length() == 0) { - res.Call(HelpText()); + String output = HelpText(); + System.out.println("Out: |" + output + "|"); + res.Call(output); return; } diff --git a/src/core/Localizer.java b/src/core/Localizer.java index 85c8b2b..beb86a0 100644 --- a/src/core/Localizer.java +++ b/src/core/Localizer.java @@ -92,7 +92,7 @@ public class Localizer return input; String value = stringStore.GetKey(input); - if(value == null || value.length() < 1) + if(value == null || value.trim().length() < 1) return input; return value; diff --git a/src/core/ObjectBuilderFactory.java b/src/core/ObjectBuilderFactory.java index c709df4..448e3cf 100644 --- a/src/core/ObjectBuilderFactory.java +++ b/src/core/ObjectBuilderFactory.java @@ -312,7 +312,7 @@ public class ObjectBuilderFactory manager.Register("results", new CommandPollResults(KittyRole.General, KittyRating.Safe)); manager.Register("showpoll", new CommandPollShow(KittyRole.General, KittyRating.Safe)); manager.Register("wolfram", new CommandWolfram(KittyRole.General, KittyRating.Safe)); - manager.Register(new String[] {"c++", "g++", "cplus",}, new CommandColiru(KittyRole.General, KittyRating.Safe)); + manager.Register(new String[] {"c++", "g++", "cplus","cpp"}, new CommandColiru(KittyRole.General, KittyRating.Safe)); manager.Register(new String[] {"java", "jdoodle" }, new CommandJDoodle(KittyRole.General, KittyRating.Safe)); manager.Register("beans", new CommandBeansShow(KittyRole.General, KittyRating.Safe)); manager.Register("role", new CommandRole(KittyRole.General, KittyRating.Safe));