From 0d3c16c4da78494242354a5611a4f8c430b448cd Mon Sep 17 00:00:00 2001 From: Matthew Cech Date: Thu, 26 Mar 2020 16:49:42 -0700 Subject: [PATCH 1/3] = Updated boop conditions to not track people booping other people --- src/commands/general/CommandBoop.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/commands/general/CommandBoop.java b/src/commands/general/CommandBoop.java index cb9104b..b54bc02 100644 --- a/src/commands/general/CommandBoop.java +++ b/src/commands/general/CommandBoop.java @@ -68,22 +68,23 @@ public class CommandBoop extends Command { if(input.mentions == null) { + // No one is booped, just the bot! boopTracker.applyBoop(); res.send(String.format(LocStrings.stub("BoopStandard"), user.name, boopTracker.howMany())); } else { + // When someone boops one other person if(input.mentions.length == 1) { - boopTracker.applyBoop(); res.send(String.format(LocStrings.stub("BoopPerson"), user.name, input.mentions[0].name)); return; } + // A number of people have been booped String booped = ""; for(int i = 0; i < input.mentions.length; i++) { - boopTracker.applyBoop(); if(i < input.mentions.length-1) booped += input.mentions[i].name + ", "; else From 6ff38f09ebc1eb74a6df0da09cb2552c2ae4dfea Mon Sep 17 00:00:00 2001 From: Matthew Cech Date: Thu, 26 Mar 2020 17:46:30 -0700 Subject: [PATCH 2/3] + Added check for edge case of backtick escape. Added concept for only trimming ends, tho it remains commented out. --- src/network/NetworkColiru.java | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/network/NetworkColiru.java b/src/network/NetworkColiru.java index 6cf23fd..ceb475c 100644 --- a/src/network/NetworkColiru.java +++ b/src/network/NetworkColiru.java @@ -6,14 +6,41 @@ public class NetworkColiru { public String compileCPlusPlus(String query) { - // Escape characters that need escaping. - // Primarily types of whitespace. + // Escape characters that need escaping - mostly whitespace. query = query.replace("\\n", "\\\\n"); query = query.replace("\\t", "\\\\t"); query = query.replace("\n", "\\n"); query = query.replace("\"", "\\\""); query = query.replace("\t", "\\t"); + query = query.replace("`", ""); + +// // replace backticks on only the edges of the string. +// StringBuilder s = new StringBuilder(query); +// +// for(int i = 0; i < s.length(); ++i) +// { +// if(s.charAt(i) != '`') +// break; +// +// s.setCharAt(i, ' '); +// } +// +// for(int i = s.length() - 1; i >= 0; --i) +// { +// if(s.charAt(i) != '`') +// break; +// +// s.setCharAt(i, ' '); +// } +// +// query = s.toString().trim(); + // Determine if the query is effectively empty or not. If it is, don't attempt to compile it. + if(query.trim().length() == 0) + { + return "I can't compile nothing!"; + } + // Send the compilation request! String result = HTTPUtils.sendPOSTRequest("http://coliru.stacked-crooked.com/compile" , "{ \"cmd\": \"g++ main.cpp && ./a.out\", \"src\": \"" + query + "\" }"); From 844edc8084ca5e3d33b0774a844c5297f623e455 Mon Sep 17 00:00:00 2001 From: Matthew Cech Date: Thu, 26 Mar 2020 17:53:47 -0700 Subject: [PATCH 3/3] = Grammar issue --- src/network/NetworkColiru.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/NetworkColiru.java b/src/network/NetworkColiru.java index ceb475c..5357b7b 100644 --- a/src/network/NetworkColiru.java +++ b/src/network/NetworkColiru.java @@ -48,7 +48,7 @@ public class NetworkColiru // If we got a valid response... if(!result.isEmpty()) { - result = "Here's what happened when I went to compiled that! \n```" + result + "```"; + result = "Here's what happened when I went to compile that! \n```" + result + "```"; } return result;