mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Fixed "raw mentions" not being clickable with special characters appended to them (#2212)
This commit is contained in:
parent
98035c5c83
commit
b79d5fa6f0
|
@ -2,6 +2,7 @@
|
|||
|
||||
## Unversioned
|
||||
|
||||
- Minor: Made `Try to find usernames without @ prefix` option still resolve usernames when special characters (commas, dots, (semi)colons, exclamation mark, question mark) are appended to them. (#2212)
|
||||
- Minor: Made usercard update user's display name (#2160)
|
||||
- Minor: Added placeholder text for message text input box. (#2143, #2149)
|
||||
- Minor: Added support for FrankerFaceZ badges. (#2101, part of #1658)
|
||||
|
|
|
@ -29,8 +29,13 @@
|
|||
|
||||
namespace {
|
||||
|
||||
const QString regexHelpString("(\\w+)[.,!?;:]*?$");
|
||||
|
||||
// matches a mention with punctuation at the end, like "@username," or "@username!!!" where capture group would return "username"
|
||||
const QRegularExpression mentionRegex("^@(\\w+)[.,!?;]*?$");
|
||||
const QRegularExpression mentionRegex("^@" + regexHelpString);
|
||||
|
||||
// if findAllUsernames setting is enabled, matches strings like in the examples above, but without @ symbol at the beginning
|
||||
const QRegularExpression allUsernamesMentionRegex("^" + regexHelpString);
|
||||
|
||||
const QSet<QString> zeroWidthEmotes{
|
||||
"SoSnowy", "IceCold", "SantaHat", "TopHat",
|
||||
|
@ -474,6 +479,7 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_)
|
|||
if (match.hasMatch())
|
||||
{
|
||||
QString username = match.captured(1);
|
||||
|
||||
this->emplace<TextElement>(string, MessageElementFlag::BoldUsername,
|
||||
textColor, FontStyle::ChatMediumBold)
|
||||
->setLink({Link::UserInfo, username});
|
||||
|
@ -488,15 +494,18 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_)
|
|||
if (this->twitchChannel != nullptr && getSettings()->findAllUsernames)
|
||||
{
|
||||
auto chatters = this->twitchChannel->accessChatters();
|
||||
if (chatters->contains(string))
|
||||
auto match = allUsernamesMentionRegex.match(string);
|
||||
QString username = match.captured(1);
|
||||
|
||||
if (match.hasMatch() && chatters->contains(username))
|
||||
{
|
||||
this->emplace<TextElement>(string, MessageElementFlag::BoldUsername,
|
||||
textColor, FontStyle::ChatMediumBold)
|
||||
->setLink({Link::UserInfo, string});
|
||||
->setLink({Link::UserInfo, username});
|
||||
|
||||
this->emplace<TextElement>(
|
||||
string, MessageElementFlag::NonBoldUsername, textColor)
|
||||
->setLink({Link::UserInfo, string});
|
||||
->setLink({Link::UserInfo, username});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue