public static void DeleteBlackWord(string typeStr, string word) { BlackWordType type; if (!Enum.TryParse(typeStr, true, out type)) { return; } BlackWord wordStruct = Words.FirstOrDefault(wordS => wordS.Type == type && word.Contains(wordS.Word)); if (string.IsNullOrEmpty(wordStruct.Word)) { return; } Words.Remove(wordStruct); using (IQueryAdapter adapter = Yupi.GetDatabaseManager().GetQueryReactor()) { adapter.SetQuery("DELETE FROM server_blackwords WHERE word = @word AND type = @type"); adapter.AddParameter("word", word); adapter.AddParameter("type", typeStr); adapter.RunQuery(); } }
/// <summary> /// Checks the specified string. /// </summary> /// <param name="str">The string.</param> /// <param name="type">The type.</param> /// <param name="word">The word.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public static bool Check(string str, BlackWordType type, out BlackWord word) { word = Empty; if (!Replaces.ContainsKey(type)) { return(false); } BlackWordTypeSettings data = Replaces[type]; str = UserChatInputFilter.Replace(data.Filter, str); BlackWord wordFirst = Words.FirstOrDefault(wordStruct => wordStruct.Type == type && str.Contains(wordStruct.Word)); word = wordFirst; return(!string.IsNullOrEmpty(wordFirst.Word)); }
/// <summary> /// Checks the specified string. /// </summary> /// <param name="str">The string.</param> /// <param name="type">The type.</param> /// <param name="word">The word.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public static bool Check(string str, BlackWordType type, out BlackWord word) { word = Empty; if (!Replaces.ContainsKey(type)) return false; var data = Replaces[type]; str = Filter.Replace(data.Filter, str); var wordFirst = Words.FirstOrDefault(wordStruct => wordStruct.Type == type && str.Contains(wordStruct.Word)); word = wordFirst; return !string.IsNullOrEmpty(wordFirst.Word); }