refactor: add Channel::addSystemMessage function (#5500)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "providers/twitch/IrcMessageHandler.hpp"
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "common/Channel.hpp"
|
||||
#include "common/Common.hpp"
|
||||
#include "common/Literals.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
@@ -1136,15 +1137,15 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
||||
QString tags = message->tags().value("msg-id").toString();
|
||||
if (tags == "usage_delete")
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(
|
||||
channel->addSystemMessage(
|
||||
"Usage: /delete <msg-id> - Deletes the specified message. "
|
||||
"Can't take more than one argument."));
|
||||
"Can't take more than one argument.");
|
||||
}
|
||||
else if (tags == "bad_delete_message_error")
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(
|
||||
channel->addSystemMessage(
|
||||
"There was a problem deleting the message. "
|
||||
"It might be from another channel or too old to delete."));
|
||||
"It might be from another channel or too old to delete.");
|
||||
}
|
||||
else if (tags == "host_on" || tags == "host_target_went_offline")
|
||||
{
|
||||
@@ -1218,7 +1219,7 @@ void IrcMessageHandler::handleJoinMessage(Communi::IrcMessage *message)
|
||||
if (message->nick() ==
|
||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserName())
|
||||
{
|
||||
twitchChannel->addMessage(makeSystemMessage("joined channel"));
|
||||
twitchChannel->addSystemMessage("joined channel");
|
||||
twitchChannel->joined.invoke();
|
||||
}
|
||||
else if (getSettings()->showJoins.getValue())
|
||||
|
||||
@@ -362,8 +362,8 @@ void TwitchAccount::loadUserstateEmotes(std::weak_ptr<Channel> weakChannel)
|
||||
|
||||
if (auto channel = weakChannel.lock(); channel != nullptr)
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(
|
||||
"Twitch subscriber emotes reloaded."));
|
||||
channel->addSystemMessage(
|
||||
"Twitch subscriber emotes reloaded.");
|
||||
}
|
||||
},
|
||||
[] {
|
||||
@@ -427,7 +427,7 @@ void TwitchAccount::autoModAllow(const QString msgID, ChannelPtr channel)
|
||||
break;
|
||||
}
|
||||
|
||||
channel->addMessage(makeSystemMessage(errorMessage));
|
||||
channel->addSystemMessage(errorMessage);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -473,7 +473,7 @@ void TwitchAccount::autoModDeny(const QString msgID, ChannelPtr channel)
|
||||
break;
|
||||
}
|
||||
|
||||
channel->addMessage(makeSystemMessage(errorMessage));
|
||||
channel->addSystemMessage(errorMessage);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "common/Common.hpp"
|
||||
#include "common/Env.hpp"
|
||||
#include "common/network/NetworkRequest.hpp"
|
||||
#include "common/network/NetworkResult.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
@@ -217,7 +216,7 @@ TwitchChannel::TwitchChannel(const QString &name)
|
||||
// debugging
|
||||
#if 0
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
this->addMessage(makeSystemMessage("asef"));
|
||||
this->addSystemMessage("asef");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1012,9 +1011,9 @@ void TwitchChannel::updateSeventvUser(
|
||||
if (auto shared = weak.lock())
|
||||
{
|
||||
this->seventvEmotes_.set(EMPTY_EMOTE_MAP);
|
||||
this->addMessage(makeSystemMessage(
|
||||
this->addSystemMessage(
|
||||
QString("Failed updating 7TV emote set (%1).")
|
||||
.arg(reason)));
|
||||
.arg(reason));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1512,7 +1511,7 @@ void TwitchChannel::refreshBadges()
|
||||
break;
|
||||
}
|
||||
|
||||
this->addMessage(makeSystemMessage(errorMessage));
|
||||
this->addSystemMessage(errorMessage);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1600,8 +1599,8 @@ void TwitchChannel::createClip()
|
||||
{
|
||||
if (!this->isLive())
|
||||
{
|
||||
this->addMessage(makeSystemMessage(
|
||||
"Cannot create clip while the channel is offline!"));
|
||||
this->addSystemMessage(
|
||||
"Cannot create clip while the channel is offline!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1616,7 +1615,7 @@ void TwitchChannel::createClip()
|
||||
return;
|
||||
}
|
||||
|
||||
this->addMessage(makeSystemMessage("Creating clip..."));
|
||||
this->addSystemMessage("Creating clip...");
|
||||
this->isClipCreationInProgress = true;
|
||||
|
||||
getHelix()->createClip(
|
||||
|
||||
@@ -42,8 +42,8 @@ void sendHelixMessage(const std::shared_ptr<TwitchChannel> &channel,
|
||||
auto broadcasterID = channel->roomId();
|
||||
if (broadcasterID.isEmpty())
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(
|
||||
"Sending messages in this channel isn't possible."));
|
||||
channel->addSystemMessage(
|
||||
"Sending messages in this channel isn't possible.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -67,14 +67,14 @@ void sendHelixMessage(const std::shared_ptr<TwitchChannel> &channel,
|
||||
return;
|
||||
}
|
||||
|
||||
auto errorMessage = [&] {
|
||||
if (res.dropReason)
|
||||
{
|
||||
return makeSystemMessage(res.dropReason->message);
|
||||
}
|
||||
return makeSystemMessage("Your message was not sent.");
|
||||
}();
|
||||
chan->addMessage(errorMessage);
|
||||
if (res.dropReason)
|
||||
{
|
||||
chan->addSystemMessage(res.dropReason->message);
|
||||
}
|
||||
else
|
||||
{
|
||||
chan->addSystemMessage("Your message was not sent.");
|
||||
}
|
||||
},
|
||||
[weak = std::weak_ptr(channel)](auto error, auto message) {
|
||||
auto chan = weak.lock();
|
||||
@@ -112,7 +112,7 @@ void sendHelixMessage(const std::shared_ptr<TwitchChannel> &channel,
|
||||
return "Unknown error: " + message;
|
||||
}
|
||||
}();
|
||||
chan->addMessage(makeSystemMessage(errorMessage));
|
||||
chan->addSystemMessage(errorMessage);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -390,14 +390,13 @@ std::shared_ptr<Channel> TwitchIrcServer::getCustomChannel(
|
||||
{
|
||||
for (auto i = 0; i < 1000; i++)
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(QString::number(i + 1)));
|
||||
channel->addSystemMessage(QString::number(i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
auto *timer = new QTimer;
|
||||
QObject::connect(timer, &QTimer::timeout, [channel] {
|
||||
channel->addMessage(
|
||||
makeSystemMessage(QTime::currentTime().toString()));
|
||||
channel->addSystemMessage(QTime::currentTime().toString());
|
||||
});
|
||||
timer->start(msBetweenMessages);
|
||||
return timer;
|
||||
@@ -562,10 +561,7 @@ bool TwitchIrcServer::prepareToSend(
|
||||
{
|
||||
if (this->lastErrorTimeSpeed_ + 30s < now)
|
||||
{
|
||||
auto errorMessage =
|
||||
makeSystemMessage("You are sending messages too quickly.");
|
||||
|
||||
channel->addMessage(errorMessage);
|
||||
channel->addSystemMessage("You are sending messages too quickly.");
|
||||
|
||||
this->lastErrorTimeSpeed_ = now;
|
||||
}
|
||||
@@ -583,10 +579,7 @@ bool TwitchIrcServer::prepareToSend(
|
||||
{
|
||||
if (this->lastErrorTimeAmount_ + 30s < now)
|
||||
{
|
||||
auto errorMessage =
|
||||
makeSystemMessage("You are sending too many messages.");
|
||||
|
||||
channel->addMessage(errorMessage);
|
||||
channel->addSystemMessage("You are sending too many messages.");
|
||||
|
||||
this->lastErrorTimeAmount_ = now;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user