mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Parse usernames out of /mods and /vips messages (#3187)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
5112ec73b0
commit
5f7caebce0
|
@ -14,6 +14,7 @@
|
||||||
- Minor: Added the ability to open an entire tab as a popup. (#3082)
|
- Minor: Added the ability to open an entire tab as a popup. (#3082)
|
||||||
- Minor: Added optional parameter to /usercard command for opening a usercard in a different channel context. (#3172)
|
- Minor: Added optional parameter to /usercard command for opening a usercard in a different channel context. (#3172)
|
||||||
- Minor: Added regex option to Nicknames. (#3146)
|
- Minor: Added regex option to Nicknames. (#3146)
|
||||||
|
- Minor: Highlight usernames in /mods and /vips messages (#3187)
|
||||||
- Minor: Added `/raw` command. (#3189)
|
- Minor: Added `/raw` command. (#3189)
|
||||||
- Minor: Colorizing usernames on IRC, originally made for Mm2PL/dankerino (#3206)
|
- Minor: Colorizing usernames on IRC, originally made for Mm2PL/dankerino (#3206)
|
||||||
- Minor: Fixed `/streamlink` command not stripping leading @'s or #'s (#3215)
|
- Minor: Fixed `/streamlink` command not stripping leading @'s or #'s (#3215)
|
||||||
|
|
|
@ -834,6 +834,31 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
||||||
hostOn);
|
hostOn);
|
||||||
channel->addMessage(builder.release());
|
channel->addMessage(builder.release());
|
||||||
}
|
}
|
||||||
|
else if (tags == "room_mods" || tags == "vips_success")
|
||||||
|
{
|
||||||
|
// /mods and /vips
|
||||||
|
// room_mods: The moderators of this channel are: ampzyh, antichriststollen, apa420, ...
|
||||||
|
// vips_success: The VIPs of this channel are: 8008, aiden, botfactory, ...
|
||||||
|
|
||||||
|
QString noticeText = msg->messageText;
|
||||||
|
if (tags == "vips_success")
|
||||||
|
{
|
||||||
|
// this one has a trailing period, need to get rid of it.
|
||||||
|
noticeText.chop(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList msgParts = noticeText.split(':');
|
||||||
|
MessageBuilder builder;
|
||||||
|
|
||||||
|
auto tc = dynamic_cast<TwitchChannel *>(channel.get());
|
||||||
|
assert(tc != nullptr &&
|
||||||
|
"IrcMessageHandler::handleNoticeMessage. Twitch specific "
|
||||||
|
"functionality called in non twitch channel");
|
||||||
|
|
||||||
|
TwitchMessageBuilder::modsOrVipsSystemMessage(
|
||||||
|
msgParts.at(0), msgParts.at(1).split(", "), tc, &builder);
|
||||||
|
channel->addMessage(builder.release());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
channel->addMessage(msg);
|
channel->addMessage(msg);
|
||||||
|
|
|
@ -1438,4 +1438,49 @@ void TwitchMessageBuilder::deletionMessage(const DeleteAction &action,
|
||||||
builder->message().timeoutUser = "msg:" + action.messageId;
|
builder->message().timeoutUser = "msg:" + action.messageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TwitchMessageBuilder::modsOrVipsSystemMessage(QString prefix,
|
||||||
|
QStringList users,
|
||||||
|
TwitchChannel *channel,
|
||||||
|
MessageBuilder *builder)
|
||||||
|
{
|
||||||
|
builder->emplace<TimestampElement>();
|
||||||
|
builder->message().flags.set(MessageFlag::System);
|
||||||
|
builder->message().flags.set(MessageFlag::DoNotTriggerNotification);
|
||||||
|
builder->emplace<TextElement>(prefix, MessageElementFlag::Text,
|
||||||
|
MessageColor::System);
|
||||||
|
bool isFirst = true;
|
||||||
|
for (const QString &username : users)
|
||||||
|
{
|
||||||
|
if (!isFirst)
|
||||||
|
{
|
||||||
|
// this is used to add the ", " after each but the last entry
|
||||||
|
builder->emplace<TextElement>(",", MessageElementFlag::Text,
|
||||||
|
MessageColor::System);
|
||||||
|
}
|
||||||
|
isFirst = false;
|
||||||
|
|
||||||
|
MessageColor color = MessageColor::System;
|
||||||
|
|
||||||
|
if (getSettings()->colorUsernames)
|
||||||
|
{
|
||||||
|
if (auto userColor = channel->getUserColor(username);
|
||||||
|
userColor.isValid())
|
||||||
|
{
|
||||||
|
color = MessageColor(userColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
builder
|
||||||
|
->emplace<TextElement>(username, MessageElementFlag::BoldUsername,
|
||||||
|
color, FontStyle::ChatMediumBold)
|
||||||
|
->setLink({Link::UserInfo, username})
|
||||||
|
->setTrailingSpace(false);
|
||||||
|
builder
|
||||||
|
->emplace<TextElement>(username,
|
||||||
|
MessageElementFlag::NonBoldUsername, color)
|
||||||
|
->setLink({Link::UserInfo, username})
|
||||||
|
->setTrailingSpace(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -64,6 +64,9 @@ public:
|
||||||
MessageBuilder *builder);
|
MessageBuilder *builder);
|
||||||
static void deletionMessage(const DeleteAction &action,
|
static void deletionMessage(const DeleteAction &action,
|
||||||
MessageBuilder *builder);
|
MessageBuilder *builder);
|
||||||
|
static void modsOrVipsSystemMessage(QString prefix, QStringList users,
|
||||||
|
TwitchChannel *channel,
|
||||||
|
MessageBuilder *builder);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void parseUsernameColor() override;
|
void parseUsernameColor() override;
|
||||||
|
|
Loading…
Reference in a new issue