mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
Medusa System Added
Read about the medusa system [here](https://nadekobot.readthedocs.io/en/latest/medusa/creating-a-medusa/)
This commit is contained in:
@@ -6,7 +6,7 @@ using NadekoBot.Services.Database.Models;
|
||||
|
||||
namespace NadekoBot.Modules.Permissions.Services;
|
||||
|
||||
public sealed class BlacklistService : IEarlyBehavior
|
||||
public sealed class BlacklistService : IExecOnMessage
|
||||
{
|
||||
public int Priority
|
||||
=> int.MaxValue;
|
||||
@@ -34,7 +34,7 @@ public sealed class BlacklistService : IEarlyBehavior
|
||||
return default;
|
||||
}
|
||||
|
||||
public Task<bool> RunBehavior(IGuild guild, IUserMessage usrMsg)
|
||||
public Task<bool> ExecOnMessageAsync(IGuild guild, IUserMessage usrMsg)
|
||||
{
|
||||
foreach (var bl in blacklist)
|
||||
{
|
||||
|
@@ -4,7 +4,7 @@ using NadekoBot.Services.Database.Models;
|
||||
|
||||
namespace NadekoBot.Modules.Permissions.Services;
|
||||
|
||||
public class CmdCdService : ILateBlocker, INService
|
||||
public class CmdCdService : IExecPreCommand, INService
|
||||
{
|
||||
public ConcurrentDictionary<ulong, ConcurrentHashSet<CommandCooldown>> CommandCooldowns { get; }
|
||||
public ConcurrentDictionary<ulong, ConcurrentHashSet<ActiveCooldown>> ActiveCooldowns { get; } = new();
|
||||
@@ -51,7 +51,7 @@ public class CmdCdService : ILateBlocker, INService
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
|
||||
public Task<bool> TryBlockLate(ICommandContext ctx, string moduleName, CommandInfo command)
|
||||
public Task<bool> ExecPreCommandAsync(ICommandContext ctx, string moduleName, CommandInfo command)
|
||||
{
|
||||
var guild = ctx.Guild;
|
||||
var user = ctx.User;
|
||||
|
@@ -6,7 +6,7 @@ using NadekoBot.Services.Database.Models;
|
||||
|
||||
namespace NadekoBot.Modules.Permissions.Services;
|
||||
|
||||
public sealed class FilterService : IEarlyBehavior
|
||||
public sealed class FilterService : IExecOnMessage
|
||||
{
|
||||
public ConcurrentHashSet<ulong> InviteFilteringChannels { get; }
|
||||
public ConcurrentHashSet<ulong> InviteFilteringServers { get; }
|
||||
@@ -69,7 +69,7 @@ public sealed class FilterService : IEarlyBehavior
|
||||
if (guild is null || newMsg is not IUserMessage usrMsg)
|
||||
return Task.CompletedTask;
|
||||
|
||||
return RunBehavior(guild, usrMsg);
|
||||
return ExecOnMessageAsync(guild, usrMsg);
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
@@ -110,7 +110,7 @@ public sealed class FilterService : IEarlyBehavior
|
||||
return words;
|
||||
}
|
||||
|
||||
public async Task<bool> RunBehavior(IGuild guild, IUserMessage msg)
|
||||
public async Task<bool> ExecOnMessageAsync(IGuild guild, IUserMessage msg)
|
||||
{
|
||||
if (msg.Author is not IGuildUser gu || gu.GuildPermissions.Administrator)
|
||||
return false;
|
||||
|
@@ -3,7 +3,7 @@ using NadekoBot.Common.ModuleBehaviors;
|
||||
|
||||
namespace NadekoBot.Modules.Permissions.Services;
|
||||
|
||||
public class GlobalPermissionService : ILateBlocker, INService
|
||||
public class GlobalPermissionService : IExecPreCommand, INService
|
||||
{
|
||||
public int Priority { get; } = 0;
|
||||
|
||||
@@ -19,7 +19,7 @@ public class GlobalPermissionService : ILateBlocker, INService
|
||||
=> _bss = bss;
|
||||
|
||||
|
||||
public Task<bool> TryBlockLate(ICommandContext ctx, string moduleName, CommandInfo command)
|
||||
public Task<bool> ExecPreCommandAsync(ICommandContext ctx, string moduleName, CommandInfo command)
|
||||
{
|
||||
var settings = _bss.Data;
|
||||
var commandName = command.Name.ToLowerInvariant();
|
||||
|
@@ -7,7 +7,7 @@ using NadekoBot.Services.Database.Models;
|
||||
|
||||
namespace NadekoBot.Modules.Permissions.Services;
|
||||
|
||||
public class PermissionService : ILateBlocker, INService
|
||||
public class PermissionService : IExecPreCommand, INService
|
||||
{
|
||||
public int Priority { get; } = 0;
|
||||
|
||||
@@ -94,7 +94,7 @@ public class PermissionService : ILateBlocker, INService
|
||||
return old;
|
||||
});
|
||||
|
||||
public async Task<bool> TryBlockLate(ICommandContext ctx, string moduleName, CommandInfo command)
|
||||
public async Task<bool> ExecPreCommandAsync(ICommandContext ctx, string moduleName, CommandInfo command)
|
||||
{
|
||||
var guild = ctx.Guild;
|
||||
var msg = ctx.Message;
|
||||
|
Reference in New Issue
Block a user