Skip to content

Commit

Permalink
group new regexes better
Browse files Browse the repository at this point in the history
  • Loading branch information
MicrocontrollersDev committed Jun 18, 2024
1 parent 688b7f3 commit c60466a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class KarmaRemover implements ChatReceiveModule {
@Override
public void onMessageReceived(@NotNull ClientChatReceivedEvent event) {
String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText());
if (getLanguage().cancelKarmaMessagesRegex.matcher(message).matches()) {
if (getLanguage().chatCleanerKarmaMessagesRegex.matcher(message).matches()) {
event.setCanceled(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ public class LanguageData {
*/
private String autoQueuePrefixGlobal = "^(?:You died! .+|YOU DIED! .+|You have been eliminated!|You won! .+|YOU WON! .+)$";

private String casualGameEnd = "^(?:MINOR EVENT! .+ in .+ ended|DRAGON EGG OVER! Earned [\\d,]+XP [\\d,]g clicking the egg \\d+ times|GIANT CAKE! Event ended! Cake's gone!|PIT EVENT ENDED: .+ \\[INFO\\])$";

private String autoFriendPattern = "Friend request from (?<name>.+)\\[ACCEPT] - \\[DENY] - \\[IGNORE].*";
private String autoAfkReplyPattern = "^From (\\[.+?] )?(.+?): .+$";

private String chatCleanerKarmaMessages = "^\\+(?<karma>\\d)+ Karma!$";
private String chatCleanerJoin = "(?:sled into|slid into|joined|spooked into) the lobby";
private String chatCleanerTicketAnnouncer = "^(?<player>(?!You )\\w{1,16} )has found an? .+$";
private String chatCleanerSoulWellFind = "^.+ has found .+ in the Soul Well!$";
Expand Down Expand Up @@ -100,8 +99,8 @@ public class LanguageData {

private String hypixelLevelUp = "You are now Hypixel Level (?<level>\\d+)!";

private String casualGameEnd = "^(?:MINOR EVENT! .+ in .+ ended|DRAGON EGG OVER! Earned [\\d,]+XP [\\d,]g clicking the egg \\d+ times|GIANT CAKE! Event ended! Cake's gone!|PIT EVENT ENDED: .+ \\[INFO\\])$";
private String cancelGgMessages = "^(?:.* )?(?:\\[.+] )?\\w{1,16}(?: .+)?: (?:❤|gg|GG|gf|Good Game|Good Fight|Good Round! :D|Have a good day!|<3|AutoGG By Sk1er!|AutoGG By Hytils Reborn!|gf|Good Fight|Good Round|:D|Well Played!|wp)$";
private String cancelKarmaMessages = "^\\+(?<karma>\\d)+ Karma!$";
private String cancelGlMessages = "(?!.+: )(gl|glhf|good luck|have a good game|autogl by sk1er)";

public String autoChatReportConfirm = "Please type /report confirm to log your report for staff review.";
Expand All @@ -118,11 +117,10 @@ public class LanguageData {
*/
public Pattern autoQueuePrefixGlobalRegex;

public Pattern casualGameEndRegex;

public Pattern autoFriendPatternRegex;
public Pattern autoAfkReplyPatternRegex;

public Pattern chatCleanerKarmaMessagesRegex;
public Pattern chatCleanerJoinRegex;
public Pattern chatCleanerTicketAnnouncerRegex;
public Pattern chatCleanerSoulWellFindRegex;
Expand Down Expand Up @@ -170,8 +168,8 @@ public class LanguageData {

public Pattern hypixelLevelUpRegex;

public Pattern casualGameEndRegex;
public Pattern cancelGgMessagesRegex;
public Pattern cancelKarmaMessagesRegex;
public Pattern cancelGlMessagesRegex;

public Pattern gameBossbarAdvertisementRegex;
Expand All @@ -185,11 +183,10 @@ public void initialize() {

autoQueuePrefixGlobalRegex = Pattern.compile(autoQueuePrefixGlobal);

casualGameEndRegex = Pattern.compile(casualGameEnd);

autoFriendPatternRegex = Pattern.compile(autoFriendPattern);
autoAfkReplyPatternRegex = Pattern.compile(autoAfkReplyPattern);

chatCleanerKarmaMessagesRegex = Pattern.compile(chatCleanerKarmaMessages);
chatCleanerJoinRegex = Pattern.compile(chatCleanerJoin);
chatCleanerTicketAnnouncerRegex = Pattern.compile(chatCleanerTicketAnnouncer);
chatCleanerSoulWellFindRegex = Pattern.compile(chatCleanerSoulWellFind);
Expand Down Expand Up @@ -237,8 +234,8 @@ public void initialize() {

hypixelLevelUpRegex = Pattern.compile(hypixelLevelUp);

casualGameEndRegex = Pattern.compile(casualGameEnd);
cancelGgMessagesRegex = Pattern.compile(cancelGgMessages);
cancelKarmaMessagesRegex = Pattern.compile(cancelKarmaMessages);
cancelGlMessagesRegex = Pattern.compile(cancelGlMessages, Pattern.CASE_INSENSITIVE);

gameBossbarAdvertisementRegex = Pattern.compile(gameBossbarAdvertisement);
Expand Down

0 comments on commit c60466a

Please sign in to comment.