mirror of
https://github.com/ppy/osu
synced 2024-12-29 10:22:43 +00:00
Make chat commands case-insensitive
Would be nice if I accidentally have caps lock enabled and write "/HELP" it still works.
This commit is contained in:
parent
8b8f7953ec
commit
cf5f0a2bdc
@ -112,7 +112,7 @@ namespace osu.Game.Tests.Chat
|
||||
});
|
||||
|
||||
AddStep("post message", () => channelManager.PostMessage("Something interesting"));
|
||||
AddUntilStep("message postesd", () => !channel.Messages.Any(m => m is LocalMessage));
|
||||
AddUntilStep("message posted", () => !channel.Messages.Any(m => m is LocalMessage));
|
||||
|
||||
AddStep("post /help command", () => channelManager.PostCommand("help", channel));
|
||||
AddStep("post /me command with no action", () => channelManager.PostCommand("me", channel));
|
||||
@ -146,6 +146,23 @@ namespace osu.Game.Tests.Chat
|
||||
AddAssert("channel has no more messages", () => channel.Messages, () => Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCommandNameCaseInsensitivity()
|
||||
{
|
||||
Channel channel = null;
|
||||
|
||||
AddStep("join channel and select it", () =>
|
||||
{
|
||||
channelManager.JoinChannel(channel = createChannel(1, ChannelType.Public));
|
||||
channelManager.CurrentChannel.Value = channel;
|
||||
});
|
||||
|
||||
AddStep("post /me command", () => channelManager.PostCommand("ME DANCES"));
|
||||
AddUntilStep("/me command received", () => channel.Messages.Last().Content.Contains("DANCES"));
|
||||
AddStep("post /help command", () => channelManager.PostCommand("HeLp"));
|
||||
AddUntilStep("/help command received", () => channel.Messages.Last().Content.Contains("Supported commands"));
|
||||
}
|
||||
|
||||
private void handlePostMessageRequest(PostMessageRequest request)
|
||||
{
|
||||
var message = new Message(++currentMessageId)
|
||||
|
@ -247,7 +247,7 @@ namespace osu.Game.Online.Chat
|
||||
string command = parameters[0];
|
||||
string content = parameters.Length == 2 ? parameters[1] : string.Empty;
|
||||
|
||||
switch (command)
|
||||
switch (command.ToLowerInvariant())
|
||||
{
|
||||
case "np":
|
||||
AddInternal(new NowPlayingCommand(target));
|
||||
|
Loading…
Reference in New Issue
Block a user