mirror-chatterino2/src/providers/bttv/BttvEmotes.hpp

35 lines
869 B
C++
Raw Normal View History

2018-06-05 17:39:49 +02:00
#pragma once
2018-08-02 14:23:27 +02:00
#include <memory>
#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 {
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 =
2019-09-03 23:32:22 +02:00
"https://api.betterttv.net/3/cached/emotes/global";
2018-08-11 17:15:17 +02:00
static constexpr const char *bttvChannelEmoteApiUrl =
2019-09-03 11:27:30 +02:00
"https://api.betterttv.net/3/cached/users/twitch/";
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
std::shared_ptr<const EmoteMap> emotes() const;
boost::optional<EmotePtr> emote(const EmoteName &name) const;
void loadEmotes();
2019-09-03 11:27:30 +02:00
static void loadChannel(const QString &channelId,
2018-08-11 17:15:17 +02:00
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