Exemple #1
0
        private void SetEnabled(ulong?serverId, bool enabled)
        {
            AdminModuleServerSettings serverSettings = GetSettings((ulong)serverId);

            serverSettings.wordFilterActive = enabled;
            serverSettings.MarkDirty();
        }
Exemple #2
0
        private bool RemoveWord(ulong?serverId, string word)
        {
            AdminModuleServerSettings serverSettings  = GetSettings((ulong)serverId);
            List <string>             bannedWordsList = new List <string>(serverSettings.bannedWords);

            if (!bannedWordsList.Remove(word.ToLower()))
            {
                return(false);
            }
            serverSettings.bannedWords = bannedWordsList.ToArray();
            serverSettings.MarkDirty();
            return(true);
        }
Exemple #3
0
 public async Task OnMessageReceived(MessageReceivedArgs args)
 {
     if (args.serverId != null)
     {
         AdminModuleServerSettings serverSettings = GetSettings((ulong)args.serverId);
         if (serverSettings.wordFilterActive)
         {
             if (serverSettings.bannedWords.Any(args.content.ToLower().Contains))
             {
                 MessageContext context = args.CreateMessageContext();
                 if (!context.authorPermissions.HasFlag(Permission.Admin) && !context.authorPermissions.HasFlag(Permission.ManageMessages))
                 {
                     DeleteResponse deleteResponse = new DeleteResponse(context);
                     await AdminModule.Instance.SendResponse(deleteResponse, context);
                 }
             }
         }
     }
 }
Exemple #4
0
 private AdminModuleServerSettings GetSettings(ulong id) => AdminModuleServerSettings.LoadOrCreate <AdminModuleServerSettings>(id);