/// <summary> /// Adds the inputed player name to their player station if it is not profane /// </summary> /// <param name="Name">The players name</param> public void SaveName(InputField Name) { string username = Name.text; if (Profanity.ValidateName(username)) { GameVariables.PlayerStations[PlayerNumber].SetName(username); Name.transform.parent.parent.gameObject.SetActive(false); GameVariables.Ready++; if (GameVariables.Ready == GameVariables.PlayerStations.Count) //Calls main menu if all players have finished { MainMenu(); } } else { Name.text = ""; Alert.SetActive(true); //Todo: clear input and alert user to change their name } }
public async Task SetMessageAsync([Remainder] string message) { if (message.Length > 1000) { await SimpleEmbedAsync($"Partner Message must be shorter than 1000 characters. Given: {message.Length}"); return; } if (Context.Message.MentionedRoles.Any() || Context.Message.MentionedUsers.Any() || Context.Message.MentionedChannels.Any() || Context.Message.Content.Contains("@everyone") || Context.Message.Content.Contains("@here")) { await SimpleEmbedAsync("Partner Message cannot contain role or user mentions as they cannot be referenced from external guilds"); return; } if (Profanity.ContainsProfanity(message)) { await SimpleEmbedAsync("Partner Message cannot contain profanity"); return; } if (message.ToLower().Contains("discord.gg") || message.ToLower().Contains("discordapp.com") || message.ToLower().Contains("discord.me") || Regex.Match(message, @"(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?(d+i+s+c+o+r+d+|a+p+p)+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$").Success) { await SimpleEmbedAsync("No need to include an invite to the bot in your message. PassiveBOT will automatically generate one"); return; /* * var invites = Regex.Matches(message, @"(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?(d+i+s+c+o+r+d+|a+p+p)+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$").OfType<Match>().ToList(); * var inviteMetadata = await Context.Guild.GetInvitesAsync(); * var mismatch = false; * foreach (var invite in invites) * { * var match = inviteMetadata.Where(x => x.MaxAge == null).FirstOrDefault(x => invite.ToString().ToLower().Contains(x.Code.ToLower())); * if (match == null) * { * mismatch = true; * } * } * * if (mismatch) * { * throw new Exception("Please ensure the message passes all checks:\n" + "1.Only invites from this server are allowed in the partner message!\n" + "2.Ensure that the invite link you are using is set to never expire\n" + "3.Ensure that it does not have a use limit.\n" + "4.If your server uses 2FA please disable it while running the command then re-enable it after\n" + "If you are using an invite for your server and you are seeing this message, please generate a new invite for your server\n\n" + $"If you believe this is an error, please contact the support server: {HomeModel.Load().HomeInvite}"); * } */ } var p = PartnerService.GetPartnerInfo(Context.Guild.Id, true); p.Message.Content = message; p.Save(); var generateMessage = PartnerHelp.GenerateMessage(p, Context.Guild); await ReplyAsync(generateMessage); await PartnerHelp.PartnerLogAsync(Context.Client, p, new EmbedFieldBuilder { Name = "Partner Message Updated", Value = $"Guild: {Context.Guild.Name} [{Context.Guild.Id}]\n" + $"Owner: {Context.Guild.Owner.Username}\n" + $"Users: {Context.Guild.MemberCount}" }); }
public void Setup() { profanity = new Profanity(); // These tests assume **** for every single swear filter // Useful function for original library compatibility too profanity.SetOriginalBehaviorMode(true); // Preload censored word list profanity.LoadCensorWords(); }
public static (bool isValid, List <string> errors) ValidateProfanity(string s) { string api = $"https://www.purgomalum.com/service/json?text={s}"; Profanity res = GetObject <Profanity>(CallWebApi(api)); List <string> errors = new List <string>(); string[] input = s.Split(' '); string[] output = res.result.Split(' '); for (int i = 0; i < input.Length; i++) { string dif = string.Join("", input[i].ToArray().Where(item => !output[i].Contains(item.ToString())).ToArray()); if (dif.Length > 0) { errors.Add(dif); } } if (errors.Count == 0) { return(true, errors); } return(false, errors); }
/// <summary> /// Removes a score from the database /// </summary> /// <param name="Name"></param> public void DeleteName(InputField Name) { DB.RemoveScore(Name.text); Profanity.BlacklistWord(Name.text); Name.text = ""; }
protected void btnCompleteProfile_Click(object sender, EventArgs e) { if (!cbxCasual.Checked && !cbxDiscreet.Checked && !cbxFriendship.Checked && !cbxLongTerm.Checked && !cbxMutually.Checked && !cbxShortDating.Checked) { MyUtils.DisplayCustomMessageInValidationSummary("You should select 'What Are You Loking For?'", RegisterUserValidationSummary, "RegisterUserValidationGroup"); return; } title = MyUtils.StripHTML(profileHeadline.Text.Trim()); desc = MyUtils.StripHTML(describe.Text.Trim()); date = MyUtils.StripHTML(ideal.Text.Trim()); nGram g = new nGram(); string s = title + ". " + desc + ". " + date; double q; q = g.CalculateQuality(s); if (q < 0.11) { MyUtils.DisplayCustomMessageInValidationSummary("Your description is below our quality standards. Please use correct grammar and write in complete sentences.", RegisterUserValidationSummary, "RegisterUserValidationGroup"); return; } if (g.WordCount < 5) { MyUtils.DisplayCustomMessageInValidationSummary("Your description doesn't have enough details. Please describe yourself in detail using correct grammar and complete sentences.", RegisterUserValidationSummary, "RegisterUserValidationGroup"); return; } string xx; xx = Profanity.TestAndMessage(desc); if (xx != null) { MyUtils.DisplayCustomMessageInValidationSummary("Your description " + xx, RegisterUserValidationSummary, "RegisterUserValidationGroup"); return; } xx = Profanity.TestAndMessage(title); if (xx != null) { MyUtils.DisplayCustomMessageInValidationSummary("Your title " + xx, RegisterUserValidationSummary, "RegisterUserValidationGroup"); return; } xx = Profanity.TestAndMessage(date); if (xx != null) { MyUtils.DisplayCustomMessageInValidationSummary("Your ideal date description " + xx, RegisterUserValidationSummary, "RegisterUserValidationGroup"); return; } desc = ReplaceEmail(desc); title = ReplaceEmail(title); date = ReplaceEmail(date); zip = MyUtils.StripHTML(zipCode.Text); otherZipData = MyUtils.GetZipCoordinates(zip.ToString()); if (otherZipData == null) { MyUtils.DisplayCustomMessageInValidationSummary("ZIP code does not exist. Please enter valid zip code.", RegisterUserValidationSummary, "RegisterUserValidationGroup"); return; } SaveUserInDB(); MyUtils.RefreshUserRow(); if (IsRegistration) { Session["message"] = "Your profile has been saved. Please upload photos."; Response.Redirect("~/Account/UploadPhotos?hidemenu=1"); } else { Session["message"] = "Your profile has been updated"; Response.Redirect(Utils.GetProfileLink(ID_USER)); } }
public void Setup() { profanity = new Profanity(); // Preload censored word list profanity.LoadCensorWords(); }
protected void btnSignUp_Click(object sender, EventArgs e) { int id_user; try { txtName.Text = txtName.Text.Trim(); txtPassword.Text = txtPassword.Text.Trim(); txtEmail.Text = txtEmail.Text.Trim(); if (db.ExecuteScalarInt(string.Format("select count(*) from users where username = {0}", MyUtils.safe(txtName.Text))) > 0) { MyUtils.DisplayCustomMessageInValidationSummary("User with this Username already exists.", ValidationSummary1); return; } if (db.ExecuteScalarInt(string.Format("select count(*) from users where email = {0}", MyUtils.safe(txtEmail.Text))) > 0) { MyUtils.DisplayCustomMessageInValidationSummary("User with this Email Address already exists.", ValidationSummary1); return; } string xx = Profanity.TestAndMessage(txtName.Text); if (xx != null) { MyUtils.DisplayCustomMessageInValidationSummary("User name " + xx, ValidationSummary1); return; } DataSet d = db.CommandBuilder_LoadDataSet("select * from users where id_user=-1"); //get the columns schema DataRow n = d.Tables[0].NewRow(); n["username"] = MyUtils.StripHTML(txtName.Text); n["password"] = txtPassword.Text; n["email"] = txtEmail.Text; n["sex"] = MyUtils.StripHTML(ddlGender.SelectedValue); string error = ""; DateTime dt = birthday.GetBirthday(out error); if (error != "") { MyUtils.DisplayCustomMessageInValidationSummary(error, ValidationSummary1); return; } n["birthdate"] = dt; n["country"] = 28; // United States d.Tables[0].Rows.Add(n); id_user = db.CommandBuilder_SaveDataset(); //gets back @@identity EmailWrapper mw = new EmailWrapper(); mw.SendTemplate("EMAIL_ACTIVATE", id_user); string membership = ""; MyUtils.authenticate(txtName.Text, txtPassword.Text, out membership); FormsAuthentication.SetAuthCookie(txtName.Text, false); Response.Redirect("~/Account/Registration"); } finally { db.CommandBuilder_Disconnect(); } }