Пример #1
0
        public async Task <bool> CheckBlacklist(LithiumContext context, List <GuildModel.Guild.antispams.IgnoreRole> exemptcheck, CommandInfo CMDCheck)
        {
            var guild = context.Server;

            if (guild.Antispam.Blacklist.BlacklistWordSet.Any())
            {
                if (CMDCheck == null)
                {
                    var BypassBlacklist = exemptcheck.Any(x => x.Blacklist);

                    if (!BypassBlacklist)
                    {
                        var blacklistdetected       = false;
                        var blacklistmessage        = guild.Antispam.Blacklist.DefaultBlacklistMessage;
                        var detectedblacklistmodule = guild.Antispam.Blacklist.BlacklistWordSet.FirstOrDefault(blist => blist.WordList.Any(x => context.Message.Content.ToLower().Contains(x.ToLower())));
                        if (detectedblacklistmodule != null)
                        {
                            blacklistdetected = true;
                            blacklistmessage  = detectedblacklistmodule.BlacklistResponse ?? guild.Antispam.Blacklist.DefaultBlacklistMessage;
                        }

                        if (blacklistdetected)
                        {
                            await context.Message?.DeleteAsync();

                            if (!string.IsNullOrEmpty(blacklistmessage))
                            {
                                var result = Formatting.DoReplacements(blacklistmessage, context);
                                await context.Channel.SendMessageAsync(result);
                            }

                            if (guild.Antispam.Blacklist.WarnOnDetection)
                            {
                                await guild.AddWarn("AutoMod - Blacklist", context.User as IGuildUser, context.Client.CurrentUser, context.Channel, context.Message.Content);

                                guild.Save();
                            }

                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Пример #2
0
        public async Task <bool> AntiInvite(LithiumContext context, List <GuildModel.Guild.antispams.IgnoreRole> exemptcheck)
        {
            var guild         = context.Server;
            var bypass_invite = exemptcheck.Any(x => x.Advertising);

            if (!bypass_invite)
            {
                if (Regex.Match(context.Message.Content, @"(http|https)?(:)?(\/\/)?(discordapp|discord).(gg|io|me|com)\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!-/]))?").Success)
                {
                    await context.Message?.DeleteAsync();

                    var emb = new EmbedBuilder();
                    if (guild.Antispam.Advertising.NoInviteMessage != null)
                    {
                        emb.Description = Formatting.DoReplacements(guild.Antispam.Advertising.NoInviteMessage, context);
                    }
                    else
                    {
                        emb.Description = $"{context.User} - This server does not allow you to send invite links in chat";
                    }

                    // Description = guild.Antispam.Advertising.NoInviteMessage ?? $"{context.User?.Mention} - no sending invite links... the admins might get angry"
                    await context.Channel.SendMessageAsync(string.Empty, false, emb.Build());

                    if (guild.Antispam.Advertising.WarnOnDetection)
                    {
                        await guild.AddWarn("AutoMod - Anti Advertising", context.User as IGuildUser, context.Client.CurrentUser, context.Channel, context.Message.Content);

                        guild.Save();
                    }

                    return(true);
                }
            }

            return(false);
        }
Пример #3
0
        public async Task <bool> AntiInvite(LithiumContext context, List <GuildModel.Guild.antispams.IgnoreRole> exemptcheck)
        {
            var guild        = context.Server;
            var BypassInvite = exemptcheck.Any(x => x.Advertising);

            if (!BypassInvite)
            {
                if (Regex.Match(context.Message.Content, @"(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 context.Message?.DeleteAsync();

                    var emb = new EmbedBuilder();
                    if (guild.Antispam.Advertising.NoInviteMessage != null)
                    {
                        emb.Description = Formatting.DoReplacements(guild.Antispam.Advertising.NoInviteMessage, context);
                    }
                    else
                    {
                        emb.Description = $"{context.User} - This server does not allow you to send invite links in chat";
                    }
                    //    Description = guild.Antispam.Advertising.NoInviteMessage ?? $"{context.User?.Mention} - no sending invite links... the admins might get angry"
                    await context.Channel.SendMessageAsync("", false, emb.Build());

                    if (guild.Antispam.Advertising.WarnOnDetection)
                    {
                        await guild.AddWarn("AutoMod - Anti Advertising", context.User as IGuildUser, context.Client.CurrentUser, context.Channel);

                        guild.Save();
                    }

                    return(true);
                }
            }

            return(false);
        }
Пример #4
0
        public async Task <bool> AntiMention(LithiumContext context, List <GuildModel.Guild.antispams.IgnoreRole> exemptcheck)
        {
            var guild          = context.Server;
            var bypass_mention = exemptcheck.Any(x => x.Mention);

            if (!bypass_mention)
            {
                if (guild.Antispam.Mention.RemoveMassMention)
                {
                    if (context.Message.MentionedRoleIds.Count + context.Message.MentionedUserIds.Count >= 5)
                    {
                        await context.Message?.DeleteAsync();

                        var emb = new EmbedBuilder
                        {
                            Description = $"{context.User} - This server does not allow you to mention 5+ roles or uses at once"
                        };
                        await context.Channel.SendMessageAsync(string.Empty, false, emb.Build());

                        if (guild.Antispam.Mention.WarnOnDetection)
                        {
                            await guild.AddWarn("AutoMod - Mass Mention", context.User as IGuildUser, context.Client.CurrentUser, context.Channel, context.Message.Content);

                            guild.Save();
                        }

                        return(true);
                    }
                }

                if (guild.Antispam.Mention.MentionAll)
                {
                    if (context.Message.Content.Contains("@everyone") || context.Message.Content.Contains("@here"))
                    {
                        await context.Message?.DeleteAsync();

                        var emb = new EmbedBuilder();
                        if (guild.Antispam.Mention.MentionAllMessage != null)
                        {
                            emb.Description = Formatting.DoReplacements(guild.Antispam.Mention.MentionAllMessage, context);
                        }
                        else
                        {
                            emb.Title = $"{context.User} - This server has disabled the ability for you to mention @everyone and @here";
                        }

                        await context.Channel.SendMessageAsync(string.Empty, false, emb.Build());

                        if (guild.Antispam.Mention.WarnOnDetection)
                        {
                            await guild.AddWarn("AutoMod - Mention All", context.User as IGuildUser, context.Client.CurrentUser, context.Channel, context.Message.Content);

                            guild.Save();
                        }

                        return(true);
                    }
                }
            }

            return(false);
        }