changed to 80 max column
This commit is contained in:
@@ -20,9 +20,9 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
|
||||
const Communi::IrcPrivateMessage *_ircMessage,
|
||||
const MessageParseArgs &_args)
|
||||
TwitchMessageBuilder::TwitchMessageBuilder(
|
||||
Channel *_channel, const Communi::IrcPrivateMessage *_ircMessage,
|
||||
const MessageParseArgs &_args)
|
||||
: channel(_channel)
|
||||
, twitchChannel(dynamic_cast<TwitchChannel *>(_channel))
|
||||
, ircMessage(_ircMessage)
|
||||
@@ -35,10 +35,9 @@ TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
|
||||
this->usernameColor_ = app->themes->messages.textColors.system;
|
||||
}
|
||||
|
||||
TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
|
||||
const Communi::IrcMessage *_ircMessage,
|
||||
const MessageParseArgs &_args, QString content,
|
||||
bool isAction)
|
||||
TwitchMessageBuilder::TwitchMessageBuilder(
|
||||
Channel *_channel, const Communi::IrcMessage *_ircMessage,
|
||||
const MessageParseArgs &_args, QString content, bool isAction)
|
||||
: channel(_channel)
|
||||
, twitchChannel(dynamic_cast<TwitchChannel *>(_channel))
|
||||
, ircMessage(_ircMessage)
|
||||
@@ -58,17 +57,21 @@ bool TwitchMessageBuilder::isIgnored() const
|
||||
// TODO(pajlada): Do we need to check if the phrase is valid first?
|
||||
for (const auto &phrase : app->ignores->phrases.getVector()) {
|
||||
if (phrase.isMatch(this->originalMessage_)) {
|
||||
Log("Blocking message because it contains ignored phrase {}", phrase.getPattern());
|
||||
Log("Blocking message because it contains ignored phrase {}",
|
||||
phrase.getPattern());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (app->settings->enableTwitchIgnoredUsers && this->tags.contains("user-id")) {
|
||||
if (app->settings->enableTwitchIgnoredUsers &&
|
||||
this->tags.contains("user-id")) {
|
||||
auto sourceUserID = this->tags.value("user-id").toString();
|
||||
|
||||
for (const auto &user : app->accounts->twitch.getCurrent()->getIgnores()) {
|
||||
for (const auto &user :
|
||||
app->accounts->twitch.getCurrent()->getIgnores()) {
|
||||
if (sourceUserID == user.id) {
|
||||
Log("Blocking message because it's from blocked user {}", user.name);
|
||||
Log("Blocking message because it's from blocked user {}",
|
||||
user.name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -162,8 +165,9 @@ MessagePtr TwitchMessageBuilder::build()
|
||||
this->appendTwitchEmote(ircMessage, emote, twitchEmotes);
|
||||
}
|
||||
|
||||
std::sort(twitchEmotes.begin(), twitchEmotes.end(),
|
||||
[](const auto &a, const auto &b) { return a.first < b.first; });
|
||||
std::sort(
|
||||
twitchEmotes.begin(), twitchEmotes.end(),
|
||||
[](const auto &a, const auto &b) { return a.first < b.first; });
|
||||
}
|
||||
|
||||
// words
|
||||
@@ -176,17 +180,20 @@ MessagePtr TwitchMessageBuilder::build()
|
||||
return this->getMessage();
|
||||
}
|
||||
|
||||
void TwitchMessageBuilder::addWords(const QStringList &words,
|
||||
const std::vector<std::pair<int, EmotePtr>> &twitchEmotes)
|
||||
void TwitchMessageBuilder::addWords(
|
||||
const QStringList &words,
|
||||
const std::vector<std::pair<int, EmotePtr>> &twitchEmotes)
|
||||
{
|
||||
auto i = int();
|
||||
auto currentTwitchEmote = twitchEmotes.begin();
|
||||
|
||||
for (const auto &word : words) {
|
||||
// check if it's a twitch emote twitch emote
|
||||
if (currentTwitchEmote != twitchEmotes.end() && currentTwitchEmote->first == i) {
|
||||
if (currentTwitchEmote != twitchEmotes.end() &&
|
||||
currentTwitchEmote->first == i) {
|
||||
auto emoteImage = currentTwitchEmote->second;
|
||||
this->emplace<EmoteElement>(emoteImage, MessageElement::TwitchEmote);
|
||||
this->emplace<EmoteElement>(emoteImage,
|
||||
MessageElement::TwitchEmote);
|
||||
|
||||
i += word.length() + 1;
|
||||
currentTwitchEmote++;
|
||||
@@ -196,9 +203,12 @@ void TwitchMessageBuilder::addWords(const QStringList &words,
|
||||
|
||||
// split words
|
||||
for (auto &variant : getApp()->emotes->emojis.parse(word)) {
|
||||
boost::apply_visitor(/*overloaded{[&](EmotePtr arg) { this->addTextOrEmoji(arg); },
|
||||
[&](const QString &arg) { this->addTextOrEmoji(arg); }}*/
|
||||
[&](auto &&arg) { this->addTextOrEmoji(arg); }, variant);
|
||||
boost::apply_visitor(/*overloaded{[&](EmotePtr arg) {
|
||||
this->addTextOrEmoji(arg); },
|
||||
[&](const QString &arg) {
|
||||
this->addTextOrEmoji(arg); }}*/
|
||||
[&](auto &&arg) { this->addTextOrEmoji(arg); },
|
||||
variant);
|
||||
}
|
||||
|
||||
for (int j = 0; j < word.size(); j++) {
|
||||
@@ -240,14 +250,15 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_)
|
||||
// Actually just text
|
||||
auto linkString = this->matchLink(string);
|
||||
auto link = Link();
|
||||
auto textColor =
|
||||
this->action_ ? MessageColor(this->usernameColor_) : MessageColor(MessageColor::Text);
|
||||
auto textColor = this->action_ ? MessageColor(this->usernameColor_)
|
||||
: MessageColor(MessageColor::Text);
|
||||
|
||||
if (linkString.isEmpty()) {
|
||||
if (string.startsWith('@')) {
|
||||
this->emplace<TextElement>(string, TextElement::BoldUsername, textColor,
|
||||
FontStyle::ChatMediumBold);
|
||||
this->emplace<TextElement>(string, TextElement::NonBoldUsername, textColor);
|
||||
this->emplace<TextElement>(string, TextElement::BoldUsername,
|
||||
textColor, FontStyle::ChatMediumBold);
|
||||
this->emplace<TextElement>(string, TextElement::NonBoldUsername,
|
||||
textColor);
|
||||
} else {
|
||||
this->emplace<TextElement>(string, TextElement::Text, textColor);
|
||||
}
|
||||
@@ -260,22 +271,26 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_)
|
||||
auto match = domainRegex.match(string);
|
||||
if (match.isValid()) {
|
||||
lowercaseLinkString = string.mid(0, match.capturedStart(1)) +
|
||||
match.captured(1).toLower() + string.mid(match.capturedEnd(1));
|
||||
match.captured(1).toLower() +
|
||||
string.mid(match.capturedEnd(1));
|
||||
} else {
|
||||
lowercaseLinkString = string;
|
||||
}
|
||||
link = Link(Link::Url, linkString);
|
||||
|
||||
textColor = MessageColor(MessageColor::Link);
|
||||
this->emplace<TextElement>(lowercaseLinkString, TextElement::LowercaseLink, textColor)
|
||||
this->emplace<TextElement>(lowercaseLinkString,
|
||||
TextElement::LowercaseLink, textColor)
|
||||
->setLink(link);
|
||||
this->emplace<TextElement>(string, TextElement::OriginalLink, textColor)
|
||||
->setLink(link);
|
||||
this->emplace<TextElement>(string, TextElement::OriginalLink, textColor)->setLink(link);
|
||||
}
|
||||
|
||||
// if (!linkString.isEmpty()) {
|
||||
// if (getApp()->settings->lowercaseLink) {
|
||||
// QRegularExpression httpRegex("\\bhttps?://",
|
||||
// QRegularExpression::CaseInsensitiveOption); QRegularExpression ftpRegex("\\bftps?://",
|
||||
// QRegularExpression::CaseInsensitiveOption); QRegularExpression
|
||||
// ftpRegex("\\bftps?://",
|
||||
// QRegularExpression::CaseInsensitiveOption); QRegularExpression
|
||||
// getDomain("\\/\\/([^\\/]*)"); QString tempString = string;
|
||||
|
||||
@@ -291,7 +306,8 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_)
|
||||
// textColor = MessageColor(MessageColor::Link);
|
||||
//}
|
||||
// if (string.startsWith('@')) {
|
||||
// this->emplace<TextElement>(string, TextElement::BoldUsername, textColor,
|
||||
// this->emplace<TextElement>(string, TextElement::BoldUsername,
|
||||
// textColor,
|
||||
// FontStyle::ChatMediumBold) //
|
||||
// ->setLink(link);
|
||||
// this->emplace<TextElement>(string, TextElement::NonBoldUsername,
|
||||
@@ -334,7 +350,8 @@ void TwitchMessageBuilder::appendChannelName()
|
||||
QString channelName("#" + this->channel->getName());
|
||||
Link link(Link::Url, this->channel->getName() + "\n" + this->messageID);
|
||||
|
||||
this->emplace<TextElement>(channelName, MessageElement::ChannelName, MessageColor::System) //
|
||||
this->emplace<TextElement>(channelName, MessageElement::ChannelName,
|
||||
MessageColor::System) //
|
||||
->setLink(link);
|
||||
}
|
||||
|
||||
@@ -355,7 +372,8 @@ void TwitchMessageBuilder::parseUsername()
|
||||
// display name
|
||||
// auto displayNameVariant = this->tags.value("display-name");
|
||||
// if (displayNameVariant.isValid()) {
|
||||
// this->userName = displayNameVariant.toString() + " (" + this->userName + ")";
|
||||
// this->userName = displayNameVariant.toString() + " (" +
|
||||
// this->userName + ")";
|
||||
// }
|
||||
|
||||
this->message_->loginName = this->userName;
|
||||
@@ -371,9 +389,11 @@ void TwitchMessageBuilder::appendUsername()
|
||||
|
||||
auto iterator = this->tags.find("display-name");
|
||||
if (iterator != this->tags.end()) {
|
||||
QString displayName = parseTagString(iterator.value().toString()).trimmed();
|
||||
QString displayName =
|
||||
parseTagString(iterator.value().toString()).trimmed();
|
||||
|
||||
if (QString::compare(displayName, this->userName, Qt::CaseInsensitive) == 0) {
|
||||
if (QString::compare(displayName, this->userName,
|
||||
Qt::CaseInsensitive) == 0) {
|
||||
username = displayName;
|
||||
|
||||
this->message_->displayName = displayName;
|
||||
@@ -391,7 +411,8 @@ void TwitchMessageBuilder::appendUsername()
|
||||
QString usernameText;
|
||||
|
||||
pajlada::Settings::Setting<int> usernameDisplayMode(
|
||||
"/appearance/messages/usernameDisplayMode", UsernameDisplayMode::UsernameAndLocalizedName);
|
||||
"/appearance/messages/usernameDisplayMode",
|
||||
UsernameDisplayMode::UsernameAndLocalizedName);
|
||||
|
||||
switch (usernameDisplayMode.getValue()) {
|
||||
case UsernameDisplayMode::Username: {
|
||||
@@ -418,10 +439,12 @@ void TwitchMessageBuilder::appendUsername()
|
||||
|
||||
if (this->args.isSentWhisper) {
|
||||
// TODO(pajlada): Re-implement
|
||||
// userDisplayString += IrcManager::getInstance().getUser().getUserName();
|
||||
// userDisplayString +=
|
||||
// IrcManager::getInstance().getUser().getUserName();
|
||||
} else if (this->args.isReceivedWhisper) {
|
||||
// Sender username
|
||||
this->emplace<TextElement>(usernameText, MessageElement::Text, this->usernameColor_,
|
||||
this->emplace<TextElement>(usernameText, MessageElement::Text,
|
||||
this->usernameColor_,
|
||||
FontStyle::ChatMediumBold)
|
||||
->setLink({Link::UserInfo, this->userName});
|
||||
|
||||
@@ -429,7 +452,8 @@ void TwitchMessageBuilder::appendUsername()
|
||||
|
||||
// Separator
|
||||
this->emplace<TextElement>("->", MessageElement::Text,
|
||||
app->themes->messages.textColors.system, FontStyle::ChatMedium);
|
||||
app->themes->messages.textColors.system,
|
||||
FontStyle::ChatMedium);
|
||||
|
||||
QColor selfColor = currentUser->color;
|
||||
if (!selfColor.isValid()) {
|
||||
@@ -437,14 +461,16 @@ void TwitchMessageBuilder::appendUsername()
|
||||
}
|
||||
|
||||
// Your own username
|
||||
this->emplace<TextElement>(currentUser->getUserName() + ":", MessageElement::Text,
|
||||
selfColor, FontStyle::ChatMediumBold);
|
||||
this->emplace<TextElement>(currentUser->getUserName() + ":",
|
||||
MessageElement::Text, selfColor,
|
||||
FontStyle::ChatMediumBold);
|
||||
} else {
|
||||
if (!this->action_) {
|
||||
usernameText += ":";
|
||||
}
|
||||
|
||||
this->emplace<TextElement>(usernameText, MessageElement::Text, this->usernameColor_,
|
||||
this->emplace<TextElement>(usernameText, MessageElement::Text,
|
||||
this->usernameColor_,
|
||||
FontStyle::ChatMediumBold)
|
||||
->setLink({Link::UserInfo, this->userName});
|
||||
}
|
||||
@@ -470,7 +496,8 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
|
||||
// update the media player url if necessary
|
||||
QUrl highlightSoundUrl;
|
||||
if (app->settings->customHighlightSound) {
|
||||
highlightSoundUrl = QUrl::fromLocalFile(app->settings->pathHighlightSound.getValue());
|
||||
highlightSoundUrl =
|
||||
QUrl::fromLocalFile(app->settings->pathHighlightSound.getValue());
|
||||
} else {
|
||||
highlightSoundUrl = QUrl("qrc:/sounds/ping2.wav");
|
||||
}
|
||||
@@ -483,12 +510,15 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
|
||||
|
||||
// TODO: This vector should only be rebuilt upon highlights being changed
|
||||
// fourtf: should be implemented in the HighlightsController
|
||||
std::vector<HighlightPhrase> activeHighlights = app->highlights->phrases.getVector();
|
||||
std::vector<HighlightPhrase> userHighlights = app->highlights->highlightedUsers.getVector();
|
||||
std::vector<HighlightPhrase> activeHighlights =
|
||||
app->highlights->phrases.getVector();
|
||||
std::vector<HighlightPhrase> userHighlights =
|
||||
app->highlights->highlightedUsers.getVector();
|
||||
|
||||
if (app->settings->enableHighlightsSelf && currentUsername.size() > 0) {
|
||||
HighlightPhrase selfHighlight(currentUsername, app->settings->enableHighlightTaskbar,
|
||||
app->settings->enableHighlightSound, false);
|
||||
HighlightPhrase selfHighlight(
|
||||
currentUsername, app->settings->enableHighlightTaskbar,
|
||||
app->settings->enableHighlightSound, false);
|
||||
activeHighlights.emplace_back(std::move(selfHighlight));
|
||||
}
|
||||
|
||||
@@ -514,15 +544,17 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
|
||||
}
|
||||
|
||||
if (playSound && doAlert) {
|
||||
// Break if no further action can be taken from other highlights
|
||||
// This might change if highlights can have custom colors/sounds/actions
|
||||
// Break if no further action can be taken from other
|
||||
// highlights This might change if highlights can have
|
||||
// custom colors/sounds/actions
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const HighlightPhrase &userHighlight : userHighlights) {
|
||||
if (userHighlight.isMatch(this->ircMessage->nick())) {
|
||||
Log("Highlight because user {} sent a message", this->ircMessage->nick());
|
||||
Log("Highlight because user {} sent a message",
|
||||
this->ircMessage->nick());
|
||||
doHighlight = true;
|
||||
|
||||
if (userHighlight.getAlert()) {
|
||||
@@ -534,8 +566,8 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
|
||||
}
|
||||
|
||||
if (playSound && doAlert) {
|
||||
// Break if no further action can be taken from other usernames
|
||||
// Mostly used for regex stuff
|
||||
// Break if no further action can be taken from other
|
||||
// usernames Mostly used for regex stuff
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -544,12 +576,14 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
|
||||
this->setHighlight(doHighlight);
|
||||
|
||||
if (!isPastMsg) {
|
||||
if (playSound && (!hasFocus || app->settings->highlightAlwaysPlaySound)) {
|
||||
if (playSound &&
|
||||
(!hasFocus || app->settings->highlightAlwaysPlaySound)) {
|
||||
player->play();
|
||||
}
|
||||
|
||||
if (doAlert) {
|
||||
QApplication::alert(getApp()->windows->getMainWindow().window(), 2500);
|
||||
QApplication::alert(getApp()->windows->getMainWindow().window(),
|
||||
2500);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -559,9 +593,9 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
|
||||
}
|
||||
}
|
||||
|
||||
void TwitchMessageBuilder::appendTwitchEmote(const Communi::IrcMessage *ircMessage,
|
||||
const QString &emote,
|
||||
std::vector<std::pair<int, EmotePtr>> &vec)
|
||||
void TwitchMessageBuilder::appendTwitchEmote(
|
||||
const Communi::IrcMessage *ircMessage, const QString &emote,
|
||||
std::vector<std::pair<int, EmotePtr>> &vec)
|
||||
{
|
||||
auto app = getApp();
|
||||
if (!emote.contains(':')) {
|
||||
@@ -588,13 +622,16 @@ void TwitchMessageBuilder::appendTwitchEmote(const Communi::IrcMessage *ircMessa
|
||||
auto start = coords.at(0).toInt();
|
||||
auto end = coords.at(1).toInt();
|
||||
|
||||
if (start >= end || start < 0 || end > this->originalMessage_.length()) {
|
||||
if (start >= end || start < 0 ||
|
||||
end > this->originalMessage_.length()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto name = EmoteName{this->originalMessage_.mid(start, end - start + 1)};
|
||||
auto name =
|
||||
EmoteName{this->originalMessage_.mid(start, end - start + 1)};
|
||||
|
||||
vec.push_back(std::make_pair(start, app->emotes->twitch.getOrCreateEmote(id, name)));
|
||||
vec.push_back(std::make_pair(
|
||||
start, app->emotes->twitch.getOrCreateEmote(id, name)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -605,11 +642,13 @@ Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name)
|
||||
|
||||
if ((emote = getApp()->emotes->bttv.getGlobalEmote(name))) {
|
||||
flags = MessageElement::BttvEmote;
|
||||
} else if (twitchChannel && (emote = this->twitchChannel->getBttvEmote(name))) {
|
||||
} else if (twitchChannel &&
|
||||
(emote = this->twitchChannel->getBttvEmote(name))) {
|
||||
flags = MessageElement::BttvEmote;
|
||||
} else if ((emote = getApp()->emotes->ffz.getGlobalEmote(name))) {
|
||||
flags = MessageElement::FfzEmote;
|
||||
} else if (twitchChannel && (emote = this->twitchChannel->getFfzEmote(name))) {
|
||||
} else if (twitchChannel &&
|
||||
(emote = this->twitchChannel->getFfzEmote(name))) {
|
||||
flags = MessageElement::FfzEmote;
|
||||
}
|
||||
|
||||
@@ -622,7 +661,8 @@ Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name)
|
||||
}
|
||||
|
||||
// fourtf: this is ugly
|
||||
// maybe put the individual badges into a map instead of this mess
|
||||
// maybe put the individual badges into a map instead of this
|
||||
//mess
|
||||
void TwitchMessageBuilder::appendTwitchBadges()
|
||||
{
|
||||
auto app = getApp();
|
||||
@@ -653,9 +693,10 @@ void TwitchMessageBuilder::appendTwitchBadges()
|
||||
// Try to fetch channel-specific bit badge
|
||||
try {
|
||||
if (twitchChannel)
|
||||
if (const auto &badge =
|
||||
this->twitchChannel->getTwitchBadge("bits", cheerAmount)) {
|
||||
this->emplace<EmoteElement>(badge.get(), MessageElement::BadgeVanity)
|
||||
if (const auto &badge = this->twitchChannel->getTwitchBadge(
|
||||
"bits", cheerAmount)) {
|
||||
this->emplace<EmoteElement>(badge.get(),
|
||||
MessageElement::BadgeVanity)
|
||||
->setTooltip(tooltip);
|
||||
continue;
|
||||
}
|
||||
@@ -665,62 +706,72 @@ void TwitchMessageBuilder::appendTwitchBadges()
|
||||
|
||||
// Use default bit badge
|
||||
// try {
|
||||
// const auto &badge = app->resources->badgeSets.at("bits").versions.at(cheerAmount);
|
||||
// this->emplace<ImageElement>(badge.badgeImage1x, MessageElement::BadgeVanity)
|
||||
// const auto &badge =
|
||||
// app->resources->badgeSets.at("bits").versions.at(cheerAmount);
|
||||
// this->emplace<ImageElement>(badge.badgeImage1x,
|
||||
// MessageElement::BadgeVanity)
|
||||
// ->setTooltip(tooltip);
|
||||
//} catch (const std::out_of_range &) {
|
||||
// Log("No default bit badge for version {} found", cheerAmount);
|
||||
// continue;
|
||||
//}
|
||||
} else if (badge == "staff/1") {
|
||||
this->emplace<ImageElement>(Image::fromNonOwningPixmap(&app->resources->twitch.staff),
|
||||
MessageElement::BadgeGlobalAuthority)
|
||||
this->emplace<ImageElement>(
|
||||
Image::fromNonOwningPixmap(&app->resources->twitch.staff),
|
||||
MessageElement::BadgeGlobalAuthority)
|
||||
->setTooltip("Twitch Staff");
|
||||
} else if (badge == "admin/1") {
|
||||
this->emplace<ImageElement>(Image::fromNonOwningPixmap(&app->resources->twitch.admin),
|
||||
MessageElement::BadgeGlobalAuthority)
|
||||
this->emplace<ImageElement>(
|
||||
Image::fromNonOwningPixmap(&app->resources->twitch.admin),
|
||||
MessageElement::BadgeGlobalAuthority)
|
||||
->setTooltip("Twitch Admin");
|
||||
} else if (badge == "global_mod/1") {
|
||||
this->emplace<ImageElement>(
|
||||
Image::fromNonOwningPixmap(&app->resources->twitch.globalmod),
|
||||
MessageElement::BadgeGlobalAuthority)
|
||||
this->emplace<ImageElement>(Image::fromNonOwningPixmap(
|
||||
&app->resources->twitch.globalmod),
|
||||
MessageElement::BadgeGlobalAuthority)
|
||||
->setTooltip("Twitch Global Moderator");
|
||||
} else if (badge == "moderator/1") {
|
||||
// TODO: Implement custom FFZ moderator badge
|
||||
this->emplace<ImageElement>(
|
||||
Image::fromNonOwningPixmap(&app->resources->twitch.moderator),
|
||||
MessageElement::BadgeChannelAuthority)
|
||||
this->emplace<ImageElement>(Image::fromNonOwningPixmap(
|
||||
&app->resources->twitch.moderator),
|
||||
MessageElement::BadgeChannelAuthority)
|
||||
->setTooltip("Twitch Channel Moderator");
|
||||
} else if (badge == "turbo/1") {
|
||||
this->emplace<ImageElement>(Image::fromNonOwningPixmap(&app->resources->twitch.turbo),
|
||||
MessageElement::BadgeGlobalAuthority)
|
||||
this->emplace<ImageElement>(
|
||||
Image::fromNonOwningPixmap(&app->resources->twitch.turbo),
|
||||
MessageElement::BadgeGlobalAuthority)
|
||||
->setTooltip("Twitch Turbo Subscriber");
|
||||
} else if (badge == "broadcaster/1") {
|
||||
this->emplace<ImageElement>(
|
||||
Image::fromNonOwningPixmap(&app->resources->twitch.broadcaster),
|
||||
Image::fromNonOwningPixmap(
|
||||
&app->resources->twitch.broadcaster),
|
||||
MessageElement::BadgeChannelAuthority)
|
||||
->setTooltip("Twitch Broadcaster");
|
||||
} else if (badge == "premium/1") {
|
||||
this->emplace<ImageElement>(Image::fromNonOwningPixmap(&app->resources->twitch.prime),
|
||||
MessageElement::BadgeVanity)
|
||||
this->emplace<ImageElement>(
|
||||
Image::fromNonOwningPixmap(&app->resources->twitch.prime),
|
||||
MessageElement::BadgeVanity)
|
||||
->setTooltip("Twitch Prime Subscriber");
|
||||
} else if (badge.startsWith("partner/")) {
|
||||
int index = badge.midRef(8).toInt();
|
||||
switch (index) {
|
||||
case 1: {
|
||||
this->emplace<ImageElement>(
|
||||
Image::fromNonOwningPixmap(&app->resources->twitch.verified),
|
||||
Image::fromNonOwningPixmap(
|
||||
&app->resources->twitch.verified),
|
||||
MessageElement::BadgeVanity)
|
||||
->setTooltip("Twitch Verified");
|
||||
} break;
|
||||
default: {
|
||||
printf("[TwitchMessageBuilder] Unhandled partner badge index: %d\n", index);
|
||||
printf("[TwitchMessageBuilder] Unhandled partner badge "
|
||||
"index: %d\n",
|
||||
index);
|
||||
} break;
|
||||
}
|
||||
} else if (badge.startsWith("subscriber/")) {
|
||||
// if (channelResources.loaded == false) {
|
||||
// // qDebug() << "Channel resources are not loaded, can't add the
|
||||
// subscriber
|
||||
// // qDebug() << "Channel resources are not loaded,
|
||||
// can't add the subscriber
|
||||
// // badge";
|
||||
// continue;
|
||||
// }
|
||||
@@ -752,7 +803,8 @@ void TwitchMessageBuilder::appendTwitchBadges()
|
||||
|
||||
// this->emplace<ImageElement>(badgeVersion.badgeImage1x,
|
||||
// MessageElement::BadgeSubscription)
|
||||
// ->setTooltip("Twitch " + QString::fromStdString(badgeVersion.title));
|
||||
// ->setTooltip("Twitch " +
|
||||
// QString::fromStdString(badgeVersion.title));
|
||||
} else {
|
||||
// if (!app->resources->dynamicBadgesLoaded) {
|
||||
// // Do nothing
|
||||
@@ -762,11 +814,12 @@ void TwitchMessageBuilder::appendTwitchBadges()
|
||||
// QStringList parts = badge.split('/');
|
||||
|
||||
// if (parts.length() != 2) {
|
||||
// qDebug() << "Bad number of parts: " << parts.length() << " in " << parts;
|
||||
// continue;
|
||||
// qDebug() << "Bad number of parts: " << parts.length() << " in
|
||||
// " << parts; continue;
|
||||
//}
|
||||
|
||||
// MessageElement::Flags badgeType = MessageElement::Flags::BadgeVanity;
|
||||
// MessageElement::Flags badgeType =
|
||||
// MessageElement::Flags::BadgeVanity;
|
||||
|
||||
// std::string badgeSetKey = parts[0].toStdString();
|
||||
// std::string versionKey = parts[1].toStdString();
|
||||
@@ -777,11 +830,14 @@ void TwitchMessageBuilder::appendTwitchBadges()
|
||||
// try {
|
||||
// auto &badgeVersion = badgeSet.versions.at(versionKey);
|
||||
|
||||
// this->emplace<ImageElement>(badgeVersion.badgeImage1x, badgeType)
|
||||
// ->setTooltip("Twitch " + QString::fromStdString(badgeVersion.title));
|
||||
// this->emplace<ImageElement>(badgeVersion.badgeImage1x,
|
||||
// badgeType)
|
||||
// ->setTooltip("Twitch " +
|
||||
// QString::fromStdString(badgeVersion.title));
|
||||
// } catch (const std::exception &e) {
|
||||
// qDebug() << "Exception caught:" << e.what()
|
||||
// << "when trying to fetch badge version " << versionKey.c_str();
|
||||
// << "when trying to fetch badge version " <<
|
||||
// versionKey.c_str();
|
||||
// }
|
||||
//} catch (const std::exception &e) {
|
||||
// qDebug() << "No badge set with key" << badgeSetKey.c_str()
|
||||
@@ -804,7 +860,8 @@ void TwitchMessageBuilder::appendChatterinoBadges()
|
||||
|
||||
// const auto badge = it->second;
|
||||
|
||||
// this->emplace<ImageElement>(badge->image, MessageElement::BadgeChatterino)
|
||||
// this->emplace<ImageElement>(badge->image,
|
||||
// MessageElement::BadgeChatterino)
|
||||
// ->setTooltip(QString::fromStdString(badge->tooltip));
|
||||
}
|
||||
|
||||
@@ -830,7 +887,8 @@ Outcome TwitchMessageBuilder::tryParseCheermote(const QString &string)
|
||||
// auto savedIt = cheermoteSet.cheermotes.end();
|
||||
|
||||
// // Fetch cheermote that matches our numBits
|
||||
// for (auto it = cheermoteSet.cheermotes.begin(); it != cheermoteSet.cheermotes.end();
|
||||
// for (auto it = cheermoteSet.cheermotes.begin(); it !=
|
||||
// cheermoteSet.cheermotes.end();
|
||||
// ++it) {
|
||||
// if (numBits >= it->minBits) {
|
||||
// savedIt = it;
|
||||
@@ -840,15 +898,17 @@ Outcome TwitchMessageBuilder::tryParseCheermote(const QString &string)
|
||||
// }
|
||||
|
||||
// if (savedIt == cheermoteSet.cheermotes.end()) {
|
||||
// Log("Error getting a cheermote from a cheermote set for the bit amount {}",
|
||||
// Log("Error getting a cheermote from a cheermote set for the
|
||||
// bit amount {}",
|
||||
// numBits);
|
||||
// return Failure;
|
||||
// }
|
||||
|
||||
// const auto &cheermote = *savedIt;
|
||||
|
||||
// this->emplace<EmoteElement>(cheermote.animatedEmote, EmoteElement::BitsAnimated);
|
||||
// this->emplace<TextElement>(amount, EmoteElement::Text, cheermote.color);
|
||||
// this->emplace<EmoteElement>(cheermote.animatedEmote,
|
||||
// EmoteElement::BitsAnimated); this->emplace<TextElement>(amount,
|
||||
// EmoteElement::Text, cheermote.color);
|
||||
|
||||
// return Success;
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user