mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Merge pull request #24190 from novialriptide/emoji-fix
Replace emoji unicode with `[emoji]`
This commit is contained in:
commit
cef0dd1d61
@ -478,8 +478,8 @@ namespace osu.Game.Tests.Chat
|
||||
Content = "This is a [http://www.simple-test.com simple test] with some [traps] and [[wiki links]]. Don't forget to visit https://osu.ppy.sh (now!)[http://google.com]\uD83D\uDE12"
|
||||
});
|
||||
|
||||
Assert.AreEqual("This is a simple test with some [traps] and wiki links. Don't forget to visit https://osu.ppy.sh now!\0\0\0", result.DisplayContent);
|
||||
Assert.AreEqual(5, result.Links.Count);
|
||||
Assert.AreEqual("This is a simple test with some [traps] and wiki links. Don't forget to visit https://osu.ppy.sh now![emoji]", result.DisplayContent);
|
||||
Assert.AreEqual(4, result.Links.Count);
|
||||
|
||||
Link f = result.Links.Find(l => l.Url == "https://dev.ppy.sh/wiki/wiki links");
|
||||
Assert.That(f, Is.Not.Null);
|
||||
@ -500,27 +500,22 @@ namespace osu.Game.Tests.Chat
|
||||
Assert.That(f, Is.Not.Null);
|
||||
Assert.AreEqual(78, f.Index);
|
||||
Assert.AreEqual(18, f.Length);
|
||||
|
||||
f = result.Links.Find(l => l.Url == "\uD83D\uDE12");
|
||||
Assert.That(f, Is.Not.Null);
|
||||
Assert.AreEqual(101, f.Index);
|
||||
Assert.AreEqual(3, f.Length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEmoji()
|
||||
{
|
||||
Message result = MessageFormatter.FormatMessage(new Message { Content = "Hello world\uD83D\uDE12<--This is an emoji,There are more:\uD83D\uDE10\uD83D\uDE00,\uD83D\uDE20" });
|
||||
Assert.AreEqual("Hello world\0\0\0<--This is an emoji,There are more:\0\0\0\0\0\0,\0\0\0", result.DisplayContent);
|
||||
Assert.AreEqual(result.Links.Count, 4);
|
||||
Assert.AreEqual(result.Links[0].Index, 11);
|
||||
Assert.AreEqual(result.Links[1].Index, 49);
|
||||
Assert.AreEqual(result.Links[2].Index, 52);
|
||||
Assert.AreEqual(result.Links[3].Index, 56);
|
||||
Assert.AreEqual(result.Links[0].Url, "\uD83D\uDE12");
|
||||
Assert.AreEqual(result.Links[1].Url, "\uD83D\uDE10");
|
||||
Assert.AreEqual(result.Links[2].Url, "\uD83D\uDE00");
|
||||
Assert.AreEqual(result.Links[3].Url, "\uD83D\uDE20");
|
||||
Message result = MessageFormatter.FormatMessage(new Message { Content = "Hello world\uD83D\uDE12<--This is an emoji,There are more emojis among us:\uD83D\uDE10\uD83D\uDE00,\uD83D\uDE20" });
|
||||
Assert.AreEqual("Hello world[emoji]<--This is an emoji,There are more emojis among us:[emoji][emoji],[emoji]", result.DisplayContent);
|
||||
Assert.AreEqual(result.Links.Count, 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEmojiWithSuccessiveParens()
|
||||
{
|
||||
Message result = MessageFormatter.FormatMessage(new Message { Content = "\uD83D\uDE10(let's hope this doesn't accidentally turn into a link)" });
|
||||
Assert.AreEqual("[emoji](let's hope this doesn't accidentally turn into a link)", result.DisplayContent);
|
||||
Assert.AreEqual(result.Links.Count, 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -89,6 +89,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
addMessageWithChecks($"Join my {OsuGameBase.OSU_PROTOCOL}chan/#english.", 1, expectedActions: LinkAction.OpenChannel);
|
||||
addMessageWithChecks("Join my #english or #japanese channels.", 2, expectedActions: new[] { LinkAction.OpenChannel, LinkAction.OpenChannel });
|
||||
addMessageWithChecks("Join my #english or #nonexistent #hashtag channels.", 1, expectedActions: LinkAction.OpenChannel);
|
||||
addMessageWithChecks("Hello world\uD83D\uDE12(<--This is an emoji). There are more:\uD83D\uDE10\uD83D\uDE00,\uD83D\uDE20");
|
||||
|
||||
void addMessageWithChecks(string text, int linkAmount = 0, bool isAction = false, bool isImportant = false, params LinkAction[] expectedActions)
|
||||
{
|
||||
|
@ -279,11 +279,8 @@ namespace osu.Game.Online.Chat
|
||||
// handle channels
|
||||
handleMatches(channel_regex, "{0}", $@"{OsuGameBase.OSU_PROTOCOL}chan/{{0}}", result, startIndex, LinkAction.OpenChannel);
|
||||
|
||||
string empty = "";
|
||||
while (space-- > 0)
|
||||
empty += "\0";
|
||||
|
||||
handleMatches(emoji_regex, empty, "{0}", result, startIndex);
|
||||
// see: https://github.com/ppy/osu/pull/24190
|
||||
result.Text = Regex.Replace(result.Text, emoji_regex.ToString(), "[emoji]");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user