コード例 #1
0
        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}" });
        }
コード例 #2
0
ファイル: Tests.cs プロジェクト: Raymonf/ProfanityFilter
 public void TestContainsProfanity_WithProfanity()
 {
     Assert.True(profanity.ContainsProfanity("f**k"));
     Assert.True(profanity.ContainsProfanity("shit"));
     Assert.IsTrue(profanity.ContainsProfanity("f**k off twat"));
 }
コード例 #3
0
 public void TestContainsProfanity()
 {
     Assert.True(profanity.ContainsProfanity("he is a m0th3rf*cker"));
 }