Skip to content

Commit

Permalink
simple auto afk reply
Browse files Browse the repository at this point in the history
  • Loading branch information
MicrocontrollersDev committed Jun 17, 2024
1 parent 0870f26 commit b503bca
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/org/polyfrost/hytils/config/HytilsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,20 @@ public class HytilsConfig extends Config {
)
public static boolean autoPartyWarpConfirm;

@Switch(
name = "Auto Reply when AFK",
description = "Automatically sends a reply of your choosing when you are AFK in Limbo.",
category = "Chat", subcategory = "Automatic"
)
public static boolean autoReplyAfk;

@Text(
name = "Auto Reply Message",
category = "Chat", subcategory = "Automatic",
size = 2
)
public static String autoReplyAfkMessage = "Hey, I am currently AFK!";

@Switch(
name = "Game Status Restyle",
description = "Replace common game status messages with a new style.\n§eExamples:\n§a§l+ §bSteve §e(§b1§e/§b12§e)\n§c§l- §bSteve§r\n§e§l* §aGame starts in §b§l5 §aseconds.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public ChatHandler() {
this.registerModule(new WhitePrivateMessages());

// Triggers
this.registerModule(new AutoAfkReply());
this.registerModule(new AutoChatReportConfirm());
this.registerModule(new AutoChatReportConfirm());
this.registerModule(new AutoChatSwapper());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Hytils Reborn - Hypixel focused Quality of Life mod.
* Copyright (C) 2020, 2021, 2022, 2023 Polyfrost, Sk1er LLC and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.polyfrost.hytils.handlers.chat.modules.triggers;

import cc.polyfrost.oneconfig.libs.universal.UChat;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import org.jetbrains.annotations.NotNull;
import org.polyfrost.hytils.config.HytilsConfig;
import org.polyfrost.hytils.handlers.chat.ChatReceiveModule;

import java.util.regex.Matcher;

public class AutoAfkReply implements ChatReceiveModule {
@Override
public void onMessageReceived(@NotNull ClientChatReceivedEvent event) {
if (getLocraw() != null && !getLocraw().getServerId().equals("limbo")) return;
String message = event.message.getFormattedText();
Matcher matcher = getLanguage().autoAfkReplyPatternRegex.matcher(message);
if (matcher.find(0)) {
UChat.say("/r " + HytilsConfig.autoReplyAfkMessage);
}
}

@Override
public boolean isEnabled() {
return HytilsConfig.autoReplyAfk;
}

@Override
public int getPriority() {
return -1;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class LanguageData {
private String autoQueuePrefixGlobal = "^(?:You died! .+|YOU DIED! .+|You have been eliminated!|You won! .+|YOU WON! .+)$";

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

private String chatCleanerJoin = "(?:sled into|slid into|joined|spooked into) the lobby";
private String chatCleanerTicketAnnouncer = "^(?<player>(?!You )\\w{1,16} )has found an? .+$";
Expand Down Expand Up @@ -114,6 +115,7 @@ public class LanguageData {
public Pattern autoQueuePrefixGlobalRegex;

public Pattern autoFriendPatternRegex;
public Pattern autoAfkReplyPatternRegex;

public Pattern chatCleanerJoinRegex;
public Pattern chatCleanerTicketAnnouncerRegex;
Expand Down Expand Up @@ -176,6 +178,7 @@ public void initialize() {
autoQueuePrefixGlobalRegex = Pattern.compile(autoQueuePrefixGlobal);

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

chatCleanerJoinRegex = Pattern.compile(chatCleanerJoin);
chatCleanerTicketAnnouncerRegex = Pattern.compile(chatCleanerTicketAnnouncer);
Expand Down

0 comments on commit b503bca

Please sign in to comment.