diff --git a/NadekoBot/Classes/ServerSpecificConfig.cs b/NadekoBot/Classes/ServerSpecificConfig.cs index 4296b648..b92915f1 100644 --- a/NadekoBot/Classes/ServerSpecificConfig.cs +++ b/NadekoBot/Classes/ServerSpecificConfig.cs @@ -100,6 +100,21 @@ namespace NadekoBot.Classes } } + [JsonIgnore] + private ObservableCollection logserverIgnoreChannels; + public ObservableCollection LogserverIgnoreChannels { + get { return logserverIgnoreChannels; } + set { + logserverIgnoreChannels = value; + if (value != null) + logserverIgnoreChannels.CollectionChanged += (s, e) => + { + if (!SpecificConfigurations.Instantiated) return; + OnPropertyChanged(); + }; + } + } + [JsonProperty("LogPresenceChannel")] private ulong? logPresenceChannel = null; [JsonIgnore] @@ -212,6 +227,7 @@ namespace NadekoBot.Classes ObservingStreams = new ObservableCollection(); GenerateCurrencyChannels = new ObservableConcurrentDictionary(); VoiceChannelLog = new ObservableConcurrentDictionary(); + LogserverIgnoreChannels = new ObservableCollection(); } public event PropertyChangedEventHandler PropertyChanged = delegate { SpecificConfigurations.Default.Save(); }; diff --git a/NadekoBot/Modules/Administration/Commands/LogCommand.cs b/NadekoBot/Modules/Administration/Commands/LogCommand.cs index 8f51c9e5..25107ca0 100644 --- a/NadekoBot/Modules/Administration/Commands/LogCommand.cs +++ b/NadekoBot/Modules/Administration/Commands/LogCommand.cs @@ -51,8 +51,9 @@ namespace NadekoBot.Modules.Administration.Commands { try { - var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel; - if (chId == null) + var config = SpecificConfigurations.Default.Of(e.Server.Id); + var chId = config.LogServerChannel; + if (chId == null || config.LogserverIgnoreChannels.Contains(e.After.Id)) return; Channel ch; if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) @@ -72,8 +73,9 @@ namespace NadekoBot.Modules.Administration.Commands { try { - var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel; - if (chId == null) + var config = SpecificConfigurations.Default.Of(e.Server.Id); + var chId = config.LogServerChannel; + if (chId == null || config.LogserverIgnoreChannels.Contains(e.Channel.Id)) return; Channel ch; if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) @@ -87,8 +89,9 @@ namespace NadekoBot.Modules.Administration.Commands { try { - var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel; - if (chId == null) + var config = SpecificConfigurations.Default.Of(e.Server.Id); + var chId = config.LogServerChannel; + if (chId == null || config.LogserverIgnoreChannels.Contains(e.Channel.Id)) return; Channel ch; if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) @@ -164,8 +167,9 @@ namespace NadekoBot.Modules.Administration.Commands { if (e.Server == null || e.Channel.IsPrivate || e.User.Id == NadekoBot.Client.CurrentUser.Id) return; - var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel; - if (chId == null || e.Channel.Id == chId) + var config = SpecificConfigurations.Default.Of(e.Server.Id); + var chId = config.LogServerChannel; + if (chId == null || e.Channel.Id == chId || config.LogserverIgnoreChannels.Contains(e.Channel.Id)) return; Channel ch; if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) @@ -192,8 +196,9 @@ namespace NadekoBot.Modules.Administration.Commands { if (e.Server == null || e.Channel.IsPrivate || e.User?.Id == NadekoBot.Client.CurrentUser.Id) return; - var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel; - if (chId == null || e.Channel.Id == chId) + var config = SpecificConfigurations.Default.Of(e.Server.Id); + var chId = config.LogServerChannel; + if (chId == null || e.Channel.Id == chId || config.LogserverIgnoreChannels.Contains(e.Channel.Id)) return; Channel ch; if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) @@ -219,8 +224,9 @@ namespace NadekoBot.Modules.Administration.Commands { if (e.Server == null || e.Channel.IsPrivate || e.User?.Id == NadekoBot.Client.CurrentUser.Id) return; - var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel; - if (chId == null || e.Channel.Id == chId) + var config = SpecificConfigurations.Default.Of(e.Server.Id); + var chId = config.LogServerChannel; + if (chId == null || e.Channel.Id == chId || config.LogserverIgnoreChannels.Contains(e.Channel.Id)) return; Channel ch; if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) @@ -370,6 +376,25 @@ $@"🕔`{prettyCurrentTime}` **Message** 📝 `#{e.Channel.Name}` await e.Channel.SendMessage($"❗**NO LONGER LOGGING IN {ch.Mention} CHANNEL**❗").ConfigureAwait(false); }); + + cgb.CreateCommand(Prefix + "logignore") + .Alias($"Toggles whether the {Prefix}logserver command ignores this channel. Useful if you have hidden admin channel and public log channel.") + .AddCheck(SimpleCheckers.OwnerOnly()) + .AddCheck(SimpleCheckers.ManageServer()) + .Do(async e => + { + var config = SpecificConfigurations.Default.Of(e.Server.Id); + if (config.LogserverIgnoreChannels.Remove(e.Channel.Id)) + { + await e.Channel.SendMessage($"`{Prefix}logserver will stop ignoring this channel.`"); + } + else + { + config.LogserverIgnoreChannels.Add(e.Channel.Id); + await e.Channel.SendMessage($"`{Prefix}logserver will ignore this channel.`"); + } + }); + cgb.CreateCommand(Module.Prefix + "userpresence") .Description("Starts logging to this channel when someone from the server goes online/offline/idle.") .AddCheck(SimpleCheckers.ManageServer()) diff --git a/NadekoBot/Modules/DiscordCommand.cs b/NadekoBot/Modules/DiscordCommand.cs index 726c813b..05f9a42a 100644 --- a/NadekoBot/Modules/DiscordCommand.cs +++ b/NadekoBot/Modules/DiscordCommand.cs @@ -7,7 +7,7 @@ namespace NadekoBot.Classes /// Base DiscordCommand Class. /// Inherit this class to create your own command. /// - internal abstract class DiscordCommand + public abstract class DiscordCommand { /// diff --git a/NadekoBot/Modules/DiscordModule.cs b/NadekoBot/Modules/DiscordModule.cs index 48427732..5e131233 100644 --- a/NadekoBot/Modules/DiscordModule.cs +++ b/NadekoBot/Modules/DiscordModule.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using NadekoBot.Classes; namespace NadekoBot.Modules { - internal abstract class DiscordModule : IModule { + public abstract class DiscordModule : IModule { protected readonly HashSet commands = new HashSet(); public abstract string Prefix { get; }