mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-04-30 03:22:04 -04:00
Support for commands without a prefix using new attribute NoPrefixRequired
This commit is contained in:
@@ -47,14 +47,11 @@ internal class BotCommands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!message.MessageRaw.StartsWith(CommandPrefix))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var messageTrimmed = message.MessageRaw.TrimStart(CommandPrefix);
|
||||
foreach (var command in Commands)
|
||||
{
|
||||
var noPrefixCommand = HasAttribute<NoPrefixRequired>(command);
|
||||
if (!noPrefixCommand && !message.MessageRaw.StartsWith(CommandPrefix)) return;
|
||||
foreach (var regex in command.Patterns)
|
||||
{
|
||||
var match = regex.Match(messageTrimmed);
|
||||
@@ -252,4 +249,10 @@ internal class WagerCommand : Attribute;
|
||||
/// It'll also check whether the user is permanently banned before running the command.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
internal class KasinoCommand : Attribute;
|
||||
internal class KasinoCommand : Attribute;
|
||||
|
||||
/// <summary>
|
||||
/// Use this on commands where the Regex should be tested even if there's no command prefix
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
internal class NoPrefixRequired : Attribute;
|
||||
Reference in New Issue
Block a user