From d481fec0af33be4ace1c6df90a04b1e7b56d025d Mon Sep 17 00:00:00 2001 From: Matthew Cech Date: Sun, 3 Jan 2021 21:46:13 -0800 Subject: [PATCH] Added ability to reply with an optional image for bet history --- assets/config.csv | 3 ++- src/commands/beans/CommandBetHistory.java | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/assets/config.csv b/assets/config.csv index b2fb4b1..bffda29 100644 --- a/assets/config.csv +++ b/assets/config.csv @@ -73,7 +73,8 @@ "Localized Strings","BetBeansNotValid","That's not a valid bet!" "Localized Strings","BetBeansWin","You won %s beans!" "Localized Strings","BetHistoryInfo","Gives how many beans I've ~~stolen~~ won from your bets!" -"Localized Strings","BetHistoryOutput","I have %s treats from betting!" +"Localized Strings","BetHistoryOptionalPNGPath","" +"Localized Strings","BetHistoryOutput","I have %s beans from betting!" "Localized Strings","BlurryInfo","Blurs your icon or the icon of a friend you mentioned" "Localized Strings","BoopInfo","Kitty will react with a counter" "Localized Strings","BoopMultiple","%s booped several others - %s!" diff --git a/src/commands/beans/CommandBetHistory.java b/src/commands/beans/CommandBetHistory.java index 825eb20..84a4888 100644 --- a/src/commands/beans/CommandBetHistory.java +++ b/src/commands/beans/CommandBetHistory.java @@ -1,5 +1,7 @@ package commands.beans; +import java.io.File; + import core.Command; import core.LocStrings; import dataStructures.KittyChannel; @@ -9,6 +11,8 @@ import dataStructures.KittyRole; import dataStructures.KittyUser; import dataStructures.Response; import dataStructures.UserInput; +import utils.GlobalLog; +import utils.LogFilter; public class CommandBetHistory extends Command { @@ -20,6 +24,22 @@ public class CommandBetHistory extends Command @Override public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res) { + // Send primary response res.send(String.format(LocStrings.stub("BetHistoryOutput"), guild.beans.get())); + + // Look up extra information to see if we ahve a flair image + String optional = LocStrings.stub("BetHistoryOptionalPNGPath"); + if(optional != null && optional.length() > 0) + { + File responseImage = new File(optional); + if(responseImage.exists()) + { + res.sendFile(responseImage, ".png"); + } + else + { + GlobalLog.warn(LogFilter.Command, "Optional PNG image for bet history was specified, but the file could not be found."); + } + } } } \ No newline at end of file