Rework badge types to fit with the way twitch sends badges

This commit is contained in:
Rasmus Karlsson 2017-06-16 10:11:44 +02:00
parent 56e521bc24
commit 8f4e20db8e
2 changed files with 50 additions and 32 deletions

View file

@ -35,29 +35,47 @@ public:
BitsStatic = (1 << 12),
BitsAnimated = (1 << 13),
BadgeStaff = (1 << 14),
BadgeAdmin = (1 << 15),
BadgeGlobalMod = (1 << 16),
BadgeModerator = (1 << 17),
BadgeTurbo = (1 << 18),
BadgeBroadcaster = (1 << 19),
BadgePremium = (1 << 20),
BadgeChatterino = (1 << 21),
BadgeCheer = (1 << 22),
BadgeVerified = (1 << 23),
BadgeMiscellaneous = (1 << 24),
Badges = BadgeStaff | BadgeAdmin | BadgeGlobalMod | BadgeModerator | BadgeTurbo |
BadgeBroadcaster | BadgePremium | BadgeChatterino | BadgeCheer | BadgeVerified |
BadgeMiscellaneous,
// Slot 1: Twitch
// - Staff badge
// - Admin badge
// - Global Moderator badge
BadgeGlobalAuthority = (1 << 14),
Username = (1 << 25),
BitsAmount = (1 << 26),
// Slot 2: Twitch
// - Moderator badge
// - Broadcaster badge
BadgeChannelAuthority = (1 << 15),
ButtonBan = (1 << 27),
ButtonTimeout = (1 << 28),
// Slot 3: Twitch
// - Subscription badges
BadgeSubscription = (1 << 16),
EmojiImage = (1 << 29),
EmojiText = (1 << 30),
// Slot 4: Twitch
// - Turbo badge
// - Prime badge
// - Bit badges
// - Game badges
BadgeVanity = (1 << 17),
// Slot 5: Chatterino
// - Chatterino developer badge
// - Chatterino donator badge
// - Chatterino top donator badge
BadgeChatterino = (1 << 18),
// Rest of slots: ffz custom badge? bttv custom badge? mywaifu (puke) custom badge?
Badges = BadgeGlobalAuthority | BadgeChannelAuthority | BadgeSubscription | BadgeVanity |
BadgeChatterino,
Username = (1 << 19),
BitsAmount = (1 << 20),
ButtonBan = (1 << 21),
ButtonTimeout = (1 << 22),
EmojiImage = (1 << 23),
EmojiText = (1 << 34),
Default = TimestampNoSeconds | Badges | Username | BitsStatic | FfzEmoteImage |
BttvEmoteImage | BttvGifEmoteImage | TwitchEmoteImage | BitsAmount | Text |

View file

@ -373,7 +373,7 @@ void TwitchMessageBuilder::appendTwitchBadges(const QStringList &badges, Resourc
auto &badgeVersion = badgeSet.versions.at(versionKey);
appendWord(
Word(badgeVersion.badgeImage1x, Word::BadgeCheer, QString(),
Word(badgeVersion.badgeImage1x, Word::BadgeVanity, QString(),
QString("Twitch " + QString::fromStdString(badgeVersion.title))));
} catch (const std::exception &e) {
qDebug() << "Exception caught:" << e.what()
@ -386,33 +386,33 @@ void TwitchMessageBuilder::appendTwitchBadges(const QStringList &badges, Resourc
}
} else if (badge == "staff/1") {
appendWord(
Word(resources.badgeStaff, Word::BadgeStaff, QString(), QString("Twitch Staff")));
appendWord(Word(resources.badgeStaff, Word::BadgeGlobalAuthority, QString(),
QString("Twitch Staff")));
} else if (badge == "admin/1") {
appendWord(
Word(resources.badgeAdmin, Word::BadgeAdmin, QString(), QString("Twitch Admin")));
appendWord(Word(resources.badgeAdmin, Word::BadgeGlobalAuthority, QString(),
QString("Twitch Admin")));
} else if (badge == "global_mod/1") {
appendWord(Word(resources.badgeGlobalModerator, Word::BadgeGlobalMod, QString(),
appendWord(Word(resources.badgeGlobalModerator, Word::BadgeGlobalAuthority, QString(),
QString("Global Moderator")));
} else if (badge == "moderator/1") {
// TODO: Implement custom FFZ moderator badge
appendWord(Word(resources.badgeModerator, Word::BadgeModerator, QString(),
appendWord(Word(resources.badgeModerator, Word::BadgeChannelAuthority, QString(),
QString("Channel Moderator"))); // custom badge
} else if (badge == "turbo/1") {
appendWord(Word(resources.badgeStaff, Word::BadgeTurbo, QString(),
appendWord(Word(resources.badgeStaff, Word::BadgeVanity, QString(),
QString("Turbo Subscriber")));
} else if (badge == "broadcaster/1") {
appendWord(Word(resources.badgeBroadcaster, Word::BadgeBroadcaster, QString(),
appendWord(Word(resources.badgeBroadcaster, Word::BadgeChannelAuthority, QString(),
QString("Channel Broadcaster")));
} else if (badge == "premium/1") {
appendWord(Word(resources.badgePremium, Word::BadgePremium, QString(),
appendWord(Word(resources.badgePremium, Word::BadgeVanity, QString(),
QString("Twitch Prime")));
} else if (badge.startsWith("partner/")) {
int index = badge.midRef(8).toInt();
switch (index) {
case 1: {
appendWord(Word(resources.badgeVerified, Word::BadgeVerified, QString(),
appendWord(Word(resources.badgeVerified, Word::BadgeVanity, QString(),
"Twitch Verified"));
} break;
default: {
@ -442,7 +442,7 @@ void TwitchMessageBuilder::appendTwitchBadges(const QStringList &badges, Resourc
continue;
}
Word::Type badgeType = Word::Type::BadgeMiscellaneous;
Word::Type badgeType = Word::Type::BadgeVanity;
std::string badgeSetKey = parts[0].toStdString();
std::string versionKey = parts[1].toStdString();