mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Restructured folders and project names, ci should be fixed
This commit is contained in:
23
src/NadekoBot/Common/ModuleBehaviors/IEarlyBlocker.cs
Normal file
23
src/NadekoBot/Common/ModuleBehaviors/IEarlyBlocker.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace NadekoBot.Common.ModuleBehaviors
|
||||
{
|
||||
/// <summary>
|
||||
/// Implemented by modules which block execution before anything is executed
|
||||
/// </summary>
|
||||
public interface IEarlyBehavior
|
||||
{
|
||||
int Priority { get; }
|
||||
ModuleBehaviorType BehaviorType { get; }
|
||||
|
||||
Task<bool> RunBehavior(DiscordSocketClient client, IGuild guild, IUserMessage msg);
|
||||
}
|
||||
|
||||
public enum ModuleBehaviorType
|
||||
{
|
||||
Blocker,
|
||||
Executor,
|
||||
}
|
||||
}
|
10
src/NadekoBot/Common/ModuleBehaviors/IINputTransformer.cs
Normal file
10
src/NadekoBot/Common/ModuleBehaviors/IINputTransformer.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot.Common.ModuleBehaviors
|
||||
{
|
||||
public interface IInputTransformer
|
||||
{
|
||||
Task<string> TransformInput(IGuild guild, IMessageChannel channel, IUser user, string input);
|
||||
}
|
||||
}
|
14
src/NadekoBot/Common/ModuleBehaviors/ILateBlocker.cs
Normal file
14
src/NadekoBot/Common/ModuleBehaviors/ILateBlocker.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace NadekoBot.Common.ModuleBehaviors
|
||||
{
|
||||
public interface ILateBlocker
|
||||
{
|
||||
public int Priority { get; }
|
||||
|
||||
Task<bool> TryBlockLate(DiscordSocketClient client, ICommandContext context,
|
||||
string moduleName, CommandInfo command);
|
||||
}
|
||||
}
|
14
src/NadekoBot/Common/ModuleBehaviors/ILateExecutor.cs
Normal file
14
src/NadekoBot/Common/ModuleBehaviors/ILateExecutor.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace NadekoBot.Common.ModuleBehaviors
|
||||
{
|
||||
/// <summary>
|
||||
/// Last thing to be executed, won't stop further executions
|
||||
/// </summary>
|
||||
public interface ILateExecutor
|
||||
{
|
||||
Task LateExecute(DiscordSocketClient client, IGuild guild, IUserMessage msg);
|
||||
}
|
||||
}
|
34
src/NadekoBot/Common/ModuleBehaviors/IModuleBehavior.cs
Normal file
34
src/NadekoBot/Common/ModuleBehaviors/IModuleBehavior.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Common.ModuleBehaviors
|
||||
{
|
||||
public struct ModuleBehaviorResult
|
||||
{
|
||||
public bool Blocked { get; set; }
|
||||
public string NewInput { get; set; }
|
||||
|
||||
public static ModuleBehaviorResult None() => new ModuleBehaviorResult
|
||||
{
|
||||
Blocked = false,
|
||||
NewInput = null,
|
||||
};
|
||||
|
||||
public static ModuleBehaviorResult FromBlocked(bool blocked) => new ModuleBehaviorResult
|
||||
{
|
||||
Blocked = blocked,
|
||||
NewInput = null,
|
||||
};
|
||||
}
|
||||
|
||||
public interface IModuleBehavior
|
||||
{
|
||||
/// <summary>
|
||||
/// Negative priority means it will try to apply as early as possible
|
||||
/// Positive priority menas it will try to apply as late as possible
|
||||
/// </summary>
|
||||
int Priority { get; }
|
||||
Task<ModuleBehaviorResult> ApplyBehavior(DiscordSocketClient client, IGuild guild, IUserMessage msg);
|
||||
}
|
||||
}
|
16
src/NadekoBot/Common/ModuleBehaviors/IReadyExecutor.cs
Normal file
16
src/NadekoBot/Common/ModuleBehaviors/IReadyExecutor.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Common.ModuleBehaviors
|
||||
{
|
||||
/// <summary>
|
||||
/// All services which need to execute something after
|
||||
/// the bot is ready should implement this interface
|
||||
/// </summary>
|
||||
public interface IReadyExecutor
|
||||
{
|
||||
/// <summary>
|
||||
/// Executed when bot is ready
|
||||
/// </summary>
|
||||
public Task OnReadyAsync();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user