Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* then educates the user about using slash commands, such as {@code /foo} instead.
*/
public final class SlashCommandEducator extends MessageReceiverAdapter {
private static final int MAX_COMMAND_LENGTH = 30;
private static final String SLASH_COMMAND_POPUP_ADVICE_PATH = "slashCommandPopupAdvice.png";
private static final Predicate<String> IS_MESSAGE_COMMAND = Pattern.compile("""
[.!?] #Start of message command
Expand All @@ -33,7 +34,8 @@ public void onMessageReceived(MessageReceivedEvent event) {
}

String content = event.getMessage().getContentRaw();
if (IS_MESSAGE_COMMAND.test(content)) {

if (IS_MESSAGE_COMMAND.test(content) && content.length() < MAX_COMMAND_LENGTH) {
sendAdvice(event.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ private static Stream<String> provideMessageCommands() {
}

private static Stream<String> provideOtherMessages() {
return Stream.of(" a ", "foo", "#foo", "/foo", "!!!", "?!?!?", "?", ".,-", "!f", "! foo");
return Stream.of(" a ", "foo", "#foo", "/foo", "!!!", "?!?!?", "?", ".,-", "!f", "! foo",
"thisIsAWordWhichLengthIsMoreThanThirtyLetterSoItShouldNotReply",
".isLetter and .isNumber are available");

}
}