Auto-fixer for multiple spaces in commands

This commit is contained in:
xeon 2024-02-21 00:32:17 +03:00
parent a7c4217068
commit e70c6aa946

View file

@ -1,4 +1,5 @@
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using GameServer.Controllers.Attributes; using GameServer.Controllers.Attributes;
using GameServer.Controllers.ChatCommands; using GameServer.Controllers.ChatCommands;
using GameServer.Models; using GameServer.Models;
@ -8,7 +9,7 @@ using GameServer.Network.Messages;
using Protocol; using Protocol;
namespace GameServer.Controllers; namespace GameServer.Controllers;
internal class ChatController : Controller internal partial class ChatController : Controller
{ {
private readonly ModelManager _modelManager; private readonly ModelManager _modelManager;
@ -42,7 +43,8 @@ internal class ChatController : Controller
} }
else else
{ {
string[] split = request.Content[1..].Split(' '); string content = MultipleSpacesRegex().Replace(request.Content, " ");
string[] split = content[1..].Split(' ');
if (split.Length >= 2) if (split.Length >= 2)
{ {
await chatCommandManager.InvokeCommandAsync(split[0], split[1], split[2..]); await chatCommandManager.InvokeCommandAsync(split[0], split[1], split[2..]);
@ -85,4 +87,7 @@ internal class ChatController : Controller
return builder.ToString(); return builder.ToString();
} }
[GeneratedRegex(@"\s+")]
private static partial Regex MultipleSpacesRegex();
} }