From b872f83c9e9bbcd13fac1fd6e80d2ad6e7fdda7c Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sun, 26 May 2019 21:48:45 +0200 Subject: [PATCH] add missing files pepega --- src/common/Env.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ src/common/Env.hpp | 19 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 src/common/Env.cpp create mode 100644 src/common/Env.hpp diff --git a/src/common/Env.cpp b/src/common/Env.cpp new file mode 100644 index 000000000..ff711ec47 --- /dev/null +++ b/src/common/Env.cpp @@ -0,0 +1,40 @@ +#include "common/Env.hpp" + +namespace chatterino { + +namespace { + + QString readStringEnv(const char *envName, QString defaultValue) + { + auto envString = std::getenv(envName); + if (envString != nullptr) + { + return QString(envString); + } + + return defaultValue; + } + +} // namespace + +Env::Env() + : recentMessagesApiUrl( + readStringEnv("CHATTERINO2_RECENT_MESSAGES_URL", + "https://recent-messages.robotty.de/api/v2/" + "recent-messages/%1?clearchatToNotice=true")) + , linkResolverUrl(readStringEnv( + "CHATTERINO2_LINK_RESOLVER_URL", + "https://braize.pajlada.com/chatterino/link_resolver/%1")) + , twitchEmoteSetResolverUrl(readStringEnv( + "CHATTERINO2_TWITCH_EMOTE_SET_RESOLVER_URL", + "https://braize.pajlada.com/chatterino/twitchemotes/set/%1/")) +{ +} + +const Env &Env::get() +{ + static Env instance; + return instance; +} + +} // namespace chatterino diff --git a/src/common/Env.hpp b/src/common/Env.hpp new file mode 100644 index 000000000..2dc7fa1ba --- /dev/null +++ b/src/common/Env.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include + +namespace chatterino { + +class Env +{ + Env(); + +public: + static const Env &get(); + + const QString recentMessagesApiUrl; + const QString linkResolverUrl; + const QString twitchEmoteSetResolverUrl; +}; + +} // namespace chatterino