public FilterWords(DiscordModule module) : base(module)
        {
            NadekoBot.OnReady += () => NadekoBot.Client.MessageReceived += async(sender, args) =>
            {
                if (args.Channel.IsPrivate || args.User.Id == NadekoBot.Client.CurrentUser.Id)
                {
                    return;
                }
                try
                {
                    Classes.ServerPermissions serverPerms;
                    if (!IsChannelOrServerFiltering(args.Channel, out serverPerms))
                    {
                        return;
                    }

                    var wordsInMessage = args.Message.RawText.ToLowerInvariant().Split(' ');
                    if (serverPerms.Words.Any(w => wordsInMessage.Contains(w)))
                    {
                        await args.Message.Delete().ConfigureAwait(false);

                        IncidentsHandler.Add(args.Server.Id, args.Channel.Id, $"User [{args.User.Name}/{args.User.Id}] posted " +
                                             $"BANNED WORD in [{args.Channel.Name}/{args.Channel.Id}] channel.\n" +
                                             $"`Full message:` {args.Message.Text}");
                        if (serverPerms.Verbose)
                        {
                            await args.Channel.SendMessage($"{args.User.Mention} One or more of the words you used " +
                                                           $"in that sentence are not allowed here.")
                            .ConfigureAwait(false);
                        }
                    }
                }
                catch { }
            };
        }
Example #2
0
        public FilterInvitesCommand(DiscordModule module) : base(module)
        {
            MidnightBot.Client.MessageReceived += async(sender, args) =>
            {
                if (args.Channel.IsPrivate || args.User.Id == MidnightBot.Client.CurrentUser.Id)
                {
                    return;
                }
                try
                {
                    Classes.ServerPermissions serverPerms;
                    if (!IsChannelOrServerFiltering(args.Channel, out serverPerms))
                    {
                        return;
                    }

                    if (filterRegex.IsMatch(args.Message.RawText))
                    {
                        await args.Message.Delete().ConfigureAwait(false);

                        IncidentsHandler.Add(args.Server.Id, args.Channel.Id, $"Benutzer [{args.User.Name}/{args.User.Id}] hat einen " +
                                             $"EINLADUNGS LINK im [{args.Channel.Name}/{args.Channel.Id}] Channel gepostet.\n" +
                                             $"`Ganze Nachricht:` {args.Message.Text}");
                        if (serverPerms.Verbose)
                        {
                            await args.Channel.SendMessage($"{args.User.Mention} Invite Links sind " +
                                                           $"in diesem Channel nicht erlaubt.")
                            .ConfigureAwait(false);
                        }
                    }
                }
                catch { }
            };
        }
        public FilterInvitesCommand(DiscordModule module) : base(module)
        {
            WizBot.Client.MessageReceived += async(sender, args) =>
            {
                if (args.Channel.IsPrivate || args.User.Id == WizBot.Client.CurrentUser.Id)
                {
                    return;
                }
                try
                {
                    Classes.ServerPermissions serverPerms;
                    if (!IsChannelOrServerFiltering(args.Channel, out serverPerms))
                    {
                        return;
                    }

                    if (filterRegex.IsMatch(args.Message.RawText))
                    {
                        await args.Message.Delete().ConfigureAwait(false);

                        IncidentsHandler.Add(args.Server.Id, $"User [{args.User.Name}/{args.User.Id}] posted " +
                                             $"INVITE LINK in [{args.Channel.Name}/{args.Channel.Id}] channel. " +
                                             $"Full message: [[{args.Message.Text}]]");
                        if (serverPerms.Verbose)
                        {
                            await args.Channel.SendMessage($"{args.User.Mention} Invite links are not " +
                                                           $"allowed on this channel.")
                            .ConfigureAwait(false);
                        }
                    }
                }
                catch { }
            };
        }
Example #4
0
        public FilterWords(DiscordModule module) : base(module)
        {
            MidnightBot.Client.MessageReceived += async(sender, args) =>
            {
                if (args.Channel.IsPrivate || args.User.Id == MidnightBot.Client.CurrentUser.Id)
                {
                    return;
                }
                try
                {
                    Classes.ServerPermissions serverPerms;
                    if (!IsChannelOrServerFiltering(args.Channel, out serverPerms) || args.User.ServerPermissions.ManageMessages)
                    {
                        return;
                    }

                    var wordsInMessage = args.Message.RawText.ToLowerInvariant().Split(' ');
                    if (serverPerms.Words.Any(w => wordsInMessage.Contains(w)))
                    {
                        await args.Message.Delete().ConfigureAwait(false);

                        IncidentsHandler.Add(args.Server.Id, args.Channel.Id, $"Benutzer [{args.User.Name}/{args.User.Id}] schreib ein " +
                                             $"gebanntes Wort im Channel [{args.Channel.Name}/{args.Channel.Id}].\n" +
                                             $"`Ganze Nachricht:` {args.Message.Text}");
                        if (serverPerms.Verbose)
                        {
                            await args.Channel.SendMessage($"{args.User.Mention} Ein, oder mehrere Wörter " +
                                                           $"in diesem Satz sind hier nicht erlaubt.")
                            .ConfigureAwait(false);
                        }
                    }
                }
                catch { }
            };
        }