Improve the "You are banned" message (#2266)

Added reconnect link to the "You are banned" message
This commit is contained in:
Mm2PL 2020-12-12 14:19:51 +01:00 committed by GitHub
parent c6d55e0d8c
commit eb8eecdfed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 3 deletions

View file

@ -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)

View file

@ -21,6 +21,7 @@ public:
AutoModDeny,
OpenAccountsPage,
JumpToChannel,
Reconnect
};
Link();

View file

@ -19,6 +19,39 @@
#include <unordered_set>
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<TimestampElement>();
builder.emplace<TextElement>(bannedText, MessageElementFlag::Text,
MessageColor::System);
builder
.emplace<TextElement>(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<MessagePtr> IrcMessageHandler::parseNoticeMessage(
return {builder.release()};
}
else if (message->content().startsWith("You are permanently banned "))
{
return {generateBannedMessage(true)};
}
else
{
std::vector<MessagePtr> builtMessages;
@ -762,13 +799,18 @@ void IrcMessageHandler::handlePartMessage(Communi::IrcMessage *message)
if (TwitchChannel *twitchChannel =
dynamic_cast<TwitchChannel *>(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

View file

@ -2080,6 +2080,10 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
}
}
break;
case Link::Reconnect: {
this->underlyingChannel_.get()->reconnect();
}
break;
default:;
}