Add ability to easily swap out the recent messages API with your own

Environment variable: CHATTERINO2_RECENT_MESSAGES_URL

For now, the API structure of the recent messages API is undocumented,
    but once it's released it will have some documentation that
    describes how to run it yourself, and it should be easy enough to
    just make your own API that fits
This commit is contained in:
Rasmus Karlsson 2019-04-13 19:23:11 +02:00
parent 8b3867fa7d
commit de4bc02b66

View file

@ -604,8 +604,17 @@ Outcome TwitchChannel::parseLiveStatus(const rapidjson::Document &document)
void TwitchChannel::loadRecentMessages()
{
static QString genericURL = "https://recent-messages.robotty.de/api/v2/"
"recent-messages/%1?clearchatToNotice=true";
static QString genericURL = [] {
QString url("https://recent-messages.robotty.de/api/v2/recent-messages/"
"%1?clearchatToNotice=true");
auto envString = std::getenv("CHATTERINO2_RECENT_MESSAGES_URL");
if (envString != nullptr)
{
url = envString;
}
return url;
}();
NetworkRequest request(genericURL.arg(this->getName()));
request.setCaller(QThread::currentThread());