diff --git a/CHANGELOG.md b/CHANGELOG.md index 36deb4934..4ab4321b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Major: Added "Channel Filters". See https://wiki.chatterino.com/Filters/ for how they work or how to configure them. (#1748, #2083, #2090, #2200) - Major: Added Streamer Mode configuration (under `Settings -> General`), where you can select which features of Chatterino should behave differently when you are in Streamer Mode. (#2001) +- Minor: Added reconnect link to the "You are banned" message. (#2266) - Minor: Improved search popup window titles. (#2268) - Minor: Made "#channel" in `/mentions` tab a clickable link which takes you to the channel that you were mentioned in. (#2220) - Minor: Added a keyboard shortcut (Ctrl+F5) for "Reconnect" (#2215) diff --git a/src/messages/Link.hpp b/src/messages/Link.hpp index ac83da587..a3fb283f1 100644 --- a/src/messages/Link.hpp +++ b/src/messages/Link.hpp @@ -21,6 +21,7 @@ public: AutoModDeny, OpenAccountsPage, JumpToChannel, + Reconnect }; Link(); diff --git a/src/providers/twitch/IrcMessageHandler.cpp b/src/providers/twitch/IrcMessageHandler.cpp index 57f4f90ff..e553d2aed 100644 --- a/src/providers/twitch/IrcMessageHandler.cpp +++ b/src/providers/twitch/IrcMessageHandler.cpp @@ -19,6 +19,39 @@ #include +namespace { +using namespace chatterino; +MessagePtr generateBannedMessage(bool confirmedBan) +{ + const auto linkColor = MessageColor(MessageColor::Link); + const auto accountsLink = Link(Link::Reconnect, QString()); + const auto bannedText = + confirmedBan + ? QString("You were banned from this channel!") + : QString( + "Your connection to this channel was unexpectedly dropped."); + + const auto reconnectPromptText = + confirmedBan + ? QString( + "If you believe you have been unbanned, try reconnecting.") + : QString("Try reconnecting."); + + MessageBuilder builder; + builder.message().flags.set(MessageFlag::System); + + builder.emplace(); + builder.emplace(bannedText, MessageElementFlag::Text, + MessageColor::System); + builder + .emplace(reconnectPromptText, MessageElementFlag::Text, + linkColor) + ->setLink(accountsLink); + + return builder.release(); +} + +} // namespace namespace chatterino { static float relativeSimilarity(const QString &str1, const QString &str2) @@ -679,6 +712,10 @@ std::vector IrcMessageHandler::parseNoticeMessage( return {builder.release()}; } + else if (message->content().startsWith("You are permanently banned ")) + { + return {generateBannedMessage(true)}; + } else { std::vector builtMessages; @@ -762,13 +799,18 @@ void IrcMessageHandler::handlePartMessage(Communi::IrcMessage *message) if (TwitchChannel *twitchChannel = dynamic_cast(channel.get())) { - if (message->nick() != - getApp()->accounts->twitch.getCurrent()->getUserName() && + const auto selfAccountName = + getApp()->accounts->twitch.getCurrent()->getUserName(); + if (message->nick() != selfAccountName && getSettings()->showParts.getValue()) { twitchChannel->addPartedUser(message->nick()); } + + if (message->nick() == selfAccountName) + { + channel->addMessage(generateBannedMessage(false)); + } } } - } // namespace chatterino diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index c3701c93d..6aadf2c8d 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -2080,6 +2080,10 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link, } } break; + case Link::Reconnect: { + this->underlyingChannel_.get()->reconnect(); + } + break; default:; }