Improve the "You are banned" message (#2266)
Added reconnect link to the "You are banned" message
This commit is contained in:
@@ -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 "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)
|
- 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: 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: 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)
|
- Minor: Added a keyboard shortcut (Ctrl+F5) for "Reconnect" (#2215)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public:
|
|||||||
AutoModDeny,
|
AutoModDeny,
|
||||||
OpenAccountsPage,
|
OpenAccountsPage,
|
||||||
JumpToChannel,
|
JumpToChannel,
|
||||||
|
Reconnect
|
||||||
};
|
};
|
||||||
|
|
||||||
Link();
|
Link();
|
||||||
|
|||||||
@@ -19,6 +19,39 @@
|
|||||||
|
|
||||||
#include <unordered_set>
|
#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 {
|
namespace chatterino {
|
||||||
|
|
||||||
static float relativeSimilarity(const QString &str1, const QString &str2)
|
static float relativeSimilarity(const QString &str1, const QString &str2)
|
||||||
@@ -679,6 +712,10 @@ std::vector<MessagePtr> IrcMessageHandler::parseNoticeMessage(
|
|||||||
|
|
||||||
return {builder.release()};
|
return {builder.release()};
|
||||||
}
|
}
|
||||||
|
else if (message->content().startsWith("You are permanently banned "))
|
||||||
|
{
|
||||||
|
return {generateBannedMessage(true)};
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::vector<MessagePtr> builtMessages;
|
std::vector<MessagePtr> builtMessages;
|
||||||
@@ -762,13 +799,18 @@ void IrcMessageHandler::handlePartMessage(Communi::IrcMessage *message)
|
|||||||
if (TwitchChannel *twitchChannel =
|
if (TwitchChannel *twitchChannel =
|
||||||
dynamic_cast<TwitchChannel *>(channel.get()))
|
dynamic_cast<TwitchChannel *>(channel.get()))
|
||||||
{
|
{
|
||||||
if (message->nick() !=
|
const auto selfAccountName =
|
||||||
getApp()->accounts->twitch.getCurrent()->getUserName() &&
|
getApp()->accounts->twitch.getCurrent()->getUserName();
|
||||||
|
if (message->nick() != selfAccountName &&
|
||||||
getSettings()->showParts.getValue())
|
getSettings()->showParts.getValue())
|
||||||
{
|
{
|
||||||
twitchChannel->addPartedUser(message->nick());
|
twitchChannel->addPartedUser(message->nick());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (message->nick() == selfAccountName)
|
||||||
|
{
|
||||||
|
channel->addMessage(generateBannedMessage(false));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|||||||
@@ -2080,6 +2080,10 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Link::Reconnect: {
|
||||||
|
this->underlyingChannel_.get()->reconnect();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user