mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Fix tabbing some emotes (i.e. R-)
)
This commit is contained in:
parent
8f00d1aece
commit
7703087fb4
1 changed files with 23 additions and 2 deletions
|
@ -21,6 +21,26 @@ QString getEmoteLink(const QString &id, const QString &emoteScale)
|
|||
return value.replace("{id}", id).replace("{scale}", emoteScale);
|
||||
}
|
||||
|
||||
QString cleanUpCode(const QString &dirtyEmoteCode)
|
||||
{
|
||||
// clang-format off
|
||||
static QMap<QString, QString> emoteNameReplacements{
|
||||
{"[oO](_|\\.)[oO]", "O_o"}, {"\\>\\;\\(", ">("}, {"\\<\\;3", "<3"},
|
||||
{"\\:-?(o|O)", ":O"}, {"\\:-?(p|P)", ":P"}, {"\\:-?[\\\\/]", ":/"},
|
||||
{"\\:-?[z|Z|\\|]", ":Z"}, {"\\:-?\\(", ":("}, {"\\:-?\\)", ":)"},
|
||||
{"\\:-?D", ":D"}, {"\\;-?(p|P)", ";P"}, {"\\;-?\\)", ";)"},
|
||||
{"R-?\\)", "R)"}, {"B-?\\)", "B)"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
auto it = emoteNameReplacements.find(dirtyEmoteCode);
|
||||
if (it != emoteNameReplacements.end()) {
|
||||
return it.value();
|
||||
}
|
||||
|
||||
return dirtyEmoteCode;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// id is used for lookup
|
||||
|
@ -95,8 +115,9 @@ void TwitchEmotes::refresh(const std::shared_ptr<TwitchAccount> &user)
|
|||
QJsonObject emoticon = emoteValue.toObject();
|
||||
QString id = QString::number(emoticon["id"].toInt());
|
||||
QString code = emoticon["code"].toString();
|
||||
emoteSet.emotes.emplace_back(id, code);
|
||||
emoteData.emoteCodes.push_back(code);
|
||||
auto cleanCode = cleanUpCode(code);
|
||||
emoteSet.emotes.emplace_back(id, cleanCode);
|
||||
emoteData.emoteCodes.push_back(cleanCode);
|
||||
|
||||
util::EmoteData emote = this->getEmoteById(id, code);
|
||||
emoteData.emotes.insert(code, emote);
|
||||
|
|
Loading…
Reference in a new issue