1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 13:22:55 +08:00

Merge pull request #26379 from wooster0/chat

Make chat command names case-insensitive
This commit is contained in:
Dean Herbert 2024-01-04 16:17:42 +09:00 committed by GitHub
commit 0f11743fff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -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)

View File

@ -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));