2018-06-05 17:39:49 +02:00
|
|
|
#pragma once
|
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
#include <memory>
|
2018-08-12 00:01:37 +02:00
|
|
|
#include "boost/optional.hpp"
|
|
|
|
#include "common/Aliases.hpp"
|
2018-08-11 14:20:53 +02:00
|
|
|
#include "common/Atomic.hpp"
|
2018-06-05 17:39:49 +02:00
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
2018-08-12 00:01:37 +02:00
|
|
|
struct Emote;
|
|
|
|
using EmotePtr = std::shared_ptr<const Emote>;
|
|
|
|
class EmoteMap;
|
|
|
|
|
2018-08-11 14:20:53 +02:00
|
|
|
class BttvEmotes final
|
2018-06-05 17:39:49 +02:00
|
|
|
{
|
2018-08-06 21:17:03 +02:00
|
|
|
static constexpr const char *globalEmoteApiUrl =
|
|
|
|
"https://api.betterttv.net/2/emotes";
|
2018-08-11 17:15:17 +02:00
|
|
|
static constexpr const char *bttvChannelEmoteApiUrl =
|
|
|
|
"https://api.betterttv.net/2/channels/";
|
2018-08-02 14:23:27 +02:00
|
|
|
|
2018-06-05 17:39:49 +02:00
|
|
|
public:
|
2018-08-11 14:20:53 +02:00
|
|
|
BttvEmotes();
|
2018-06-05 17:39:49 +02:00
|
|
|
|
2018-08-12 00:01:37 +02:00
|
|
|
std::shared_ptr<const EmoteMap> emotes() const;
|
|
|
|
boost::optional<EmotePtr> emote(const EmoteName &name) const;
|
|
|
|
void loadEmotes();
|
2018-08-11 17:15:17 +02:00
|
|
|
static void loadChannel(const QString &channelName,
|
|
|
|
std::function<void(EmoteMap &&)> callback);
|
2018-06-05 17:39:49 +02:00
|
|
|
|
2018-06-07 12:22:28 +02:00
|
|
|
private:
|
2018-08-11 14:20:53 +02:00
|
|
|
Atomic<std::shared_ptr<const EmoteMap>> global_;
|
2018-06-05 17:39:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace chatterino
|