Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BCMERTwitch v0.0.3
BCMERTwitch.dll
Decompiled 2 days agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BCMERTwitch.Manager; using BCMERTwitch.NetcodePatcher; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using BrutalCompanyMinus; using BrutalCompanyMinus.Minus; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BCMERTwitch")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("BCMER and Twitch Integration")] [assembly: AssemblyFileVersion("0.7.13.0")] [assembly: AssemblyInformationalVersion("0.7.13+53f77a9d8fe854ccbaf18b860061e2de8dc1d912")] [assembly: AssemblyProduct("BCMERTwitch")] [assembly: AssemblyTitle("BCMERTwitch")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.7.13.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BCMERTwitch { [HarmonyPatch] public class Compatibility { public static Assembly GetAssembly(string name) { if (Chainloader.PluginInfos.ContainsKey(name)) { return ((object)Chainloader.PluginInfos[name].Instance).GetType().Assembly; } return null; } public static bool IsModPresent(string name, string logMessage = "") { bool flag = Chainloader.PluginInfos.ContainsKey(name); if (flag) { Log.LogInfo(name + " is present. " + logMessage); } return flag; } } public class Configs { public static ConfigFile? generalConfig; public static ConfigFile? eventsConfig; public static ConfigEntry<bool> blocklistIsAllow; public static ConfigEntry<bool> subEventAllowed; public static ConfigEntry<bool> raidEventAllowed; public static ConfigEntry<bool> bitsEventAllowed; public static ConfigEntry<bool> chatEventAllowed; public static ConfigEntry<string> blockedUsernames; public static ConfigEntry<float> globalCooldown; public static ConfigEntry<float> perUserCooldown; public static ConfigEntry<float> secondsBetweenSubs; public static ConfigEntry<float> secondsBetweenRaids; public static ConfigEntry<float> secondsBetweenBits; public static ConfigEntry<float> secondsBetweenChat; public static ConfigEntry<int> minimumBitsNeeded; public static ConfigEntry<int> maxEventsBeforeDeny; public static ConfigEntry<bool> respectForcedEventsList; public static ConfigEntry<string> chatPrefix; public static ConfigEntry<int> raidHowManyForce; public static ConfigEntry<int> bitsHowManyForce; public static ConfigEntry<int> subsHowManyForce; public static ConfigEntry<int> chatHowManyForce; public static ConfigEntry<bool> sendAsTipGUI; public static ConfigEntry<bool> logMessages; public static ConfigEntry<bool> logFailures; public static ConfigEntry<bool> logOtherMessages; public static ConfigEntry<float> timeWaitTips; public static void GenerateConfig() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown eventsConfig = new ConfigFile(Paths.ConfigPath + "\\BCMERTwitch\\Event_Settings.cfg", true); generalConfig = new ConfigFile(Paths.ConfigPath + "\\BCMERTwitch\\General_Settings.cfg", true); subEventAllowed = generalConfig.Bind<bool>("General", "Allow Sub Events", true, "Should subs be allowed to trigger events?"); raidEventAllowed = generalConfig.Bind<bool>("General", "Allow Raid Events", true, "Should raids be allowed to trigger events?"); bitsEventAllowed = generalConfig.Bind<bool>("General", "Allow Bits Events", true, "Should bit donation be allowed to trigger events?"); chatEventAllowed = generalConfig.Bind<bool>("General", "Allow Chat Events", true, "Should chat messages (requires the chat prefix from config) be allowed to trigger events?"); globalCooldown = generalConfig.Bind<float>("General", "Global Cooldown", 0f, "How many seconds should be between Twitch integration features before anyone (on a global basis) can succesfully trigger BCMER events? Use 0 to disable cooldown. This is a global cooldown and takes priority over any cooldown ."); perUserCooldown = generalConfig.Bind<float>("General", "Per User Cooldown", 2f, "How many seconds should be between Twitch integration features before anyone (on a per-user basis) can succesfully trigger BCMER events? Use 0 to disable cooldown"); maxEventsBeforeDeny = generalConfig.Bind<int>("General", "Max Forcable Events", int.MaxValue, "How many events can be enforced via BCMERTwitch before it denies any extra requests?"); respectForcedEventsList = generalConfig.Bind<bool>("General", "Respect Forced Events List?", true, "This will make it respect already forced events"); logMessages = generalConfig.Bind<bool>("General", "Log Twitch Messages?", false, "Should the mod log messages from users from Twitch."); logOtherMessages = generalConfig.Bind<bool>("General", "Log Other Twitch Events?", true, "Should the mod log other events such as raids, subs, etc?"); logFailures = generalConfig.Bind<bool>("General", "Log Cooldown Messages?", true, "Should the mod log cooldown messages?"); secondsBetweenSubs = generalConfig.Bind<float>("Subs", "Cooldown (In Seconds) Between Subs", 5f, "How many seconds should be between sub events? Use 0 to disable cooldown"); subsHowManyForce = generalConfig.Bind<int>("Subs", "How Many BCMER Events To Force", 1, "How many events should be forced when someone subs?"); secondsBetweenBits = generalConfig.Bind<float>("Bits", "Cooldown (In Seconds) Between Bits", 1f, "How many seconds should be between bits events? Use 0 to disable cooldown"); minimumBitsNeeded = generalConfig.Bind<int>("Bits", "Minimum Bits Needed", 0, "How many bits are needed to trigger a bits event?"); bitsHowManyForce = generalConfig.Bind<int>("Bits", "How Many BCMER Events To Force", 1, "How many BCMER events should be forced when someone donates bits?"); secondsBetweenRaids = generalConfig.Bind<float>("Raid", "Cooldown (In Seconds) Between Raids", 30f, "How many seconds should be between raid events? Use 0 to disable cooldown"); raidHowManyForce = generalConfig.Bind<int>("Raid", "How Many BCMER Events To Force", 1, "How many BCMER events should be forced when someone raids?"); secondsBetweenChat = generalConfig.Bind<float>("Chat", "Cooldown (In Seconds) Between Messages", 300f, "How many seconds should be between chat events? Use 0 to disable cooldown"); chatPrefix = generalConfig.Bind<string>("Chat", "Chat Prefix", "!bcmer", "What prefix is used for BCMER Events regardless if message detection is on or off? This is case-insensitive."); chatHowManyForce = generalConfig.Bind<int>("Chat", "How Many BCMER Events To Force", 1, "How many BCMER events should be forced when someone chats? This feature only works if message detection feature is off and requires the prefix."); blockedUsernames = generalConfig.Bind<string>("General", "Blocked Usernames", "", "List of usernames that are blocked from interacting with any features of the mod.. Comma seperated."); blocklistIsAllow = generalConfig.Bind<bool>("General", "Is Allow List", false, "Should the blocked usernames list as a whitelist instead?"); sendAsTipGUI = generalConfig.Bind<bool>("Notifications", "Send Notification Via Tip Gui", true, "Should there be a GUI that pops up for each event that is redeemed?"); timeWaitTips = generalConfig.Bind<float>("Notifications", "How long between each Tip Notification?", 3f, "Choose a suitable value for the time between each notification"); generalConfig.SaveOnConfigSet = true; generalConfig.Save(); } public static void generateBCMERConfig() { eventsConfig.SaveOnConfigSet = false; for (int i = 0; i < EventManager.events.Count; i++) { string text = EventManager.events[i].Name(); BCMERTwitch.Manager.Manager.Enabled[text] = eventsConfig.Bind<bool>(text, "Enabled", true, "Should this event be forcable at all?"); BCMERTwitch.Manager.Manager.BlockedUsernames[text] = eventsConfig.Bind<string>(text, "Blocked Usernames", "", "List of usernames that are blocked from forcing this event. Comma seperated. Global settings will take priority before this."); BCMERTwitch.Manager.Manager.IsAllowList[text] = eventsConfig.Bind<bool>(text, "Is Allow List", false, "Should the blocked usernames list as a whitelist instead? Global settings will take priority before this."); BCMERTwitch.Manager.Manager.ForcableBySub[text] = eventsConfig.Bind<bool>(text, "Forcable By Sub", true, "Should this event be forcable by users via a sub event?"); BCMERTwitch.Manager.Manager.ForcableByRaid[text] = eventsConfig.Bind<bool>(text, "Forcable By Raid", true, "Should this event be forcable by users via a raid event?"); BCMERTwitch.Manager.Manager.ForcableByBits[text] = eventsConfig.Bind<bool>(text, "Forcable By Bits", true, "Should this event be forcable by users via a bits event?"); BCMERTwitch.Manager.Manager.BitsRequiredToForce[text] = eventsConfig.Bind<int>(text, "Bits Required To Force", 0, "How many bits are required to force this event? Leave the number equal to or less than your global amount required to have it work at the global bits amount. Otherwise increase it."); BCMERTwitch.Manager.Manager.ForcableByChat[text] = eventsConfig.Bind<bool>(text, "Forcable By Chat", true, "Should this event be forcable by users via a chat event?"); } eventsConfig.SaveOnConfigSet = true; eventsConfig.Save(); } } internal class Log { internal static ManualLogSource logSource; internal static void Initalize(ManualLogSource LogSource) { logSource = LogSource; } internal static void LogDebug(object data) { logSource.LogDebug(data); } internal static void LogError(object data) { logSource.LogError(data); } internal static void LogFatal(object data) { logSource.LogFatal(data); } internal static void LogInfo(object data) { logSource.LogInfo(data); } internal static void LogMessage(object data) { logSource.LogMessage(data); } internal static void LogWarning(object data) { logSource.LogWarning(data); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("SoftDiamond.BCMERTwitch", "BCMERTwitch", "0.0.3")] public class Plugin : BaseUnityPlugin { public const string GUID = "SoftDiamond.BCMERTwitch"; public const string NAME = "BCMERTwitch"; public const string VERSION = "0.0.3"; public static GameObject ManagerNet; private static readonly Harmony harmony = new Harmony("SoftDiamond.BCMERTwitch"); internal static Plugin Instance { get; private set; } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } Log.Initalize(((BaseUnityPlugin)this).Logger); ManagerNet = NetworkPrefabs.CreateNetworkPrefab("BCMERTwitch_Net"); ManagerNet.AddComponent<BCMERTwitch.Manager.Manager>(); Configs.GenerateConfig(); InitializeNetworkBehaviours(); harmony.PatchAll(); Log.LogInfo("BCMERTwitch 0.0.3 is done patching."); } private static void InitializeNetworkBehaviours() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { try { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } catch { } } } } internal static bool IsModLoaded(string modGUID) { bool flag = Chainloader.PluginInfos.ContainsKey(modGUID); if (flag) { Log.LogInfo("Mod compatibility loaded for mod : GUID " + modGUID); } return flag; } } public static class PluginInfo { public const string PLUGIN_GUID = "BCMERTwitch"; public const string PLUGIN_NAME = "BCMERTwitch"; public const string PLUGIN_VERSION = "0.7.13"; } } namespace BCMERTwitch.Manager { [HarmonyPatch] public class Manager : NetworkBehaviour { public List<MEvent> events = new List<MEvent>(); public static List<MEvent> tipsToDoEvent = new List<MEvent>(); public static List<string> tipsToDoString = new List<string>(); public static Dictionary<string, ConfigEntry<bool>> Enabled = new Dictionary<string, ConfigEntry<bool>>(); public static Dictionary<string, ConfigEntry<string>> BlockedUsernames = new Dictionary<string, ConfigEntry<string>>(); public static Dictionary<string, ConfigEntry<bool>> IsAllowList = new Dictionary<string, ConfigEntry<bool>>(); public static Dictionary<string, ConfigEntry<bool>> ForcableBySub = new Dictionary<string, ConfigEntry<bool>>(); public static Dictionary<string, ConfigEntry<bool>> ForcableByRaid = new Dictionary<string, ConfigEntry<bool>>(); public static Dictionary<string, ConfigEntry<bool>> ForcableByBits = new Dictionary<string, ConfigEntry<bool>>(); public static Dictionary<string, ConfigEntry<int>> BitsRequiredToForce = new Dictionary<string, ConfigEntry<int>>(); public static Dictionary<string, ConfigEntry<bool>> ForcableByChat = new Dictionary<string, ConfigEntry<bool>>(); public static Dictionary<string, DateTimeOffset> lastBits = new Dictionary<string, DateTimeOffset>(); public static Dictionary<string, DateTimeOffset> lastSub = new Dictionary<string, DateTimeOffset>(); public static Dictionary<string, DateTimeOffset> lastRaid = new Dictionary<string, DateTimeOffset>(); public static Dictionary<string, DateTimeOffset> lastMessage = new Dictionary<string, DateTimeOffset>(); public DateTimeOffset lastRaidGlobal = DateTimeOffset.MinValue; public DateTimeOffset lastSubGlobal = DateTimeOffset.MinValue; public DateTimeOffset lastBitsGlobal = DateTimeOffset.MinValue; public DateTimeOffset lastMessageGlobal = DateTimeOffset.MinValue; public DateTimeOffset anyActionGlobal = DateTimeOffset.MinValue; private static FileSystemWatcher? eventWatcher; private static FileSystemWatcher? generalWatcher; public static Manager Instance { get; private set; } = null; public void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)Instance).gameObject); } Instance = this; } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); if (!((NetworkBehaviour)this).NetworkManager.IsServer) { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)Instance).gameObject); } Instance = this; } } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "Start")] public static void OnStart() { GameObject val = Object.Instantiate<GameObject>(Plugin.ManagerNet); if (((NetworkBehaviour)RoundManager.Instance).IsServer) { val.GetComponent<NetworkObject>().Spawn(false); Instance.prepareEventsForForcing(); NotifyMainConfigChanged(); NotifyEventConfigChanged(); } } private static void NotifyEventConfigChanged() { try { eventWatcher = new FileSystemWatcher(Paths.ConfigPath + "\\BCMERTwitch"); eventWatcher.Filter = "Event_Settings.cfg"; eventWatcher.NotifyFilter = NotifyFilters.Size | NotifyFilters.LastWrite; eventWatcher.Changed += OnEventsChanged; eventWatcher.EnableRaisingEvents = true; } catch (Exception ex) { Log.LogError("An error occured during FileSystemWatch setup: " + ex.Message); } } private static void OnEventsChanged(object sender, FileSystemEventArgs e) { if (e.ChangeType != WatcherChangeTypes.Changed) { return; } try { Log.LogInfo("A change was detected in the Events Config. Reloading"); ConfigFile? eventsConfig = Configs.eventsConfig; if (eventsConfig != null) { eventsConfig.Reload(); } } catch (Exception ex) { Log.LogError("An error occured trying to reload Event Config: " + ex.Message); } } private static void NotifyMainConfigChanged() { try { generalWatcher = new FileSystemWatcher(Paths.ConfigPath + "\\BCMERTwitch"); generalWatcher.Filter = "General_Settings.cfg"; generalWatcher.NotifyFilter = NotifyFilters.Size | NotifyFilters.LastWrite; generalWatcher.Changed += OnGeneralChanged; generalWatcher.EnableRaisingEvents = true; } catch (Exception ex) { Log.LogError("An error occured during FileSystemWatch setup: " + ex.Message); } } private static void OnGeneralChanged(object sender, FileSystemEventArgs e) { if (e.ChangeType != WatcherChangeTypes.Changed) { return; } try { Log.LogInfo("A change was detected in the General Config. Reloading"); ConfigFile? generalConfig = Configs.generalConfig; if (generalConfig != null) { generalConfig.Reload(); } } catch (Exception ex) { Log.LogError("An error occured trying to reload General Config: " + ex.Message); } } [HarmonyPostfix] [HarmonyPatch(typeof(Assets), "OnSceneLoaded")] public static void OnbcmerStart() { Configs.generateBCMERConfig(); } [HarmonyPrefix] [HarmonyPatch(typeof(StartOfRound), "OnLocalDisconnect")] public static void OnDisconnect() { if (((NetworkBehaviour)RoundManager.Instance).IsServer) { try { Object.Destroy((Object)(object)((Component)Instance).gameObject); } catch (Exception) { Log.LogFatal("An error occured deleting the BCMERTwitch Net Object"); } } } public void prepareEventsForForcing() { events = EventManager.events.FindAll((MEvent e) => e != null && e.AddEventIfOnly() && e.Enabled); } public void OnEnable() { if (Configs.chatEventAllowed.Value) { API.OnMessage += HandleMessage; } if (Configs.bitsEventAllowed.Value) { API.OnCheer += HandleCheer; } if (Configs.subEventAllowed.Value) { API.OnSub += HandleSub; } if (Configs.raidEventAllowed.Value) { API.OnRaid += HandleRaid; } } public void OnDisable() { API.OnMessage -= HandleMessage; API.OnCheer -= HandleCheer; API.OnSub -= HandleSub; API.OnRaid -= HandleRaid; } internal bool isOnGlobalBlackList(string username, string type) { if (!Configs.blocklistIsAllow.Value && Configs.blockedUsernames.Value.ToLower().Contains(username.ToLower())) { Log.LogInfo(type + " from " + username + " ignored due to blocklist."); return true; } if (Configs.blocklistIsAllow.Value && !Configs.blockedUsernames.Value.ToLower().Contains(username.ToLower())) { Log.LogInfo(type + " from " + username + " ignored due to allowlist."); return true; } return false; } internal void generateEvents(int amount, int type, string UserName, int BitsSent = 0) { ConfigFile? eventsConfig = Configs.eventsConfig; if (eventsConfig != null) { eventsConfig.Reload(); } ConfigFile? generalConfig = Configs.generalConfig; if (generalConfig != null) { generalConfig.Reload(); } List<MEvent> list = new List<MEvent>(events); list = list.FindAll((MEvent e) => Enabled[e.Name()].Value); if (type == 1) { list = list.FindAll((MEvent e) => ForcableByRaid[e.Name()].Value); } if (type == 2) { list = list.FindAll((MEvent e) => ForcableBySub[e.Name()].Value); } if (type == 3) { list = list.FindAll((MEvent e) => ForcableByBits[e.Name()].Value); list = list.FindAll((MEvent e) => BitsSent >= Math.Abs(BitsRequiredToForce[e.Name()].Value)); } if (type == 4) { list = list.FindAll((MEvent e) => ForcableByChat[e.Name()].Value); } list = list.FindAll((MEvent e) => IsAllowList[e.Name()].Value ? BlockedUsernames[e.Name()].Value.ToLower().Contains(UserName.ToLower()) : (!BlockedUsernames[e.Name()].Value.ToLower().Contains(UserName.ToLower()))); if (Configs.respectForcedEventsList.Value) { IEnumerable<MEvent> sharedEvents = list.Intersect(EventManager.forcedEvents); list.RemoveAll((MEvent e) => sharedEvents.Contains(e)); } List<MEvent> list2 = new List<MEvent>(); for (int num = 0; num < Math.Abs(amount); num++) { if (list.Count == 0) { Log.LogInfo("No more selectable events available to force."); break; } int index = Random.Range(0, list.Count); MEvent val = list[index]; try { Log.LogInfo("Trying to force an event named " + val.Name()); } catch { Log.LogInfo("An error occured trying to display a HUD Menu."); } list2.Add(val); try { API.ForceEvents(list2); } catch (Exception ex) { Log.LogError("Error forcing event " + val.Name() + ": " + ex.Message); EventManager.forcedEvents.AddRange(list2); } list.RemoveAt(index); } tipsToDoEvent = new List<MEvent>(list2); if (list2.Count > 1) { ((MonoBehaviour)HUDManager.Instance).StartCoroutine(EventTips(tipsToDoEvent)); } else if (list2.Count == 1) { HUDManager.Instance.DisplayTip("Forced Event", "An event named " + list2[0].Name() + " was forced.", false, false, "LC_Tip1"); } list2.Clear(); list.Clear(); } internal void generateEventsByName(string[] eventNames) { ConfigFile? eventsConfig = Configs.eventsConfig; if (eventsConfig != null) { eventsConfig.Reload(); } ConfigFile? generalConfig = Configs.generalConfig; if (generalConfig != null) { generalConfig.Reload(); } List<string> list = new List<string>(); for (int i = 0; i < eventNames.Length; i++) { string text = eventNames[i].Trim(); if (API.DoesEventExist(text)) { try { Log.LogInfo("Trying to force an event named " + text); } catch { Log.LogInfo("An error occured trying to display a HUD Menu."); } list.Add(text); } else { Log.LogInfo("Event " + text + " does not exist."); } } tipsToDoString = new List<string>(list); if (list.Count > 1) { ((MonoBehaviour)HUDManager.Instance).StartCoroutine(EventTips(tipsToDoString)); } else if (list.Count == 1) { HUDManager.Instance.DisplayTip("Forced Event", "An event named " + list[0] + " was forced.", false, false, "LC_Tip1"); } API.ForceEvents(list.ToArray()); list.Clear(); } internal static IEnumerator EventTips(List<string> events) { yield return (object)new WaitForSeconds(Mathf.Abs(Configs.timeWaitTips.Value)); foreach (string e in events) { HUDManager.Instance.DisplayTip("Forced Event", "An event named " + e + " was forced.", false, false, "LC_Tip1"); yield return (object)new WaitForSeconds(Mathf.Abs(Configs.timeWaitTips.Value)); } } internal static IEnumerator EventTips(List<MEvent> events) { yield return (object)new WaitForSeconds(Mathf.Abs(Configs.timeWaitTips.Value)); foreach (MEvent e in events) { HUDManager.Instance.DisplayTip("Forced Event", "An event named " + e.Name() + " was forced.", false, false, "LC_Tip1"); yield return (object)new WaitForSeconds(Mathf.Abs(Configs.timeWaitTips.Value)); } } private void HandleRaid(TwitchRaidEvent raid) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) TwitchUser user = ((TwitchEvent)raid).User; string text = ((TwitchUser)(ref user)).Username.ToLower(); if (isOnGlobalBlackList(text, "Raid")) { return; } if (Configs.logOtherMessages.Value) { Log.LogInfo($"Raid from {text} with {raid.ViewerCount} viewers."); } if (EventManager.forcedEvents.Count >= Math.Abs(Configs.maxEventsBeforeDeny.Value)) { if (Configs.logFailures.Value) { Log.LogInfo("Events have hit the limit. Not enforcing events until list is cleared or lever is pulled."); } return; } DateTimeOffset now = DateTimeOffset.Now; TimeSpan timeSpan = now - anyActionGlobal; if (timeSpan.TotalSeconds < (double)Mathf.Abs(Configs.globalCooldown.Value)) { if (Configs.logFailures.Value) { Log.LogInfo($"Raid from {text} ignored due to global cooldown. Time since last raid: {timeSpan.TotalSeconds} seconds."); } return; } if (lastRaid.TryGetValue(text, out var value)) { timeSpan = now - value; if (timeSpan.TotalSeconds < (double)Mathf.Abs(Configs.perUserCooldown.Value)) { if (Configs.logFailures.Value) { Log.LogInfo($"Raid from {text} ignored due to user cooldown. Time since last raid: {timeSpan.TotalSeconds} seconds."); } return; } } timeSpan = now - lastRaidGlobal; if (timeSpan.TotalSeconds < (double)Mathf.Abs(Configs.secondsBetweenRaids.Value)) { if (Configs.logFailures.Value) { Log.LogInfo($"Raid from {text} ignored due to event cooldown. Time since last raid: {timeSpan.TotalSeconds} seconds."); } } else { anyActionGlobal = now; lastRaidGlobal = now; lastRaid[text] = now; Log.LogInfo("Raid from " + text + " accepted."); generateEvents(Configs.raidHowManyForce.Value, 1, text); } } private void HandleSub(TwitchSubEvent sub) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) TwitchUser user = ((TwitchEvent)sub).User; string text = ((TwitchUser)(ref user)).Username.ToLower(); if (isOnGlobalBlackList(text, "Sub")) { return; } DateTimeOffset now = DateTimeOffset.Now; if (EventManager.forcedEvents.Count >= Configs.maxEventsBeforeDeny.Value) { if (Configs.logFailures.Value) { Log.LogInfo("Events have hit the limit. Not enforcing events until list is cleared or lever is pulled."); } return; } TimeSpan timeSpan = now - anyActionGlobal; if (timeSpan.TotalSeconds < (double)Mathf.Abs(Configs.globalCooldown.Value)) { if (Configs.logFailures.Value) { Log.LogInfo($"Sub from {text} ignored due to global cooldown. Time since last sub: {timeSpan.TotalSeconds} seconds."); } return; } if (lastSub.TryGetValue(text, out var value)) { timeSpan = now - value; if (timeSpan.TotalSeconds < (double)Mathf.Abs(Configs.perUserCooldown.Value)) { if (Configs.logFailures.Value) { Log.LogInfo($"Sub from {text} ignored due to user cooldown. Time since last sub: {timeSpan.TotalSeconds} seconds."); } return; } } timeSpan = now - lastSubGlobal; if (timeSpan.TotalSeconds < (double)Mathf.Abs(Configs.secondsBetweenSubs.Value)) { if (Configs.logFailures.Value) { Log.LogInfo($"Sub from {text} ignored due to event cooldown. Time since last sub: {timeSpan.TotalSeconds} seconds."); } } else { anyActionGlobal = now; lastSubGlobal = now; lastSub[text] = now; Log.LogInfo("Sub from " + text + " accepted."); generateEvents(Configs.subsHowManyForce.Value, 2, text); } } private void HandleCheer(TwitchCheerEvent bits) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) TwitchUser user = ((TwitchEvent)bits).User; string text = ((TwitchUser)(ref user)).Username.ToLower(); int cheerAmount = bits.CheerAmount; if (isOnGlobalBlackList(text, "Bits Donation")) { return; } if (Configs.logOtherMessages.Value) { Log.LogInfo($"Bits donation from {text} with {cheerAmount} bits."); } if (EventManager.forcedEvents.Count >= Configs.maxEventsBeforeDeny.Value) { if (Configs.logFailures.Value) { Log.LogInfo("Events have hit the limit. Not enforcing events until list is cleared or lever is pulled."); } return; } DateTimeOffset now = DateTimeOffset.Now; if (cheerAmount < Configs.minimumBitsNeeded.Value) { if (Configs.logFailures.Value) { Log.LogInfo($"Bits donation from {text} ignored due to not meeting minimum bits needed. Amount: {cheerAmount} bits."); } return; } TimeSpan timeSpan = now - anyActionGlobal; if (timeSpan.TotalSeconds < (double)Mathf.Abs(Configs.globalCooldown.Value)) { if (Configs.logFailures.Value) { Log.LogInfo($"Bits from {text} ignored due to global cooldown. Time since last Bits: {timeSpan.TotalSeconds} seconds."); } return; } if (lastBits.TryGetValue(text, out var value)) { timeSpan = now - value; if (timeSpan.TotalSeconds < (double)Mathf.Abs(Configs.perUserCooldown.Value)) { if (Configs.logFailures.Value) { Log.LogInfo($"Bits from {text} ignored due to user cooldown. Time since last Bits: {timeSpan.TotalSeconds} seconds."); } return; } } timeSpan = now - lastBitsGlobal; if (timeSpan.TotalSeconds < (double)Mathf.Abs(Configs.secondsBetweenBits.Value)) { if (Configs.logFailures.Value) { Log.LogInfo($"Bits from {text} ignored due to event cooldown. Time since last Bits: {timeSpan.TotalSeconds} seconds."); } } else { anyActionGlobal = now; lastBitsGlobal = now; lastBits[text] = now; Log.LogInfo("Bits from " + text + " accepted."); generateEvents(Configs.bitsHowManyForce.Value, 3, text, bits.CheerAmount); } } private void HandleMessage(TwitchMessage chat) { //IL_0003: 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) TwitchUser user = ((TwitchMessage)(ref chat)).User; string text = ((TwitchUser)(ref user)).Username.ToLower(); string text2 = ((TwitchMessage)(ref chat)).Message.ToLower(); if (isOnGlobalBlackList(text, "Message") || !text2.StartsWith(Configs.chatPrefix.Value.ToLower())) { return; } if (Configs.logMessages.Value) { Log.LogInfo("Message from " + text + ": " + text2); } DateTimeOffset now = DateTimeOffset.Now; if (EventManager.forcedEvents.Count >= Configs.maxEventsBeforeDeny.Value) { if (Configs.logFailures.Value) { Log.LogInfo("Events have hit the limit. Not enforcing events until list is cleared or lever is pulled."); } return; } if (text2.StartsWith(Configs.chatPrefix.Value.ToLower())) { TimeSpan timeSpan = now - anyActionGlobal; if (timeSpan.TotalSeconds < (double)Mathf.Abs(Configs.globalCooldown.Value)) { if (Configs.logFailures.Value) { Log.LogInfo($"Message from {text} ignored due to global cooldown. Time since last message: {timeSpan.TotalSeconds} seconds."); } return; } if (lastMessage.TryGetValue(text, out var value)) { timeSpan = now - value; if (timeSpan.TotalSeconds < (double)Mathf.Abs(Configs.perUserCooldown.Value)) { Log.LogInfo($"Message from {text} ignored due to user cooldown. Time since last message: {timeSpan.TotalSeconds} seconds."); return; } } timeSpan = now - lastMessageGlobal; if (timeSpan.TotalSeconds < (double)Mathf.Abs(Configs.secondsBetweenChat.Value)) { Log.LogInfo($"Message from {text} ignored due to event cooldown. Time since last message: {timeSpan.TotalSeconds} seconds."); return; } generateEvents(Math.Abs(Configs.chatHowManyForce.Value), 4, text); } anyActionGlobal = now; lastMessageGlobal = now; lastMessage[text] = now; Log.LogInfo("Message from " + text + " accepted."); } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { ((NetworkBehaviour)this).__initializeRpcs(); } protected internal override string __getTypeName() { return "Manager"; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace BCMERTwitch.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }