Initial split of the modules
This commit is contained in:
@ -0,0 +1,37 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
using NadekoBot.Common.Collections;
|
||||
using NadekoBot.Common.ModuleBehaviors;
|
||||
using NadekoBot.Services;
|
||||
|
||||
namespace NadekoBot.Modules.Permissions.Services
|
||||
{
|
||||
public class GlobalPermissionService : ILateBlocker, INService
|
||||
{
|
||||
public readonly ConcurrentHashSet<string> BlockedModules;
|
||||
public readonly ConcurrentHashSet<string> BlockedCommands;
|
||||
|
||||
public GlobalPermissionService(IBotConfigProvider bc)
|
||||
{
|
||||
BlockedModules = new ConcurrentHashSet<string>(bc.BotConfig.BlockedModules.Select(x => x.Name));
|
||||
BlockedCommands = new ConcurrentHashSet<string>(bc.BotConfig.BlockedCommands.Select(x => x.Name));
|
||||
}
|
||||
|
||||
public async Task<bool> TryBlockLate(DiscordSocketClient client, IUserMessage msg, IGuild guild, IMessageChannel channel, IUser user, string moduleName, string commandName)
|
||||
{
|
||||
await Task.Yield();
|
||||
commandName = commandName.ToLowerInvariant();
|
||||
|
||||
if (commandName != "resetglobalperms" &&
|
||||
(BlockedCommands.Contains(commandName) ||
|
||||
BlockedModules.Contains(moduleName.ToLowerInvariant())))
|
||||
{
|
||||
return true;
|
||||
//return new ExecuteCommandResult(cmd, null, SearchResult.FromError(CommandError.Exception, $"Command or module is blocked globally by the bot owner."));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user