protected override void OnMessageReceived(string userNickName, string userColorCode, string text) { if (text.EqualsAny("!notes1", "!notes2", "!notes3", "!notes4")) { int index = "1234".IndexOf(text.Substring(6, 1), StringComparison.Ordinal); _ircConnection.SendMessage(TwitchPlaySettings.data.Notes, index + 1, _notes[index]); return; } if (text.StartsWith("!notes1 ", StringComparison.InvariantCultureIgnoreCase) || text.StartsWith("!notes2 ", StringComparison.InvariantCultureIgnoreCase) || text.StartsWith("!notes3 ", StringComparison.InvariantCultureIgnoreCase) || text.StartsWith("!notes4 ", StringComparison.InvariantCultureIgnoreCase)) { if (!IsAuthorizedDefuser(userNickName)) { return; } int index = "1234".IndexOf(text.Substring(6, 1), StringComparison.Ordinal); string notes = text.Substring(8); if (notes == "") { return; } _ircConnection.SendMessage(TwitchPlaySettings.data.NotesTaken, index + 1, notes); _notes[index] = notes; moduleCameras?.SetNotes(index, notes); return; } if (text.StartsWith("!appendnotes1 ", StringComparison.InvariantCultureIgnoreCase) || text.StartsWith("!appendnotes2 ", StringComparison.InvariantCultureIgnoreCase) || text.StartsWith("!appendnotes3 ", StringComparison.InvariantCultureIgnoreCase) || text.StartsWith("!appendnotes4 ", StringComparison.InvariantCultureIgnoreCase)) { text = text.Substring(0, 1) + text.Substring(7, 6) + text.Substring(1, 6) + text.Substring(13); } if (text.StartsWith("!notes1append ", StringComparison.InvariantCultureIgnoreCase) || text.StartsWith("!notes2append ", StringComparison.InvariantCultureIgnoreCase) || text.StartsWith("!notes3append ", StringComparison.InvariantCultureIgnoreCase) || text.StartsWith("!notes4append ", StringComparison.InvariantCultureIgnoreCase)) { if (!IsAuthorizedDefuser(userNickName)) { return; } int index = "1234".IndexOf(text.Substring(6, 1), StringComparison.Ordinal); string notes = text.Substring(14); if (notes == "") { return; } _ircConnection.SendMessage(TwitchPlaySettings.data.NotesAppended, index + 1, notes); _notes[index] += " " + notes; moduleCameras?.AppendNotes(index, notes); return; } if (text.EqualsAny("!clearnotes1", "!clearnotes2", "!clearnotes3", "!clearnotes4")) { text = text.Substring(0, 1) + text.Substring(6, 6) + text.Substring(1, 5); } if (text.EqualsAny("!notes1clear", "!notes2clear", "!notes3clear", "!notes4clear")) { if (!IsAuthorizedDefuser(userNickName)) { return; } int index = "1234".IndexOf(text.Substring(6, 1), StringComparison.Ordinal); _notes[index] = TwitchPlaySettings.data.NotesSpaceFree; _ircConnection.SendMessage(TwitchPlaySettings.data.NoteSlotCleared, index + 1); moduleCameras?.SetNotes(index, TwitchPlaySettings.data.NotesSpaceFree); return; } if (text.Equals("!snooze", StringComparison.InvariantCultureIgnoreCase)) { if (!IsAuthorizedDefuser(userNickName)) { return; } if (TwitchPlaySettings.data.AllowSnoozeOnly) { alarmClock.TurnOff(); } else { alarmClock.ButtonDown(0); } return; } if (text.Equals("!stop", StringComparison.InvariantCultureIgnoreCase)) { if (!IsAuthorizedDefuser(userNickName, true)) { return; } _currentBomb = _coroutineQueue.CurrentBombID; return; } if (text.Equals("!modules", StringComparison.InvariantCultureIgnoreCase)) { if (!IsAuthorizedDefuser(userNickName)) { return; } moduleCameras?.AttachToModules(_componentHandles); return; } if (text.StartsWith("!claims ", StringComparison.InvariantCultureIgnoreCase)) { if (!IsAuthorizedDefuser(userNickName)) { return; } userNickName = text.Substring(8); text = "!claims"; if (userNickName == "") { return; } } if (text.Equals("!claims", StringComparison.InvariantCultureIgnoreCase)) { if (!IsAuthorizedDefuser(userNickName)) { return; } List <string> claimed = (from handle in _componentHandles where handle.PlayerName != null && handle.PlayerName.Equals(userNickName, StringComparison.InvariantCultureIgnoreCase) && !handle.Solved select string.Format(TwitchPlaySettings.data.OwnedModule, handle.idText.text.Replace("!", ""), handle.headerText.text)).ToList(); if (claimed.Count > 0) { string message = string.Format(TwitchPlaySettings.data.OwnedModuleList, userNickName, string.Join(", ", claimed.ToArray(), 0, Math.Min(claimed.Count, 5))); if (claimed.Count > 5) { message += "..."; } _ircConnection.SendMessage(message); } else { _ircConnection.SendMessage(TwitchPlaySettings.data.NoOwnedModules, userNickName); } return; } if (text.StartsWith("!claim ", StringComparison.InvariantCultureIgnoreCase)) { var split = text.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var claim in split.Skip(1)) { TwitchComponentHandle handle = _componentHandles.FirstOrDefault(x => x.Code.Equals(claim)); if (handle == null || !GameRoom.Instance.IsCurrentBomb(handle.bombID)) { continue; } handle.OnMessageReceived(userNickName, userColorCode, string.Format("!{0} claim", claim)); } return; } if (text.EqualsAny("!unclaim all", "!release all", "!unclaimall", "!releaseall")) { string[] moduleIDs = _componentHandles.Where(x => x.PlayerName != null && x.PlayerName.Equals(userNickName, StringComparison.InvariantCultureIgnoreCase)) .Select(x => x.Code).ToArray(); text = string.Format("!unclaim {0}", string.Join(" ", moduleIDs)); } if (text.StartsWith("!unclaim ", StringComparison.InvariantCultureIgnoreCase) || text.StartsWith("!release ", StringComparison.InvariantCultureIgnoreCase)) { var split = text.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var claim in split.Skip(1)) { TwitchComponentHandle handle = _componentHandles.FirstOrDefault(x => x.Code.Equals(claim)); if (handle == null || !GameRoom.Instance.IsCurrentBomb(handle.bombID)) { continue; } handle.OnMessageReceived(userNickName, userColorCode, string.Format("!{0} unclaim", claim)); } return; } if (text.Equals("!unclaimed", StringComparison.InvariantCultureIgnoreCase)) { if (!IsAuthorizedDefuser(userNickName)) { return; } IEnumerable <string> unclaimed = _componentHandles.Where(handle => !handle.claimed && !handle.Solved && GameRoom.Instance.IsCurrentBomb(handle.bombID)).Shuffle().Take(3) .Select(handle => string.Format("{0} ({1})", handle.headerText.text, handle.Code)).ToList(); if (unclaimed.Any()) { _ircConnection.SendMessage("Unclaimed Modules: {0}", unclaimed.Join(", ")); } else { _ircConnection.SendMessage("There are no more unclaimed modules."); } return; } if (text.StartsWith("!find ", StringComparison.InvariantCultureIgnoreCase) || text.StartsWith("!search ", StringComparison.InvariantCultureIgnoreCase)) { if (!IsAuthorizedDefuser(userNickName)) { return; } var split = text.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string query = split.Skip(1).Join(" "); IEnumerable <string> modules = _componentHandles.Where(handle => handle.headerText.text.ContainsIgnoreCase(query) && GameRoom.Instance.IsCurrentBomb(handle.bombID)) .OrderByDescending(handle => handle.headerText.text.EqualsIgnoreCase(query)).ThenBy(handle => handle.Solved).ThenBy(handle => handle.PlayerName != null).Take(3) .Select(handle => string.Format("{0} ({1}) - {2}", handle.headerText.text, handle.Code, handle.Solved ? "Solved" : (handle.PlayerName == null ? "Unclaimed" : "Claimed by " + handle.PlayerName) )).ToList(); if (modules.Any()) { _ircConnection.SendMessage("Modules: {0}", modules.Join(", ")); } else { _ircConnection.SendMessage("Couldn't find any modules containing \"{0}\".", query); } return; } if (text.Equals("!filledgework", StringComparison.InvariantCultureIgnoreCase) && UserAccess.HasAccess(userNickName, AccessLevel.Mod, true)) { foreach (var commander in _bombCommanders) { commander.FillEdgework(_currentBomb != commander.twitchBombHandle.bombID); } return; } if (text.StartsWith("!setmultiplier", StringComparison.InvariantCultureIgnoreCase) && UserAccess.HasAccess(userNickName, AccessLevel.SuperUser, true)) { float tempNumber = float.Parse(text.Substring(15)); OtherModes.setMultiplier(tempNumber); } if (text.Equals("!solvebomb", StringComparison.InvariantCultureIgnoreCase) && UserAccess.HasAccess(userNickName, AccessLevel.SuperUser, true)) { foreach (var handle in _componentHandles.Where(x => GameRoom.Instance.IsCurrentBomb(x.bombID))) { if (!handle.Solved) { handle.SolveSilently(); } } return; } GameRoom.Instance.RefreshBombID(ref _currentBomb); if (_currentBomb > -1) { //Check for !bomb messages, and pass them off to the currently held bomb. Match match = Regex.Match(text, "^!bomb (.+)", RegexOptions.IgnoreCase); if (match.Success) { string internalCommand = match.Groups[1].Value; text = string.Format("!bomb{0} {1}", _currentBomb + 1, internalCommand); } match = Regex.Match(text, "^!edgework$"); if (match.Success) { text = string.Format("!edgework{0}", _currentBomb + 1); } else { match = Regex.Match(text, "^!edgework (.+)"); if (match.Success) { string internalCommand = match.Groups[1].Value; text = string.Format("!edgework{0} {1}", _currentBomb + 1, internalCommand); } } } foreach (TwitchBombHandle handle in _bombHandles) { if (handle == null) { continue; } IEnumerator onMessageReceived = handle.OnMessageReceived(userNickName, userColorCode, text); if (onMessageReceived == null) { continue; } if (_currentBomb != handle.bombID) { if (!GameRoom.Instance.IsCurrentBomb(handle.bombID)) { continue; } _coroutineQueue.AddToQueue(_bombHandles[_currentBomb].HideMainUIWindow(), handle.bombID); _coroutineQueue.AddToQueue(handle.ShowMainUIWindow(), handle.bombID); _coroutineQueue.AddToQueue(_bombCommanders[_currentBomb].LetGoBomb(), handle.bombID); _currentBomb = handle.bombID; } _coroutineQueue.AddToQueue(onMessageReceived, handle.bombID); } foreach (TwitchComponentHandle componentHandle in _componentHandles) { if (!GameRoom.Instance.IsCurrentBomb(componentHandle.bombID)) { continue; } IEnumerator onMessageReceived = componentHandle.OnMessageReceived(userNickName, userColorCode, text); if (onMessageReceived == null) { continue; } if (_currentBomb != componentHandle.bombID) { _coroutineQueue.AddToQueue(_bombHandles[_currentBomb].HideMainUIWindow(), componentHandle.bombID); _coroutineQueue.AddToQueue(_bombHandles[componentHandle.bombID].ShowMainUIWindow(), componentHandle.bombID); _coroutineQueue.AddToQueue(_bombCommanders[_currentBomb].LetGoBomb(), componentHandle.bombID); _currentBomb = componentHandle.bombID; } _coroutineQueue.AddToQueue(onMessageReceived, componentHandle.bombID); } }
protected override void OnMessageReceived(string userNickName, string userColorCode, string text) { Match match; int index; if (!text.StartsWith("!") || text.Equals("!")) { return; } text = text.Substring(1); if (IsAuthorizedDefuser(userNickName)) { if (text.RegexMatch(out match, "^notes(-?[0-9]+) (.+)$") && int.TryParse(match.Groups[1].Value, out index)) { string notes = match.Groups[2].Value; IRCConnection.Instance.SendMessage(TwitchPlaySettings.data.NotesTaken, index--, notes); _notesDictionary[index] = notes; moduleCameras?.SetNotes(index, notes); return; } if (text.RegexMatch(out match, "^notes(-?[0-9]+)append (.+)", "^appendnotes(-?[0-9]+) (.+)") && int.TryParse(match.Groups[1].Value, out index)) { string notes = match.Groups[2].Value; IRCConnection.Instance.SendMessage(TwitchPlaySettings.data.NotesAppended, index--, notes); if (!_notesDictionary.ContainsKey(index)) { _notesDictionary[index] = TwitchPlaySettings.data.NotesSpaceFree; } _notesDictionary[index] += " " + notes; moduleCameras?.AppendNotes(index, notes); return; } if (text.RegexMatch(out match, "^clearnotes(-?[0-9]+)$", "^notes(-?[0-9]+)clear$") && int.TryParse(match.Groups[1].Value, out index)) { IRCConnection.Instance.SendMessage(TwitchPlaySettings.data.NoteSlotCleared, index--); _notesDictionary[index] = (OtherModes.ZenModeOn && index == 3) ? TwitchPlaySettings.data.ZenModeFreeSpace : TwitchPlaySettings.data.NotesSpaceFree; moduleCameras?.SetNotes(index, _notesDictionary[index]); return; } if (text.Equals("snooze", StringComparison.InvariantCultureIgnoreCase)) { if (GameRoom.Instance is ElevatorGameRoom) { return; //There is no alarm clock in the elevator room. } DropCurrentBomb(); _coroutineQueue.AddToQueue(AlarmClockHoldableHandler.Instance.RespondToCommand(userNickName, "alarmclock snooze")); return; } if (text.Equals("modules", StringComparison.InvariantCultureIgnoreCase)) { moduleCameras?.AttachToModules(ComponentHandles); return; } if (text.RegexMatch(out match, "^claims (.+)")) { OnMessageReceived(match.Groups[1].Value, userColorCode, "!claims"); return; } if (text.Equals("claims", StringComparison.InvariantCultureIgnoreCase)) { List <string> claimed = ( from handle in ComponentHandles where handle.PlayerName != null && handle.PlayerName.Equals(userNickName, StringComparison.InvariantCultureIgnoreCase) && !handle.Solved select string.Format(TwitchPlaySettings.data.OwnedModule, handle.Code, handle.HeaderText)).ToList(); if (claimed.Count > 0) { string message = string.Format(TwitchPlaySettings.data.OwnedModuleList, userNickName, string.Join(", ", claimed.ToArray(), 0, Math.Min(claimed.Count, 5))); if (claimed.Count > 5) { message += "..."; } IRCConnection.Instance.SendMessage(message); } else { IRCConnection.Instance.SendMessage(TwitchPlaySettings.data.NoOwnedModules, userNickName); } return; } if (text.RegexMatch("^(?:claim ?|view ?|all ?){2,3}$")) { if (text.Contains("claim") && text.Contains("all")) { foreach (var handle in ComponentHandles) { if (handle == null || !GameRoom.Instance.IsCurrentBomb(handle.bombID)) { continue; } handle.AddToClaimQueue(userNickName, text.Contains("view")); } return; } } if (text.StartsWith("claim ", StringComparison.InvariantCultureIgnoreCase)) { var split = text.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var claim in split.Skip(1)) { TwitchComponentHandle handle = ComponentHandles.FirstOrDefault(x => x.Code.Equals(claim, StringComparison.InvariantCultureIgnoreCase)); if (handle == null || !GameRoom.Instance.IsCurrentBomb(handle.bombID)) { continue; } handle.AddToClaimQueue(userNickName); } return; } if (text.RegexMatch("^(unclaim|release) ?all$")) { foreach (TwitchComponentHandle handle in ComponentHandles) { handle.RemoveFromClaimQueue(userNickName); } string[] moduleIDs = ComponentHandles.Where(x => !x.Solved && x.PlayerName != null && x.PlayerName.Equals(userNickName, StringComparison.InvariantCultureIgnoreCase)) .Select(x => x.Code).ToArray(); text = string.Format("unclaim {0}", string.Join(" ", moduleIDs)); } if (text.RegexMatch(out match, "^(?:unclaim|release) (.+)")) { var split = match.Groups[1].Value.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var claim in split) { TwitchComponentHandle handle = ComponentHandles.FirstOrDefault(x => x.Code.Equals(claim)); if (handle == null || !GameRoom.Instance.IsCurrentBomb(handle.bombID)) { continue; } handle.OnMessageReceived(userNickName, userColorCode, "unclaim"); } return; } if (text.Equals("unclaimed", StringComparison.InvariantCultureIgnoreCase)) { IEnumerable <string> unclaimed = ComponentHandles.Where(handle => !handle.Claimed && !handle.Solved && GameRoom.Instance.IsCurrentBomb(handle.bombID)).Shuffle().Take(3) .Select(handle => string.Format($"{handle.HeaderText} ({handle.Code})")).ToList(); if (unclaimed.Any()) { IRCConnection.Instance.SendMessage("Unclaimed Modules: {0}", unclaimed.Join(", ")); } else { IRCConnection.Instance.SendMessage("There are no more unclaimed modules."); } return; } if (text.Equals("unsolved", StringComparison.InvariantCultureIgnoreCase)) { IEnumerable <string> unsolved = ComponentHandles.Where(handle => !handle.Solved && GameRoom.Instance.IsCurrentBomb(handle.bombID)).Shuffle().Take(3) .Select(handle => string.Format("{0} ({1}) - {2}", handle.HeaderText, handle.Code, handle.PlayerName == null ? "Unclaimed" : "Claimed by " + handle.PlayerName)).ToList(); if (unsolved.Any()) { IRCConnection.Instance.SendMessage("Unsolved Modules: {0}", unsolved.Join(", ")); } else { IRCConnection.Instance.SendMessage("There are no unsolved modules, something went wrong as this message should never be displayed."); //this should never happen } return; } if (text.RegexMatch(out match, "^(?:find|search) (.+)")) { string[] queries = match.Groups[1].Value.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries); foreach (string query in queries) { string trimmed = query.Trim(); IEnumerable <string> modules = ComponentHandles.Where(handle => handle.HeaderText.ContainsIgnoreCase(trimmed) && GameRoom.Instance.IsCurrentBomb(handle.bombID)) .OrderByDescending(handle => handle.HeaderText.EqualsIgnoreCase(trimmed)).ThenBy(handle => handle.Solved).ThenBy(handle => handle.PlayerName != null).Take(3) .Select(handle => string.Format("{0} ({1}) - {2}", handle.HeaderText, handle.Code, handle.Solved ? "Solved" : (handle.PlayerName == null ? "Unclaimed" : "Claimed by " + handle.PlayerName) )).ToList(); if (modules.Any()) { IRCConnection.Instance.SendMessage("Modules: {0}", modules.Join(", ")); } else { IRCConnection.Instance.SendMessage($"Couldn't find any modules containing \"{trimmed}\"."); } } return; } if (text.RegexMatch(out match, "^(?:findplayer|playerfind|searchplayer|playersearch) (.+)")) { string[] queries = match.Groups[1].Value.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Distinct().ToArray(); foreach (string query in queries) { string trimmed = query.Trim(); IEnumerable <TwitchComponentHandle> modules = ComponentHandles.Where(handle => handle.HeaderText.ContainsIgnoreCase(trimmed) && GameRoom.Instance.IsCurrentBomb(handle.bombID)) .OrderByDescending(handle => handle.HeaderText.EqualsIgnoreCase(trimmed)).ThenBy(handle => handle.Solved).ToList(); IEnumerable <string> playerModules = modules.Where(handle => handle.PlayerName != null).OrderByDescending(handle => handle.HeaderText.EqualsIgnoreCase(trimmed)) .Select(handle => string.Format($"{handle.HeaderText} ({handle.Code}) - Claimed by {handle.PlayerName}")).ToList(); if (modules.Any()) { if (playerModules.Any()) { IRCConnection.Instance.SendMessage("Modules: {0}", playerModules.Join(", ")); } else { IRCConnection.Instance.SendMessage("None of the specified modules are claimed/have been solved."); } } else { IRCConnection.Instance.SendMessage($"Could not find any modules containing \"{trimmed}\"."); } } } if (text.RegexMatch(out match, "^(claim ?(?:any|van|mod) ?(?:view)?|view ?claim ?(?:any|van|mod))")) { var vanilla = match.Groups[1].Value.Contains("van"); var modded = match.Groups[1].Value.Contains("mod"); var view = match.Groups[1].Value.Contains("view"); var avoid = new[] { "Souvenir", "Forget Me Not", "Turn The Key", "Turn The Keys", "The Swan", "Forget Everything" }; var unclaimed = ComponentHandles .Where(handle => (vanilla ? !handle.IsMod : modded ? handle.IsMod : true) && !handle.Claimed && !handle.Solved && !avoid.Contains(handle.HeaderText) && GameRoom.Instance.IsCurrentBomb(handle.bombID)) .Shuffle().FirstOrDefault(); if (unclaimed != null) { text = unclaimed.Code + (view ? " claimview" : " claim"); } else { IRCConnection.Instance.SendMessage(string.Format("There are no more unclaimed{0} modules.", vanilla ? " vanilla" : modded ? " modded" : null)); } } if (text.RegexMatch(out match, "^(?:findsolved|solvedfind|searchsolved|solvedsearch) (.+)")) { string[] queries = match.Groups[1].Value.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Distinct().ToArray(); foreach (string query in queries) { string trimmed = query.Trim(); IEnumerable <BombCommander> commanders = BombCommanders.Where(handle => handle.SolvedModules.Keys.ToArray().Any(x => x.ContainsIgnoreCase(trimmed))).ToList(); IEnumerable <TwitchComponentHandle> modules = commanders.SelectMany(x => x.SolvedModules.Where(y => y.Key.ContainsIgnoreCase(trimmed))) .OrderByDescending(x => x.Key.EqualsIgnoreCase(trimmed)).SelectMany(x => x.Value).ToList(); IEnumerable <string> playerModules = modules.Where(handle => handle.PlayerName != null) .Select(handle => string.Format($"{handle.HeaderText} ({handle.Code}) - Claimed by {handle.PlayerName}", handle.HeaderText, handle.Code, "Claimed by " + handle.PlayerName)).ToList(); if (commanders.Any()) { if (playerModules.Any()) { IRCConnection.Instance.SendMessage("Modules: {0}", playerModules.Join(", ")); } else { IRCConnection.Instance.SendMessage("None of the specified modules have been solved."); } } else { IRCConnection.Instance.SendMessage($"Could not find any modules containing \"{trimmed}\"."); } } } if (text.RegexMatch(out match, "^((?:(?:find|search)|claim|view|all){2,4}) (.+)")) { bool validFind = match.Groups[1].Value.Contains("find") || match.Groups[1].Value.Contains("search"); bool validClaim = match.Groups[1].Value.Contains("claim"); if (!validFind || !validClaim) { return; } bool validView = match.Groups[1].Value.Contains("view"); bool validAll = match.Groups[1].Value.Contains("all"); string[] queries = match.Groups[2].Value.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries); int counter = 0; foreach (string query in queries) { if (counter == 2) { return; } string trimmed = query.Trim(); IEnumerable <string> modules = ComponentHandles.Where(handle => handle.HeaderText.ContainsIgnoreCase(trimmed) && GameRoom.Instance.IsCurrentBomb(handle.bombID) && !handle.Solved && !handle.Claimed) .OrderByDescending(handle => handle.HeaderText.EqualsIgnoreCase(trimmed)).Select(handle => $"{handle.Code}").ToList(); if (modules.Any()) { if (!validAll) { modules = modules.Take(1); } foreach (string module in modules) { TwitchComponentHandle handle = ComponentHandles.FirstOrDefault(x => x.Code.Equals(module)); if (handle == null || !GameRoom.Instance.IsCurrentBomb(handle.bombID)) { continue; } handle.AddToClaimQueue(userNickName, validView); } if (validAll) { counter++; } } else { IRCConnection.Instance.SendMessage($"Couldn't find any modules containing \"{trimmed}\"."); } } return; } if (text.Equals("newbomb", StringComparison.InvariantCultureIgnoreCase) && OtherModes.ZenModeOn) { TwitchPlaySettings.SetRewardBonus(0); foreach (var handle in ComponentHandles.Where(x => GameRoom.Instance.IsCurrentBomb(x.bombID))) { if (!handle.Solved) { handle.SolveSilently(); } } return; } } if (text.RegexMatch(out match, "^notes(-?[0-9]+)$") && int.TryParse(match.Groups[1].Value, out index)) { if (!_notesDictionary.ContainsKey(index - 1)) { _notesDictionary[index - 1] = TwitchPlaySettings.data.NotesSpaceFree; } IRCConnection.Instance.SendMessage(TwitchPlaySettings.data.Notes, index, _notesDictionary[index - 1]); return; } switch (UserAccess.HighestAccessLevel(userNickName)) { case AccessLevel.Streamer: case AccessLevel.SuperUser: if (text.RegexMatch(out match, @"^setmultiplier ([0-9]+(?:\.[0-9]+)*)$")) { OtherModes.SetMultiplier(float.Parse(match.Groups[1].Value)); return; } if (text.Equals("solvebomb", StringComparison.InvariantCultureIgnoreCase)) { foreach (var handle in ComponentHandles.Where(x => GameRoom.Instance.IsCurrentBomb(x.bombID))) { if (!handle.Solved) { handle.SolveSilently(); } } return; } goto case AccessLevel.Admin; case AccessLevel.Admin: if (text.Equals("enablecamerawall", StringComparison.InvariantCultureIgnoreCase) || text.Equals("enablemodulewall", StringComparison.InvariantCultureIgnoreCase)) { moduleCameras.EnableWallOfCameras(); StartCoroutine(HideBombs()); } if (text.Equals("disablecamerawall", StringComparison.InvariantCultureIgnoreCase) || text.Equals("disablemodulewall", StringComparison.InvariantCultureIgnoreCase)) { moduleCameras.DisableWallOfCameras(); _hideBombs = false; } goto case AccessLevel.Mod; case AccessLevel.Mod: if (text.RegexMatch(out match, @"^assign (\S+) (.+)")) { var split = match.Groups[2].Value.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var assign in split) { TwitchComponentHandle handle = ComponentHandles.FirstOrDefault(x => x.Code.Equals(assign)); if (handle == null || !GameRoom.Instance.IsCurrentBomb(handle.bombID)) { continue; } handle.OnMessageReceived(userNickName, userColorCode, string.Format("assign {0}", match.Groups[1].Value)); } return; } if (text.RegexMatch("^bot ?unclaim( ?all)?$")) { userNickName = IRCConnection.Instance.UserNickName; foreach (TwitchComponentHandle handle in ComponentHandles) { handle.RemoveFromClaimQueue(userNickName); } string[] moduleIDs = ComponentHandles.Where(x => !x.Solved && x.PlayerName != null && x.PlayerName.Equals(userNickName, StringComparison.InvariantCultureIgnoreCase)) .Select(x => x.Code).ToArray(); foreach (var claim in moduleIDs) { TwitchComponentHandle handle = ComponentHandles.FirstOrDefault(x => x.Code.Equals(claim)); if (handle == null || !GameRoom.Instance.IsCurrentBomb(handle.bombID)) { continue; } handle.OnMessageReceived(userNickName, userColorCode, "unclaim"); } return; } if (text.Equals("filledgework", StringComparison.InvariantCultureIgnoreCase)) { foreach (var commander in BombCommanders) { commander.FillEdgework(_currentBomb != commander.twitchBombHandle.bombID); } return; } break; } GameRoom.Instance.RefreshBombID(ref _currentBomb); if (_currentBomb > -1) { //Check for !bomb messages, and pass them off to the currently held bomb. if (text.RegexMatch(out match, "^bomb (.+)")) { string internalCommand = match.Groups[1].Value; text = string.Format("bomb{0} {1}", _currentBomb + 1, internalCommand); } if (text.RegexMatch(out match, "^edgework$")) { text = string.Format("edgework{0}", _currentBomb + 1); } else { if (text.RegexMatch(out match, "^edgework (.+)")) { string internalCommand = match.Groups[1].Value; text = string.Format("edgework{0} {1}", _currentBomb + 1, internalCommand); } } } foreach (TwitchBombHandle handle in BombHandles) { if (handle == null) { continue; } IEnumerator onMessageReceived = handle.OnMessageReceived(userNickName, userColorCode, text); if (onMessageReceived == null) { continue; } if (_currentBomb != handle.bombID) { if (!GameRoom.Instance.IsCurrentBomb(handle.bombID)) { continue; } _coroutineQueue.AddToQueue(BombHandles[_currentBomb].HideMainUIWindow(), handle.bombID); _coroutineQueue.AddToQueue(handle.ShowMainUIWindow(), handle.bombID); _coroutineQueue.AddToQueue(BombCommanders[_currentBomb].LetGoBomb(), handle.bombID); _currentBomb = handle.bombID; } _coroutineQueue.AddToQueue(onMessageReceived, handle.bombID); } foreach (TwitchComponentHandle componentHandle in ComponentHandles) { if (!GameRoom.Instance.IsCurrentBomb(componentHandle.bombID)) { continue; } if (!text.StartsWith(componentHandle.Code + " ")) { continue; } IEnumerator onMessageReceived = componentHandle.OnMessageReceived(userNickName, userColorCode, text.Substring(componentHandle.Code.Length + 1)); if (onMessageReceived == null) { continue; } if (_currentBomb != componentHandle.bombID) { _coroutineQueue.AddToQueue(BombHandles[_currentBomb].HideMainUIWindow(), componentHandle.bombID); _coroutineQueue.AddToQueue(BombHandles[componentHandle.bombID].ShowMainUIWindow(), componentHandle.bombID); _coroutineQueue.AddToQueue(BombCommanders[_currentBomb].LetGoBomb(), componentHandle.bombID); _currentBomb = componentHandle.bombID; } _coroutineQueue.AddToQueue(onMessageReceived, componentHandle.bombID); } if (TwitchPlaySettings.data.BombCustomMessages.ContainsKey(text.ToLowerInvariant())) { IRCConnection.Instance.SendMessage(TwitchPlaySettings.data.BombCustomMessages[text.ToLowerInvariant()]); } }