Compare commits

..

2 commits

Author SHA1 Message Date
pajlada 24d8144d65
Merge 439d21d009 into 18c4815ad7 2024-10-22 18:48:59 +02:00
iProdigy 18c4815ad7
feat: add shared chat badge (#5661) 2024-10-22 18:42:19 +02:00
12 changed files with 150 additions and 2 deletions

View file

@ -7,7 +7,7 @@
- Major: Improve high-DPI support on Windows. (#4868, #5391, #5664, #5666) - Major: Improve high-DPI support on Windows. (#4868, #5391, #5664, #5666)
- Major: Added transparent overlay window (default keybind: <kbd>CTRL</kbd> + <kbd>ALT</kbd> + <kbd>N</kbd>). (#4746, #5643, #5659) - Major: Added transparent overlay window (default keybind: <kbd>CTRL</kbd> + <kbd>ALT</kbd> + <kbd>N</kbd>). (#4746, #5643, #5659)
- Minor: Removed the Ctrl+Shift+L hotkey for toggling the "live only" tab visibility state. (#5530) - Minor: Removed the Ctrl+Shift+L hotkey for toggling the "live only" tab visibility state. (#5530)
- Minor: Add support for Shared Chat messages. Shared chat messages can be filtered with the `flags.shared` filter variable, or with search using `is:shared`. Some messages like subscriptions are filtered on purpose to avoid confusion for the broadcaster. If you have both channels participating in Shared Chat open, only one of the message triggering your highlight will trigger. (#5606, #5625) - Minor: Add support for Shared Chat messages. Shared chat messages can be filtered with the `flags.shared` filter variable, or with search using `is:shared`. Some messages like subscriptions are filtered on purpose to avoid confusion for the broadcaster. If you have both channels participating in Shared Chat open, only one of the message triggering your highlight will trigger. (#5606, #5625, #5661)
- Minor: Moved tab visibility control to a submenu, without any toggle actions. (#5530) - Minor: Moved tab visibility control to a submenu, without any toggle actions. (#5530)
- Minor: Add option to customise Moderation buttons with images. (#5369) - Minor: Add option to customise Moderation buttons with images. (#5369)
- Minor: Colored usernames now update on the fly when changing the "Color @usernames" setting. (#5300) - Minor: Colored usernames now update on the fly when changing the "Color @usernames" setting. (#5300)

View file

@ -3,6 +3,7 @@
#include "common/Args.hpp" #include "common/Args.hpp"
#include "mocks/DisabledStreamerMode.hpp" #include "mocks/DisabledStreamerMode.hpp"
#include "mocks/EmptyApplication.hpp" #include "mocks/EmptyApplication.hpp"
#include "mocks/TwitchUsers.hpp"
#include "providers/bttv/BttvLiveUpdates.hpp" #include "providers/bttv/BttvLiveUpdates.hpp"
#include "singletons/Fonts.hpp" #include "singletons/Fonts.hpp"
#include "singletons/Settings.hpp" #include "singletons/Settings.hpp"
@ -55,6 +56,11 @@ public:
return &this->fonts; return &this->fonts;
} }
ITwitchUsers *getTwitchUsers() override
{
return &this->twitchUsers;
}
BttvLiveUpdates *getBttvLiveUpdates() override BttvLiveUpdates *getBttvLiveUpdates() override
{ {
return nullptr; return nullptr;
@ -71,6 +77,7 @@ public:
DisabledStreamerMode streamerMode; DisabledStreamerMode streamerMode;
Theme theme; Theme theme;
Fonts fonts; Fonts fonts;
TwitchUsers twitchUsers;
}; };
} // namespace chatterino::mock } // namespace chatterino::mock

View file

@ -0,0 +1,24 @@
#pragma once
#include "providers/twitch/TwitchUser.hpp"
#include "providers/twitch/TwitchUsers.hpp"
namespace chatterino::mock {
class TwitchUsers : public ITwitchUsers
{
public:
TwitchUsers() = default;
std::shared_ptr<TwitchUser> resolveID(const UserId &id)
{
TwitchUser u = {
.id = id.string,
.name = {},
.displayName = {},
};
return std::make_shared<TwitchUser>(u);
}
};
} // namespace chatterino::mock

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -32,6 +32,7 @@
#include "providers/twitch/TwitchChannel.hpp" #include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchIrc.hpp" #include "providers/twitch/TwitchIrc.hpp"
#include "providers/twitch/TwitchIrcServer.hpp" #include "providers/twitch/TwitchIrcServer.hpp"
#include "providers/twitch/TwitchUsers.hpp"
#include "singletons/Emotes.hpp" #include "singletons/Emotes.hpp"
#include "singletons/Resources.hpp" #include "singletons/Resources.hpp"
#include "singletons/Settings.hpp" #include "singletons/Settings.hpp"
@ -380,6 +381,18 @@ EmotePtr makeAutoModBadge()
Url{"https://dashboard.twitch.tv/settings/moderation/automod"}}); Url{"https://dashboard.twitch.tv/settings/moderation/automod"}});
} }
EmotePtr makeSharedChatBadge(const QString &sourceName)
{
return std::make_shared<Emote>(Emote{
.name = EmoteName{},
.images = ImageSet{Image::fromResourcePixmap(
getResources().twitch.sharedChat, 0.25)},
.tooltip = Tooltip{"Shared Message" +
(sourceName.isEmpty() ? "" : " from " + sourceName)},
.homePage = Url{"https://link.twitch.tv/SharedChatViewer"},
});
}
std::tuple<std::optional<EmotePtr>, MessageElementFlags, bool> parseEmote( std::tuple<std::optional<EmotePtr>, MessageElementFlags, bool> parseEmote(
TwitchChannel *twitchChannel, const EmoteName &name) TwitchChannel *twitchChannel, const EmoteName &name)
{ {
@ -2751,6 +2764,28 @@ void MessageBuilder::appendTwitchBadges(const QVariantMap &tags,
return; return;
} }
if (this->message().flags.has(MessageFlag::SharedMessage))
{
const QString sourceId = tags["source-room-id"].toString();
QString sourceName;
if (sourceId.isEmpty())
{
sourceName = "";
}
else if (twitchChannel->roomId() == sourceId)
{
sourceName = twitchChannel->getName();
}
else
{
sourceName =
getApp()->getTwitchUsers()->resolveID({sourceId})->displayName;
}
this->emplace<BadgeElement>(makeSharedChatBadge(sourceName),
MessageElementFlag::BadgeSharedChannel);
}
auto badgeInfos = parseBadgeInfoTag(tags); auto badgeInfos = parseBadgeInfoTag(tags);
auto badges = parseBadgeTag(tags); auto badges = parseBadgeTag(tags);
appendBadges(this, badges, badgeInfos, twitchChannel); appendBadges(this, badges, badgeInfos, twitchChannel);

View file

@ -66,6 +66,10 @@ enum class MessageElementFlag : int64_t {
BitsStatic = (1LL << 11), BitsStatic = (1LL << 11),
BitsAnimated = (1LL << 12), BitsAnimated = (1LL << 12),
// Slot 0: Twitch
// - Shared Channel indicator badge
BadgeSharedChannel = (1LL << 37),
// Slot 1: Twitch // Slot 1: Twitch
// - Staff badge // - Staff badge
// - Admin badge // - Admin badge
@ -119,7 +123,7 @@ enum class MessageElementFlag : int64_t {
Badges = BadgeGlobalAuthority | BadgePredictions | BadgeChannelAuthority | Badges = BadgeGlobalAuthority | BadgePredictions | BadgeChannelAuthority |
BadgeSubscription | BadgeVanity | BadgeChatterino | BadgeSevenTV | BadgeSubscription | BadgeVanity | BadgeChatterino | BadgeSevenTV |
BadgeFfz, BadgeFfz | BadgeSharedChannel,
ChannelName = (1LL << 20), ChannelName = (1LL << 20),

View file

@ -195,6 +195,7 @@ void WindowManager::updateWordTypeMask()
flags.set(settings->animateEmotes ? MEF::BitsAnimated : MEF::BitsStatic); flags.set(settings->animateEmotes ? MEF::BitsAnimated : MEF::BitsStatic);
// badges // badges
flags.set(MEF::BadgeSharedChannel);
flags.set(settings->showBadgesGlobalAuthority ? MEF::BadgeGlobalAuthority flags.set(settings->showBadgesGlobalAuthority ? MEF::BadgeGlobalAuthority
: MEF::None); : MEF::None);
flags.set(settings->showBadgesPredictions ? MEF::BadgePredictions flags.set(settings->showBadgesPredictions ? MEF::BadgePredictions

View file

@ -2410,6 +2410,11 @@ void ChannelView::handleMouseClick(QMouseEvent *event,
return; return;
} }
if (link.value.startsWith("id:"))
{
return;
}
// Insert @username into split input // Insert @username into split input
const bool commaMention = const bool commaMention =
getSettings()->mentionUsersWithComma; getSettings()->mentionUsersWithComma;

View file

@ -64,6 +64,24 @@
"trailingSpace": true, "trailingSpace": true,
"type": "TwitchModerationElement" "type": "TwitchModerationElement"
}, },
{
"emote": {
"homePage": "https://link.twitch.tv/SharedChatViewer",
"images": {
"1x": ""
},
"name": "",
"tooltip": "Shared Message"
},
"flags": "BadgeSharedChannel",
"link": {
"type": "None",
"value": ""
},
"tooltip": "Shared Message",
"trailingSpace": true,
"type": "BadgeElement"
},
{ {
"emote": { "emote": {
"homePage": "https://www.twitch.tv/jobs?ref=chat_badge", "homePage": "https://www.twitch.tv/jobs?ref=chat_badge",

View file

@ -64,6 +64,24 @@
"trailingSpace": true, "trailingSpace": true,
"type": "TwitchModerationElement" "type": "TwitchModerationElement"
}, },
{
"emote": {
"homePage": "https://link.twitch.tv/SharedChatViewer",
"images": {
"1x": ""
},
"name": "",
"tooltip": "Shared Message from twitchdev"
},
"flags": "BadgeSharedChannel",
"link": {
"type": "None",
"value": ""
},
"tooltip": "Shared Message from twitchdev",
"trailingSpace": true,
"type": "BadgeElement"
},
{ {
"color": "#ffff0000", "color": "#ffff0000",
"flags": "Username", "flags": "Username",

View file

@ -64,6 +64,24 @@
"trailingSpace": true, "trailingSpace": true,
"type": "TwitchModerationElement" "type": "TwitchModerationElement"
}, },
{
"emote": {
"homePage": "https://link.twitch.tv/SharedChatViewer",
"images": {
"1x": ""
},
"name": "",
"tooltip": "Shared Message from twitchdev"
},
"flags": "BadgeSharedChannel",
"link": {
"type": "None",
"value": ""
},
"tooltip": "Shared Message from twitchdev",
"trailingSpace": true,
"type": "BadgeElement"
},
{ {
"emote": { "emote": {
"homePage": "https://www.twitch.tv/jobs?ref=chat_badge", "homePage": "https://www.twitch.tv/jobs?ref=chat_badge",

View file

@ -64,6 +64,24 @@
"trailingSpace": true, "trailingSpace": true,
"type": "TwitchModerationElement" "type": "TwitchModerationElement"
}, },
{
"emote": {
"homePage": "https://link.twitch.tv/SharedChatViewer",
"images": {
"1x": ""
},
"name": "",
"tooltip": "Shared Message"
},
"flags": "BadgeSharedChannel",
"link": {
"type": "None",
"value": ""
},
"tooltip": "Shared Message",
"trailingSpace": true,
"type": "BadgeElement"
},
{ {
"emote": { "emote": {
"homePage": "https://www.twitch.tv/jobs?ref=chat_badge", "homePage": "https://www.twitch.tv/jobs?ref=chat_badge",