public override Boolean Set(String property, IEnumerable <String> arguments) { switch (property.ToLower()) { case "u": case "user": case "users": switch (arguments.FirstOrDefault()) { case "c": case "clear": UsersToReplyTo.Clear(); break; } break; case "c": case "compare": case "comparator": Comparator = arguments.FirstOrDefault() switch { "c" or "contain" or "contains" => ContainsComparator, _ => EqualsComparator, }; break; case "w": case "with": // If there are no arguments, this will return empty string, // indicating the default behaviour of mirror the trigger // message. ReplyMessage = String.Join(' ', arguments); return(true); case "t": case "to": // If there are no arguments, this will return empty string, // indicating the default behaviour of replying to any // message. TriggerMessage = String.Join(' ', arguments); return(true); default: return(false); } return(true); }
private void TwitchClient_OnMessageReceived(Object sender, OnMessageReceivedArgs e) { if (UsersToReplyTo.Any() && !UsersToReplyTo.Contains(e.ChatMessage.Username)) { return; } if (!Comparator.Matches(e.ChatMessage.Message, TriggerMessage)) { return; } String replyMessage = String.IsNullOrWhiteSpace(ReplyMessage) ? TriggerMessage : ReplyMessage; String replyMessageWithUserName = replyMessage.Replace("@", $"@{e.ChatMessage.DisplayName}"); TwitchClientManager.SpoolMessage(replyMessageWithUserName); }
public override Boolean Remove(String property, IEnumerable <String> arguments) { switch (property) { case "u": case "user": case "users": Int32 beforeCount = UsersToReplyTo.Count; foreach (String username in arguments) { UsersToReplyTo.Remove(username); } return(beforeCount != UsersToReplyTo.Count); default: return(false); } }