Add extra context to messages that are added to channels, allowing the logging controller to take more responsibility in what messages to log (#5499)
Co-auhtored-by: James Upjohn <jupjohn@jammeh.co.nz>
This commit is contained in:
@@ -90,7 +90,7 @@ QString listEnvironmentVariables(const CommandContext &ctx)
|
||||
builder.emplace<TimestampElement>(QTime::currentTime());
|
||||
builder.emplace<TextElement>(str, MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
channel->addMessage(builder.release());
|
||||
channel->addMessage(builder.release(), MessageContext::Original);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ QString testChatters(const CommandContext &ctx)
|
||||
TwitchMessageBuilder::listOfUsersSystemMessage(
|
||||
prefix, entries, twitchChannel, &builder);
|
||||
|
||||
channel->addMessage(builder.release());
|
||||
channel->addMessage(builder.release(), MessageContext::Original);
|
||||
},
|
||||
[channel{ctx.channel}](auto error, auto message) {
|
||||
auto errorMessage = formatChattersError(error, message);
|
||||
|
||||
@@ -81,7 +81,7 @@ QString getModerators(const CommandContext &ctx)
|
||||
TwitchMessageBuilder::listOfUsersSystemMessage(
|
||||
"The moderators of this channel are", result, twitchChannel,
|
||||
&builder);
|
||||
channel->addMessage(builder.release());
|
||||
channel->addMessage(builder.release(), MessageContext::Original);
|
||||
},
|
||||
[channel{ctx.channel}](auto error, auto message) {
|
||||
auto errorMessage = formatModsError(error, message);
|
||||
|
||||
@@ -110,7 +110,7 @@ QString getVIPs(const CommandContext &ctx)
|
||||
TwitchMessageBuilder::listOfUsersSystemMessage(
|
||||
messagePrefix, vipList, twitchChannel, &builder);
|
||||
|
||||
channel->addMessage(builder.release());
|
||||
channel->addMessage(builder.release(), MessageContext::Original);
|
||||
},
|
||||
[channel{ctx.channel}](auto error, auto message) {
|
||||
auto errorMessage = formatGetVIPsError(error, message);
|
||||
|
||||
@@ -177,18 +177,16 @@ bool appendWhisperMessageWordsLocally(const QStringList &words)
|
||||
b->flags.set(MessageFlag::Whisper);
|
||||
auto messagexD = b.release();
|
||||
|
||||
getIApp()->getTwitch()->getWhispersChannel()->addMessage(messagexD);
|
||||
|
||||
auto overrideFlags = std::optional<MessageFlags>(messagexD->flags);
|
||||
overrideFlags->set(MessageFlag::DoNotLog);
|
||||
getIApp()->getTwitch()->getWhispersChannel()->addMessage(
|
||||
messagexD, MessageContext::Original);
|
||||
|
||||
if (getSettings()->inlineWhispers &&
|
||||
!(getSettings()->streamerModeSuppressInlineWhispers &&
|
||||
getIApp()->getStreamerMode()->isEnabled()))
|
||||
{
|
||||
app->getTwitchAbstract()->forEachChannel(
|
||||
[&messagexD, overrideFlags](ChannelPtr _channel) {
|
||||
_channel->addMessage(messagexD, overrideFlags);
|
||||
[&messagexD](ChannelPtr _channel) {
|
||||
_channel->addMessage(messagexD, MessageContext::Repost);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +202,8 @@ void NotificationController::checkStream(bool live, QString channelName)
|
||||
}
|
||||
MessageBuilder builder;
|
||||
TwitchMessageBuilder::liveMessage(channelName, &builder);
|
||||
getIApp()->getTwitch()->getLiveChannel()->addMessage(builder.release());
|
||||
getIApp()->getTwitch()->getLiveChannel()->addMessage(
|
||||
builder.release(), MessageContext::Original);
|
||||
|
||||
// Indicate that we have pushed notifications for this stream
|
||||
fakeTwitchChannels.push_back(channelName);
|
||||
|
||||
@@ -380,8 +380,8 @@ QString PluginController::tryExecPluginCommand(const QString &commandName,
|
||||
auto res = lua_pcall(L, 1, 0, 0);
|
||||
if (res != LUA_OK)
|
||||
{
|
||||
ctx.channel->addMessage(makeSystemMessage(
|
||||
"Lua error: " + lua::humanErrorText(L, res)));
|
||||
ctx.channel->addSystemMessage("Lua error: " +
|
||||
lua::humanErrorText(L, res));
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
|
||||
@@ -200,7 +200,7 @@ int ChannelRef::add_system_message(lua_State *L)
|
||||
}
|
||||
ChannelPtr that = ChannelRef::getOrError(L);
|
||||
text = text.replace('\n', ' ');
|
||||
that->addMessage(makeSystemMessage(text));
|
||||
that->addSystemMessage(text);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user