Fix chat messages

This commit is contained in:
D1GQ committed 2025-03-24 03:48:12 -05:00
1 parent 90cf6da9ef
commit ff44659a70
1 file changed
-36
-36
View File
@@ -1,12 +1,9 @@
using AmongUs.GameOptions;
using Assets.CoreScripts;
using BetterAmongUs.Helpers;
using BetterAmongUs.Modules;
using BetterAmongUs.Modules.AntiCheat;
using HarmonyLib;
using Hazel;
using System.Text;
using System.Text.RegularExpressions;
using TMPro;
using UnityEngine;
@@ -24,39 +21,6 @@ class ChatPatch
HudManager.Instance.Chat.chatBubblePool.ReclaimAll();
}
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.RpcSendChat))]
class RpcSendChatPatch
{
internal static bool Prefix(PlayerControl __instance, string chatText, ref bool __result)
{
if (string.IsNullOrWhiteSpace(chatText))
{
__result = false;
return false;
}
if (!GameState.IsBetterHostLobby)
{
__result = false;
return true;
}
chatText = Regex.Replace(chatText, "<.*?>", string.Empty);
if (AmongUsClient.Instance.AmClient && DestroyableSingleton<HudManager>.Instance)
{
DestroyableSingleton<HudManager>.Instance.Chat.AddChat(__instance, chatText, true);
}
if (chatText.IndexOf("who", StringComparison.OrdinalIgnoreCase) >= 0)
{
DestroyableSingleton<UnityTelemetry>.Instance.SendWho();
}
chatText = "\n" + chatText;
MessageWriter messageWriter = AmongUsClient.Instance.StartRpc(__instance.NetId, 13, SendOption.Reliable);
messageWriter.Write(chatText);
messageWriter.EndMessage();
__result = true;
return false;
}
}
[HarmonyPatch(typeof(ChatController))]
internal class ChatControllerPatch
{