From 5e267435d4077e4f2aa4308051904f3692d4124e Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Tue, 17 Oct 2017 07:03:56 +0200 Subject: [PATCH] fixed .log command not showing --- .../Modules/Administration/LogCommands.cs | 30 +++++++++---------- .../Services/LogCommandService.cs | 2 +- .../Modules/Gambling/Services/WaifuService.cs | 2 ++ .../Modules/Permissions/FilterCommands.cs | 16 +++++++--- .../Permissions/Services/FilterService.cs | 6 +++- .../Services/Database/Models/GuildConfig.cs | 20 +++++++++++++ 6 files changed, 55 insertions(+), 21 deletions(-) diff --git a/NadekoBot.Core/Modules/Administration/LogCommands.cs b/NadekoBot.Core/Modules/Administration/LogCommands.cs index 731809ae..2738a5de 100644 --- a/NadekoBot.Core/Modules/Administration/LogCommands.cs +++ b/NadekoBot.Core/Modules/Administration/LogCommands.cs @@ -124,49 +124,49 @@ namespace NadekoBot.Modules.Administration switch (type) { case LogType.Other: - channelId = logSetting.LogOtherId = (logSetting.LogOtherId == null ? channel.Id : default); + channelId = logSetting.LogOtherId = (logSetting.LogOtherId == null ? (ulong?)channel.Id : default); break; case LogType.MessageUpdated: - channelId = logSetting.MessageUpdatedId = (logSetting.MessageUpdatedId == null ? channel.Id : default); + channelId = logSetting.MessageUpdatedId = (logSetting.MessageUpdatedId == null ? (ulong?)channel.Id : default); break; case LogType.MessageDeleted: - channelId = logSetting.MessageDeletedId = (logSetting.MessageDeletedId == null ? channel.Id : default); + channelId = logSetting.MessageDeletedId = (logSetting.MessageDeletedId == null ? (ulong?)channel.Id : default); break; case LogType.UserJoined: - channelId = logSetting.UserJoinedId = (logSetting.UserJoinedId == null ? channel.Id : default); + channelId = logSetting.UserJoinedId = (logSetting.UserJoinedId == null ? (ulong?)channel.Id : default); break; case LogType.UserLeft: - channelId = logSetting.UserLeftId = (logSetting.UserLeftId == null ? channel.Id : default); + channelId = logSetting.UserLeftId = (logSetting.UserLeftId == null ? (ulong?)channel.Id : default); break; case LogType.UserBanned: - channelId = logSetting.UserBannedId = (logSetting.UserBannedId == null ? channel.Id : default); + channelId = logSetting.UserBannedId = (logSetting.UserBannedId == null ? (ulong?)channel.Id : default); break; case LogType.UserUnbanned: - channelId = logSetting.UserUnbannedId = (logSetting.UserUnbannedId == null ? channel.Id : default); + channelId = logSetting.UserUnbannedId = (logSetting.UserUnbannedId == null ? (ulong?)channel.Id : default); break; case LogType.UserUpdated: - channelId = logSetting.UserUpdatedId = (logSetting.UserUpdatedId == null ? channel.Id : default); + channelId = logSetting.UserUpdatedId = (logSetting.UserUpdatedId == null ? (ulong?)channel.Id : default); break; case LogType.UserMuted: - channelId = logSetting.UserMutedId = (logSetting.UserMutedId == null ? channel.Id : default); + channelId = logSetting.UserMutedId = (logSetting.UserMutedId == null ? (ulong?)channel.Id : default); break; case LogType.ChannelCreated: - channelId = logSetting.ChannelCreatedId = (logSetting.ChannelCreatedId == null ? channel.Id : default); + channelId = logSetting.ChannelCreatedId = (logSetting.ChannelCreatedId == null ? (ulong?)channel.Id : default); break; case LogType.ChannelDestroyed: - channelId = logSetting.ChannelDestroyedId = (logSetting.ChannelDestroyedId == null ? channel.Id : default); + channelId = logSetting.ChannelDestroyedId = (logSetting.ChannelDestroyedId == null ? (ulong?)channel.Id : default); break; case LogType.ChannelUpdated: - channelId = logSetting.ChannelUpdatedId = (logSetting.ChannelUpdatedId == null ? channel.Id : default); + channelId = logSetting.ChannelUpdatedId = (logSetting.ChannelUpdatedId == null ? (ulong?)channel.Id : default); break; case LogType.UserPresence: - channelId = logSetting.LogUserPresenceId = (logSetting.LogUserPresenceId == null ? channel.Id : default); + channelId = logSetting.LogUserPresenceId = (logSetting.LogUserPresenceId == null ? (ulong?)channel.Id : default); break; case LogType.VoicePresence: - channelId = logSetting.LogVoicePresenceId = (logSetting.LogVoicePresenceId == null ? channel.Id : default); + channelId = logSetting.LogVoicePresenceId = (logSetting.LogVoicePresenceId == null ? (ulong?)channel.Id : default); break; case LogType.VoicePresenceTTS: - channelId = logSetting.LogVoicePresenceTTSId = (logSetting.LogVoicePresenceTTSId == null ? channel.Id : default); + channelId = logSetting.LogVoicePresenceTTSId = (logSetting.LogVoicePresenceTTSId == null ? (ulong?)channel.Id : default); break; } diff --git a/NadekoBot.Core/Modules/Administration/Services/LogCommandService.cs b/NadekoBot.Core/Modules/Administration/Services/LogCommandService.cs index cae41488..17ba8293 100644 --- a/NadekoBot.Core/Modules/Administration/Services/LogCommandService.cs +++ b/NadekoBot.Core/Modules/Administration/Services/LogCommandService.cs @@ -950,7 +950,7 @@ namespace NadekoBot.Modules.Administration.Services break; } - if (!id.HasValue) + if (!id.HasValue || id == 0) { UnsetLogSetting(guild.Id, logChannelType); return null; diff --git a/NadekoBot.Core/Modules/Gambling/Services/WaifuService.cs b/NadekoBot.Core/Modules/Gambling/Services/WaifuService.cs index 2fbc4f26..17ccb4eb 100644 --- a/NadekoBot.Core/Modules/Gambling/Services/WaifuService.cs +++ b/NadekoBot.Core/Modules/Gambling/Services/WaifuService.cs @@ -8,5 +8,7 @@ namespace NadekoBot.Modules.Gambling.Services { public ConcurrentDictionary DivorceCooldowns { get; } = new ConcurrentDictionary(); public ConcurrentDictionary AffinityCooldowns { get; } = new ConcurrentDictionary(); + + } } diff --git a/NadekoBot.Core/Modules/Permissions/FilterCommands.cs b/NadekoBot.Core/Modules/Permissions/FilterCommands.cs index e300a5de..5bb47657 100644 --- a/NadekoBot.Core/Modules/Permissions/FilterCommands.cs +++ b/NadekoBot.Core/Modules/Permissions/FilterCommands.cs @@ -16,17 +16,25 @@ namespace NadekoBot.Modules.Permissions public partial class Permissions { [Group] - public class FilterCommands : NadekoSubmodule + public class FilterCommands : NadekoSubmodule { private readonly DbService _db; - private readonly FilterService _service; - public FilterCommands(FilterService service, DbService db) + public FilterCommands(DbService db) { - _service = service; _db = db; } + //[NadekoCommand, Usage, Description, Aliases] + //[RequireContext(ContextType.Guild)] + //public async Task SrvrFilterLinks() + //{ + // using (var uow = _db.UnitOfWork) + // { + // var config = + // } + //} + [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] public async Task SrvrFilterInv() diff --git a/NadekoBot.Core/Modules/Permissions/Services/FilterService.cs b/NadekoBot.Core/Modules/Permissions/Services/FilterService.cs index f0170f6a..f3596071 100644 --- a/NadekoBot.Core/Modules/Permissions/Services/FilterService.cs +++ b/NadekoBot.Core/Modules/Permissions/Services/FilterService.cs @@ -27,6 +27,9 @@ namespace NadekoBot.Modules.Permissions.Services public ConcurrentHashSet WordFilteringChannels { get; } public ConcurrentHashSet WordFilteringServers { get; } + //public ConcurrentHashSet LinkFilteringServers { get; } + //public ConcurrentDictionary LinkFilteringChannelSettings { get; } + public ConcurrentHashSet FilteredWordsForChannel(ulong channelId, ulong guildId) { ConcurrentHashSet words = new ConcurrentHashSet(); @@ -56,9 +59,10 @@ namespace NadekoBot.Modules.Permissions.Services var serverFiltering = bot.AllGuildConfigs.Where(gc => gc.FilterWords); WordFilteringServers = new ConcurrentHashSet(serverFiltering.Select(gc => gc.GuildId)); - WordFilteringChannels = new ConcurrentHashSet(bot.AllGuildConfigs.SelectMany(gc => gc.FilterWordsChannelIds.Select(fwci => fwci.ChannelId))); + //LinkFilteringServers = new ConcurrentHashSet(bot.AllGuildConfigs.Where(gc => gc.FilterLinks).Select(x => x.GuildId)); + _client.MessageUpdated += (oldData, newMsg, channel) => { var _ = Task.Run(() => diff --git a/NadekoBot.Core/Services/Database/Models/GuildConfig.cs b/NadekoBot.Core/Services/Database/Models/GuildConfig.cs index cd2c9b14..3cda8b09 100644 --- a/NadekoBot.Core/Services/Database/Models/GuildConfig.cs +++ b/NadekoBot.Core/Services/Database/Models/GuildConfig.cs @@ -55,6 +55,9 @@ namespace NadekoBot.Core.Services.Database.Models public bool FilterInvites { get; set; } public HashSet FilterInvitesChannelIds { get; set; } = new HashSet(); + public bool FilterLinks { get; set; } + public HashSet FilterLinksChannels { get; set; } = new HashSet(); + public bool FilterWords { get; set; } public HashSet FilteredWords { get; set; } = new HashSet(); public HashSet FilterWordsChannelIds { get; set; } = new HashSet(); @@ -211,6 +214,23 @@ namespace NadekoBot.Core.Services.Database.Models public ulong ChannelId { get; set; } } + public class FilterLinksChannelId : DbEntity + { + public ulong ChannelId { get; set; } + + public override bool Equals(object obj) + { + return obj is FilterLinksChannelId f + ? f.ChannelId == ChannelId + : false; + } + + public override int GetHashCode() + { + return ChannelId.GetHashCode(); + } + } + public class FilteredWord : DbEntity { public string Word { get; set; }