chore: refactor TwitchIrcServer (#5421)

This commit is contained in:
pajlada
2024-06-01 14:56:40 +02:00
committed by GitHub
parent 2a46ee708e
commit b6dc5d9e03
28 changed files with 373 additions and 163 deletions
+7 -6
View File
@@ -390,9 +390,9 @@ QString popup(const CommandContext &ctx)
}
// Open channel passed as argument in a popup
auto *app = getApp();
auto targetChannel = app->twitch->getOrAddChannel(target);
app->getWindows()->openInPopup(targetChannel);
auto targetChannel =
getIApp()->getTwitchAbstract()->getOrAddChannel(target);
getIApp()->getWindows()->openInPopup(targetChannel);
return "";
}
@@ -533,7 +533,8 @@ QString sendRawMessage(const CommandContext &ctx)
if (ctx.channel->isTwitchChannel())
{
getApp()->twitch->sendRawMessage(ctx.words.mid(1).join(" "));
getIApp()->getTwitchAbstract()->sendRawMessage(
ctx.words.mid(1).join(" "));
}
else
{
@@ -566,7 +567,7 @@ QString injectFakeMessage(const CommandContext &ctx)
}
auto ircText = ctx.words.mid(1).join(" ");
getApp()->twitch->addFakeMessage(ircText);
getIApp()->getTwitchAbstract()->addFakeMessage(ircText);
return "";
}
@@ -667,7 +668,7 @@ QString openUsercard(const CommandContext &ctx)
stripChannelName(channelName);
ChannelPtr channelTemp =
getApp()->twitch->getChannelOrEmpty(channelName);
getIApp()->getTwitchAbstract()->getChannelOrEmpty(channelName);
if (channelTemp->isEmpty())
{
@@ -92,7 +92,7 @@ QString formatWhisperError(HelixWhisperError error, const QString &message)
bool appendWhisperMessageWordsLocally(const QStringList &words)
{
auto *app = getApp();
auto *app = getIApp();
MessageBuilder b;
@@ -177,7 +177,7 @@ bool appendWhisperMessageWordsLocally(const QStringList &words)
b->flags.set(MessageFlag::Whisper);
auto messagexD = b.release();
app->twitch->whispersChannel->addMessage(messagexD);
getIApp()->getTwitch()->getWhispersChannel()->addMessage(messagexD);
auto overrideFlags = std::optional<MessageFlags>(messagexD->flags);
overrideFlags->set(MessageFlag::DoNotLog);
@@ -186,7 +186,7 @@ bool appendWhisperMessageWordsLocally(const QStringList &words)
!(getSettings()->streamerModeSuppressInlineWhispers &&
getIApp()->getStreamerMode()->isEnabled()))
{
app->twitch->forEachChannel(
app->getTwitchAbstract()->forEachChannel(
[&messagexD, overrideFlags](ChannelPtr _channel) {
_channel->addMessage(messagexD, overrideFlags);
});
@@ -124,7 +124,7 @@ void NotificationController::fetchFakeChannels()
for (std::vector<int>::size_type i = 0;
i < channelMap[Platform::Twitch].raw().size(); i++)
{
auto chan = getApp()->twitch->getChannelOrEmpty(
auto chan = getIApp()->getTwitchAbstract()->getChannelOrEmpty(
channelMap[Platform::Twitch].raw()[i]);
if (chan->isEmpty())
{
@@ -202,7 +202,7 @@ void NotificationController::checkStream(bool live, QString channelName)
}
MessageBuilder builder;
TwitchMessageBuilder::liveMessage(channelName, &builder);
getApp()->twitch->liveChannel->addMessage(builder.release());
getIApp()->getTwitch()->getLiveChannel()->addMessage(builder.release());
// Indicate that we have pushed notifications for this stream
fakeTwitchChannels.push_back(channelName);
@@ -217,7 +217,7 @@ void NotificationController::removeFakeChannel(const QString channelName)
fakeTwitchChannels.erase(it);
// "delete" old 'CHANNEL is live' message
LimitedQueueSnapshot<MessagePtr> snapshot =
getApp()->twitch->liveChannel->getMessageSnapshot();
getIApp()->getTwitch()->getLiveChannel()->getMessageSnapshot();
int snapshotLength = snapshot.size();
// MSVC hates this code if the parens are not there
+2 -2
View File
@@ -300,7 +300,7 @@ int ChannelRef::get_by_name(lua_State *L)
lua_pushnil(L);
return 1;
}
auto chn = getApp()->twitch->getChannelOrEmpty(name);
auto chn = getIApp()->getTwitchAbstract()->getChannelOrEmpty(name);
lua::push(L, chn);
return 1;
}
@@ -324,7 +324,7 @@ int ChannelRef::get_by_twitch_id(lua_State *L)
lua_pushnil(L);
return 1;
}
auto chn = getApp()->twitch->getChannelOrEmptyByID(id);
auto chn = getIApp()->getTwitch()->getChannelOrEmptyByID(id);
lua::push(L, chn);
return 1;