Decompiled source of SimpleTwitchChat v0.0.4

SimpleTwitchChat.dll

Decompiled 3 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CSync.Extensions;
using CSync.Lib;
using GameNetcodeStuff;
using HarmonyLib;
using LethalNetworkAPI;
using TwitchChatAPI;
using TwitchChatAPI.Objects;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SimpleTwitchChat")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SimpleTwitchChat")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("40bf9cbf-1c57-4f43-92af-6600335dd3ae")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SimpleTwitchChat;

public class ConfigHandler : SyncedConfig2<ConfigHandler>
{
	public enum PrefixColorModes
	{
		BothTwitchPurple,
		BothTwitchUsernameColor,
		Hybrid,
		CustomColor
	}

	public enum ChatColorModes
	{
		TwitchPurple,
		TwitchUsernameColor,
		CustomColor
	}

	public ConfigEntry<string> ChatPrefix;

	public ConfigEntry<PrefixColorModes> PrefixColorMode;

	public ConfigEntry<string> CustomPrefixColor;

	public ConfigEntry<ChatColorModes> ChatColorMode;

	public ConfigEntry<string> CustomChatColor;

	public ConfigEntry<bool> shouldHighlightsAlert;

	public ConfigEntry<bool> shouldAlertsSkipChat;

	public ConfigEntry<float> alertWaitTime;

	public ConfigEntry<bool> hideClankers;

	public ConfigEntry<bool> hideBroadcaster;

	public ConfigEntry<bool> hideMods;

	public ConfigEntry<string> prefixBlacklist;

	public ConfigEntry<string> blacklistedUsers;

	public ConfigEntry<bool> blacklistIsWhitelist;

	public ConfigEntry<bool> subOnly;

	[SyncedEntryField]
	public SyncedEntry<bool> networkHostsEntireChat;

	public ConfigEntry<bool> printDebugInfo;

	public ConfigEntry<bool> printRedeemInfo;

	public ConfigEntry<float> chatDelay;

	public ConfigHandler(ConfigFile config)
		: base("ZetaArcade.SimpleTwitchChat")
	{
		printDebugInfo = config.Bind<bool>("Debugging", "Print Debug Info", false, "If true, any chat messages that come into the connected chat will have all their metadata printed into the log.");
		printRedeemInfo = config.Bind<bool>("Debugging", "Print Redeem Info", false, "If true, any redeems used will print their IDs into the log, useful for setting up the Redeem part of this config.");
		ChatPrefix = config.Bind<string>("Chat Formatting", "Chat Prefix", "[TTV]", "What to prefix any chat messages coming from Twitch with. Leave blank for nothing.");
		PrefixColorMode = config.Bind<PrefixColorModes>("Chat Formatting", "Prefix Color Mode", PrefixColorModes.Hybrid, "What mode to color the Prefix + Username of Twitch chat messages. BothTwitchPurple = Both will be Purple. BothUsernameColor = Both will match their Twitch Username color. Hybrid = The Prefix will Twitch Purple, whilst the Username will be their Twitch Username color. CustomColor = Both will be a custom color you set below.");
		CustomPrefixColor = config.Bind<string>("Chat Formatting", "Custom Prefix Color", "#FFFFFF", "If 'Prefix Color Mode' is set to 'AllCustomColor', this color will be used instead for the Prefix. Needs to be the Hex color code.");
		ChatColorMode = config.Bind<ChatColorModes>("Chat Formatting", "Chat Color Mode", ChatColorModes.CustomColor, "Mode to choose the color for the actual message from the Twitch User. Default is Custom Color which is set to white.");
		CustomChatColor = config.Bind<string>("Chat Formatting", "Custom Chat Color", "#FFFFFF", "If 'Chat Color Mode' is set to 'CustomColor', this will be used for the message's color. Default is white.");
		shouldHighlightsAlert = config.Bind<bool>("Highlights", "Should Highlights Alert", true, "If true, when a redeem is used to highlight a Twitch message, it will popup as a yellow 'Alert' like message at the bottom of the screen.");
		shouldAlertsSkipChat = config.Bind<bool>("Highlights", "Should Alerts Skip Chat", false, "If 'Should Highlights Alert' is true, and an Alert comes through, this being enabled prevents the message appearing in the normal chat as well. Disable if you want highlighted messages to appear both as an Alert AND in the text chat.");
		alertWaitTime = config.Bind<float>("Highlights", "Alert Wait Time", 9f, "How long the Alert message will stay on screen for before disappearing.");
		hideClankers = config.Bind<bool>("Filtering", "Hide Clankers", true, "If true, any messages from users with a Bot Badge will not be passed in game. Isn't smart enough to catch user-bots though.");
		hideBroadcaster = config.Bind<bool>("Filtering", "Hide Broadcaster", false, "If true, any messages from the Broadcaster themself will not be passed in game.");
		prefixBlacklist = config.Bind<string>("Filtering", "Prefix Blacklist", "!", "A comma separated list of prefixes that will be filtered out from the chat, useful for hiding commands being used. Due to this format, messages starting with a ',' will be filtered automatically.");
		hideMods = config.Bind<bool>("Filtering", "Hide Mods", false, "If true, any messages from moderators will not be passed in game.");
		subOnly = config.Bind<bool>("Filtering", "Sub Only", false, "If true, any messages from users who are not subscribed to the channel will not be passed in game.");
		blacklistedUsers = config.Bind<string>("Filtering", "Blacklisted User IDs", "", "A comma separated list of Twitch IDs that you want to block messages from coming through from. Example: '469784489,469334489,555584489'. This config takes priority over all other filters. You can use 'StreamWeasels' web tool to get User IDs from Usernames.");
		blacklistIsWhitelist = config.Bind<bool>("Filtering", "Blacklist is Whitelist", false, "If true, the above list of Blacklisted User IDs will be treated as a Whitelist instead, meaning only users in that list will be allowed to have their messages come through. This config still takes priority over all other filters, meaning if you Whitelist a non-sub in sub-only mode, their message will still come through.");
		networkHostsEntireChat = SyncedBindingExtensions.BindSyncedEntry<bool>(config, "Networking", "Network Chat to Whole Lobby", false, "If true, all Twitch chat messages from the Host's Twitch will be sent to all players in the game (This also means ONLY the host's Twitch stream will work. Any clients playing who are also streaming will not be able to see their chat in game as it is overwritten). If false, only the host will see their own Twitch chat messages, and clients will be able to see their own seperate Twitch chat messages. ");
		chatDelay = config.Bind<float>("Networking", "Message Cooldown", 0.25f, "How much of a cooldown to put between chat messages, useful for very busy Twitch channels where lots of messages can come through at once, to queue them up. 1f = 1 second.");
		ConfigManager.Register<ConfigHandler>((SyncedConfig2<ConfigHandler>)this);
	}
}
internal class MessageHandler : MonoBehaviour
{
	private static Queue<STCNetworking.ChatMessage> messageQueue = new Queue<STCNetworking.ChatMessage>();

	private static bool isProcessingQueue = false;

	public static void Send(HUDManager hud, string msg, string sender)
	{
		MethodInfo method = typeof(HUDManager).GetMethod("AddChatMessage", BindingFlags.Instance | BindingFlags.NonPublic);
		method.Invoke(hud, new object[4] { msg, sender, -1, false });
	}

	internal static IEnumerator ShowMessageAfterDelay(string title, string text, float delay = 0f, bool isWarning = false)
	{
		if (delay > 0f)
		{
			yield return (object)new WaitForSeconds(delay);
		}
		yield return (object)new WaitUntil((Func<bool>)delegate
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			AnimatorStateInfo currentAnimatorStateInfo = HUDManager.Instance.tipsPanelAnimator.GetCurrentAnimatorStateInfo(0);
			return ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime >= 1f;
		});
		HUDManager.Instance.DisplayTip(title, text, isWarning, false, "LC_Tip1");
	}

	public static List<DialogueSegment> GetDialogueSegment(string newSpeakerText, string newBodyText, float newWaitTime)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		DialogueSegment item = new DialogueSegment
		{
			speakerText = newSpeakerText,
			bodyText = newBodyText,
			waitTime = newWaitTime
		};
		List<DialogueSegment> list = new List<DialogueSegment>();
		list.Add(item);
		return list;
	}

	public static void AddTextToChat(bool doHighlight, bool doChatMessage, float alertWaitTime, string messageMain, string displayName, string chatPrefix, string desiredPrefixColor, string desiredUsernameColor, string desiredChatColor, bool isTip, bool isWarning)
	{
		messageQueue.Enqueue(new STCNetworking.ChatMessage
		{
			doHighlight = doHighlight,
			doChatMessage = doChatMessage,
			alertWaitTime = alertWaitTime,
			messageMain = messageMain,
			displayName = displayName,
			chatPrefix = chatPrefix,
			desiredPrefixColor = desiredPrefixColor,
			desiredUsernameColor = desiredUsernameColor,
			desiredChatColor = desiredChatColor,
			isTip = isTip,
			isWarning = isWarning
		});
		if (!isProcessingQueue)
		{
			((MonoBehaviour)HUDManager.Instance).StartCoroutine(ProcessMessageQueue());
		}
	}

	private static IEnumerator ProcessMessageQueue()
	{
		isProcessingQueue = true;
		while (messageQueue.Count > 0)
		{
			STCNetworking.ChatMessage msg = messageQueue.Dequeue();
			if (msg.doHighlight)
			{
				HUDManager.Instance.ReadDialogue(GetDialogueSegment("Message from: " + msg.displayName, msg.messageMain, msg.alertWaitTime).ToArray());
				HUDManager.Instance.PingHUDElement(HUDManager.Instance.Chat, 4f, 1f, 0.2f);
			}
			if (msg.doChatMessage)
			{
				Send(HUDManager.Instance, "<color=" + msg.desiredPrefixColor + ">" + msg.chatPrefix + "</color> <color=" + msg.desiredUsernameColor + ">[" + msg.displayName + "]</color>: <color=" + msg.desiredChatColor + ">" + msg.messageMain + "</color>", "");
				HUDManager.Instance.PingHUDElement(HUDManager.Instance.Chat, 4f, 1f, 0.2f);
			}
			if (msg.isTip)
			{
				if (msg.isWarning)
				{
					HUDManager.Instance.DisplayTip("Warning, Redeem Triggered", msg.messageMain, true, false, "LC_Tip1");
				}
				else
				{
					HUDManager.Instance.DisplayTip("Alert, Redeem Triggered", msg.messageMain, false, false, "LC_Tip1");
				}
			}
			yield return (object)new WaitForSeconds(SimpleTwitchChatBase.Config.chatDelay.Value);
		}
		isProcessingQueue = false;
	}
}
public static class PluginInfo
{
	public const string modGUID = "ZetaArcade.SimpleTwitchChat";

	public const string modName = "SimpleTwitchChat";

	public const string modVersion = "0.0.4";
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("ZetaArcade.SimpleTwitchChat", "SimpleTwitchChat", "0.0.4")]
public class SimpleTwitchChatBase : BaseUnityPlugin
{
	private Harmony harmony = new Harmony("ZetaArcade.SimpleTwitchChat");

	public static ManualLogSource Logger;

	public static SimpleTwitchChatBase Instance;

	internal static ConfigHandler Config;

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		Logger = ((BaseUnityPlugin)this).Logger;
		Config = new ConfigHandler(((BaseUnityPlugin)this).Config);
		TwitchHandler.Initialize();
		STCNetworking.Init();
		harmony.PatchAll();
		Logger.LogInfo((object)"Plugin is loaded!");
	}
}
internal class STCNetworking : MonoBehaviour
{
	public class ChatMessage
	{
		public ulong playerID;

		public string messageMain;

		public string displayName;

		public bool doHighlight;

		public bool doChatMessage;

		public float alertWaitTime;

		public string chatPrefix;

		public string desiredPrefixColor;

		public string desiredUsernameColor;

		public string desiredChatColor;

		public bool isTip;

		public bool isWarning;
	}

	public static LNetworkMessage<ChatMessage> NewChatMessage;

	public static void Init()
	{
		NewChatMessage = LNetworkMessage<ChatMessage>.Create("NewChatMessage", (Action<ChatMessage, ulong>)null, (Action<ChatMessage>)OnNewChatMessage, (Action<ChatMessage, ulong>)null);
	}

	private static void OnNewChatMessage(ChatMessage message)
	{
		MessageHandler.AddTextToChat(message.doHighlight, message.doChatMessage, message.alertWaitTime, message.messageMain, message.displayName, message.chatPrefix, message.desiredPrefixColor, message.desiredUsernameColor, message.desiredChatColor, message.isTip, message.isWarning);
	}

	public static void SendNewChatMessage(ulong playerID, string messageMain, string displayName, bool isHighlight, bool doChatMessage, float alertWaitTime, string chatPrefix, string desiredPrefixColor, string desiredUsernameColor, string desiredChatColor, bool isTip, bool isWarning)
	{
		if (NetworkManager.Singleton.IsHost)
		{
			NewChatMessage.SendClients(new ChatMessage
			{
				playerID = playerID,
				messageMain = messageMain,
				displayName = displayName,
				doHighlight = isHighlight,
				doChatMessage = doChatMessage,
				alertWaitTime = alertWaitTime,
				chatPrefix = chatPrefix,
				desiredPrefixColor = desiredPrefixColor,
				desiredUsernameColor = desiredUsernameColor,
				desiredChatColor = desiredChatColor,
				isTip = isTip,
				isWarning = isWarning
			});
		}
	}
}
public class TwitchHandler : MonoBehaviour
{
	public static List<string> userBlacklist;

	public static event Action<ulong, bool, bool, string, TwitchMessage, string, string, string, bool, bool> OnRedeemEvent;

	public static event Action<ulong, bool, bool, string, string, string, string, string, bool, bool> NewRedeemMessageEvent;

	public static void Initialize()
	{
		API.OnMessage += HandleMessage;
		SimpleTwitchChatBase.Logger.LogDebug((object)"TwitchHandler initializing...");
		string[] source = SimpleTwitchChatBase.Config.blacklistedUsers.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
		userBlacklist = source.ToList();
		Application.quitting += delegate
		{
			API.OnMessage -= HandleMessage;
		};
	}

	private void OnEnable()
	{
		API.OnMessage += HandleMessage;
	}

	private void OnDisable()
	{
		API.OnMessage -= HandleMessage;
	}

	private static void HandleMessage(TwitchMessage message)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0414: Unknown result type (might be due to invalid IL or missing references)
		//IL_0419: Unknown result type (might be due to invalid IL or missing references)
		//IL_0462: Unknown result type (might be due to invalid IL or missing references)
		//IL_0467: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0588: Unknown result type (might be due to invalid IL or missing references)
		//IL_058d: Unknown result type (might be due to invalid IL or missing references)
		//IL_066b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0670: Unknown result type (might be due to invalid IL or missing references)
		//IL_0606: Unknown result type (might be due to invalid IL or missing references)
		//IL_060b: Unknown result type (might be due to invalid IL or missing references)
		//IL_062a: Unknown result type (might be due to invalid IL or missing references)
		//IL_062f: Unknown result type (might be due to invalid IL or missing references)
		//IL_063e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0643: Unknown result type (might be due to invalid IL or missing references)
		//IL_0751: Unknown result type (might be due to invalid IL or missing references)
		//IL_0756: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_07cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0886: Unknown result type (might be due to invalid IL or missing references)
		//IL_088b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0848: Unknown result type (might be due to invalid IL or missing references)
		//IL_084d: Unknown result type (might be due to invalid IL or missing references)
		//IL_08d6: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)StartOfRound.Instance))
		{
			return;
		}
		ManualLogSource logger = SimpleTwitchChatBase.Logger;
		ConfigHandler config = SimpleTwitchChatBase.Config;
		PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
		ulong playerClientId = localPlayerController.playerClientId;
		if (config.networkHostsEntireChat.Value && !((NetworkBehaviour)StartOfRound.Instance.localPlayerController).NetworkManager.IsServer)
		{
			logger.LogDebug((object)"Skipping message because this player is not the Host and networkHostsEntireChat is enabled");
		}
		else
		{
			if (!((Object)(object)HUDManager.Instance != (Object)null) || config == null)
			{
				return;
			}
			string value = "";
			if (((TwitchMessage)(ref message)).Tags.ContainsKey("custom-reward-id") && ((TwitchMessage)(ref message)).Tags.TryGetValue("custom-reward-id", out value) && config.printDebugInfo.Value)
			{
				logger.LogInfo((object)("Redeem ID for: '" + ((TwitchMessage)(ref message)).Message + "' is: " + value));
			}
			TwitchUser user;
			if (config.printDebugInfo.Value)
			{
				logger.LogInfo((object)"------Printing Full Message Debug Info Below-------");
				user = ((TwitchMessage)(ref message)).User;
				logger.LogInfo((object)("[" + ((TwitchUser)(ref user)).DisplayName + "]: " + ((TwitchMessage)(ref message)).Message));
				logger.LogInfo((object)("Channel: " + ((TwitchMessage)(ref message)).Channel));
				user = ((TwitchMessage)(ref message)).User;
				logger.LogInfo((object)("Display Name: " + ((TwitchUser)(ref user)).DisplayName));
				user = ((TwitchMessage)(ref message)).User;
				logger.LogInfo((object)("Username: " + ((TwitchUser)(ref user)).Username));
				user = ((TwitchMessage)(ref message)).User;
				logger.LogInfo((object)("User Color: " + ((TwitchUser)(ref user)).Color));
				user = ((TwitchMessage)(ref message)).User;
				logger.LogInfo((object)("User ID: " + ((TwitchUser)(ref user)).UserId));
				logger.LogInfo((object)"Tags below: ");
				foreach (KeyValuePair<string, string> tag in ((TwitchMessage)(ref message)).Tags)
				{
					logger.LogInfo((object)(tag.Key + " = " + tag.Value));
				}
			}
			NetworkManager networkManager = ((NetworkBehaviour)StartOfRound.Instance.localPlayerController).NetworkManager;
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			List<string> list = (from s in config.prefixBlacklist.Value.Split(new char[1] { ',' })
				select s.Trim()).ToList();
			list.Add(",");
			if (((TwitchMessage)(ref message)).Tags.ContainsKey("badges") && ((TwitchMessage)(ref message)).Tags["badges"].Contains("bot-badge"))
			{
				flag = true;
			}
			if (((TwitchMessage)(ref message)).Tags.ContainsKey("msg-id") && ((TwitchMessage)(ref message)).Tags["msg-id"] == "highlighted-message")
			{
				flag2 = true;
			}
			if (((TwitchMessage)(ref message)).Tags.ContainsKey("custom-reward-id"))
			{
				flag3 = true;
				((TwitchMessage)(ref message)).Tags.TryGetValue("custom-reward-id", out value);
				if (config.printRedeemInfo.Value)
				{
					logger.LogInfo((object)"REDEEM DETECTED");
					logger.LogInfo((object)("Redeem id attached to " + ((TwitchMessage)(ref message)).Message + " is: " + value));
				}
			}
			if (!config.blacklistIsWhitelist.Value)
			{
				List<string> source = userBlacklist;
				user = ((TwitchMessage)(ref message)).User;
				if (Enumerable.Contains(source, ((TwitchUser)(ref user)).UserId) && !flag3)
				{
					logger.LogDebug((object)"Skipping message because this sender is Blacklisted");
					return;
				}
			}
			if (config.blacklistIsWhitelist.Value)
			{
				List<string> source2 = userBlacklist;
				user = ((TwitchMessage)(ref message)).User;
				if (!Enumerable.Contains(source2, ((TwitchUser)(ref user)).UserId))
				{
					logger.LogDebug((object)"Skipping message because this sender is not in the Whitelist");
					return;
				}
			}
			if (config.subOnly.Value)
			{
				user = ((TwitchMessage)(ref message)).User;
				if (!((TwitchUser)(ref user)).IsSubscriber)
				{
					logger.LogDebug((object)"Skipping message because this sender is not a subscriber");
					return;
				}
			}
			if (config.hideBroadcaster.Value)
			{
				user = ((TwitchMessage)(ref message)).User;
				if (((TwitchUser)(ref user)).IsBroadcaster && !flag3)
				{
					logger.LogDebug((object)"Skipping message because this sender is the Broadcaster");
					return;
				}
			}
			if (config.hideClankers.Value && flag && !flag3)
			{
				logger.LogDebug((object)"Skipping message because this sender is a CLANKER");
				return;
			}
			if (list.Any((string p) => ((TwitchMessage)(ref message)).Message.StartsWith(p)))
			{
				logger.LogDebug((object)"Skipping message because this message starts with the Blacklisted Prefix, or ','");
				return;
			}
			if (config.hideMods.Value)
			{
				user = ((TwitchMessage)(ref message)).User;
				if (((TwitchUser)(ref user)).IsModerator && !flag3)
				{
					logger.LogDebug((object)"Skipping message because this sender is a moderator");
					return;
				}
			}
			if (config.shouldHighlightsAlert.Value && flag2)
			{
				if (!config.networkHostsEntireChat.Value)
				{
					bool doHighlight = flag2;
					float value2 = config.alertWaitTime.Value;
					string message2 = ((TwitchMessage)(ref message)).Message;
					user = ((TwitchMessage)(ref message)).User;
					string displayName = ((TwitchUser)(ref user)).DisplayName;
					string value3 = config.ChatPrefix.Value;
					user = ((TwitchMessage)(ref message)).User;
					string color = ((TwitchUser)(ref user)).Color;
					user = ((TwitchMessage)(ref message)).User;
					MessageHandler.AddTextToChat(doHighlight, doChatMessage: false, value2, message2, displayName, value3, "#FFFFFF", color, ((TwitchUser)(ref user)).Color, isTip: false, isWarning: false);
				}
				else
				{
					string message3 = ((TwitchMessage)(ref message)).Message;
					user = ((TwitchMessage)(ref message)).User;
					STCNetworking.SendNewChatMessage(playerClientId, message3, ((TwitchUser)(ref user)).DisplayName, flag2, doChatMessage: false, config.alertWaitTime.Value, config.ChatPrefix.Value, "#FFFFFF", "#FFFFFF", "#FFFFFF", isTip: false, isWarning: false);
				}
			}
			if (config.shouldHighlightsAlert.Value && config.shouldAlertsSkipChat.Value && flag2)
			{
				logger.LogDebug((object)"Skipping message because this message is a highlight");
				HUDManager.Instance.PingHUDElement(HUDManager.Instance.Chat, 4f, 1f, 0.2f);
				return;
			}
			string text = "#FFFFFF";
			string text2 = "#FFFFFF";
			string text3 = "#FFFFFF";
			switch (config.ChatColorMode.Value)
			{
			case ConfigHandler.ChatColorModes.TwitchPurple:
				text2 = "#A970FF";
				break;
			case ConfigHandler.ChatColorModes.TwitchUsernameColor:
				user = ((TwitchMessage)(ref message)).User;
				text2 = ((TwitchUser)(ref user)).Color;
				break;
			case ConfigHandler.ChatColorModes.CustomColor:
				text2 = config.CustomChatColor.Value;
				break;
			}
			switch (config.PrefixColorMode.Value)
			{
			case ConfigHandler.PrefixColorModes.BothTwitchPurple:
				text = "#A970FF";
				text3 = "#A970FF";
				break;
			case ConfigHandler.PrefixColorModes.BothTwitchUsernameColor:
				user = ((TwitchMessage)(ref message)).User;
				text = ((TwitchUser)(ref user)).Color;
				user = ((TwitchMessage)(ref message)).User;
				text3 = ((TwitchUser)(ref user)).Color;
				break;
			case ConfigHandler.PrefixColorModes.Hybrid:
				text = "#A970FF";
				user = ((TwitchMessage)(ref message)).User;
				text3 = ((TwitchUser)(ref user)).Color;
				break;
			case ConfigHandler.PrefixColorModes.CustomColor:
				text = config.CustomPrefixColor.Value;
				text3 = config.CustomPrefixColor.Value;
				break;
			}
			if (!config.networkHostsEntireChat.Value)
			{
				float value4 = config.alertWaitTime.Value;
				string message4 = ((TwitchMessage)(ref message)).Message;
				user = ((TwitchMessage)(ref message)).User;
				MessageHandler.AddTextToChat(doHighlight: false, doChatMessage: true, value4, message4, ((TwitchUser)(ref user)).DisplayName, config.ChatPrefix.Value, text, text3, text2, isTip: false, isWarning: false);
			}
			else
			{
				string message5 = ((TwitchMessage)(ref message)).Message;
				user = ((TwitchMessage)(ref message)).User;
				STCNetworking.SendNewChatMessage(playerClientId, message5, ((TwitchUser)(ref user)).DisplayName, isHighlight: false, doChatMessage: true, config.alertWaitTime.Value, config.ChatPrefix.Value, text, text3, text2, isTip: false, isWarning: false);
			}
			if (flag3)
			{
				TwitchHandler.OnRedeemEvent?.Invoke(playerClientId, arg2: false, arg3: true, value, message, text, text3, text2, arg9: false, arg10: false);
			}
		}
	}

	public static void NewRedeemMessage(ulong playerID, bool doHighlight, bool doChatMessage, string chatText, string displayName, string desiredPrefixColor, string desiredUsernameColor, string desiredChatColor, bool isTip, bool isRedeemEvil)
	{
		TwitchHandler.NewRedeemMessageEvent?.Invoke(playerID, doHighlight, doChatMessage, chatText, displayName, desiredPrefixColor, desiredUsernameColor, desiredChatColor, isTip, isRedeemEvil);
		if (Object.op_Implicit((Object)(object)StartOfRound.Instance) && ((NetworkBehaviour)StartOfRound.Instance.localPlayerController).NetworkManager.IsServer)
		{
			ConfigHandler config = SimpleTwitchChatBase.Config;
			if (!config.networkHostsEntireChat.Value)
			{
				MessageHandler.AddTextToChat(doHighlight, doChatMessage, config.alertWaitTime.Value, chatText, displayName, config.ChatPrefix.Value, desiredPrefixColor, desiredUsernameColor, desiredChatColor, isTip, isRedeemEvil);
			}
			else
			{
				STCNetworking.SendNewChatMessage(playerID, chatText, displayName, doHighlight, doChatMessage, config.alertWaitTime.Value, config.ChatPrefix.Value, desiredPrefixColor, desiredUsernameColor, desiredChatColor, isTip, isRedeemEvil);
			}
		}
	}
}