mirror-chatterino2/src/providers/twitch/TwitchEmotes.hpp

53 lines
1.1 KiB
C++
Raw Normal View History

#pragma once
2018-08-13 13:54:39 +02:00
#include <QColor>
#include <QRegularExpression>
2018-08-02 14:23:27 +02:00
#include <QString>
#include <unordered_map>
#include "common/Aliases.hpp"
2018-08-02 14:23:27 +02:00
#include "common/UniqueAccess.hpp"
#include <memory>
// NB: "default" can be replaced with "static" to always get a non-animated
// variant
2018-08-06 21:17:03 +02:00
#define TWITCH_EMOTE_TEMPLATE \
"https://static-cdn.jtvnw.net/emoticons/v2/{id}/default/dark/{scale}"
namespace chatterino {
struct Emote;
using EmotePtr = std::shared_ptr<const Emote>;
2018-08-13 13:54:39 +02:00
struct CheerEmote {
QColor color;
int minBits;
QRegularExpression regex;
2018-08-13 13:54:39 +02:00
EmotePtr animatedEmote;
EmotePtr staticEmote;
};
struct CheerEmoteSet {
QRegularExpression regex;
std::vector<CheerEmote> cheerEmotes;
};
class TwitchEmotes
{
public:
static QString cleanUpEmoteCode(const QString &dirtyEmoteCode);
TwitchEmotes();
2018-08-02 14:23:27 +02:00
EmotePtr getOrCreateEmote(const EmoteId &id, const EmoteName &name);
private:
2019-08-13 13:02:11 +02:00
Url getEmoteLink(const EmoteId &id, const QString &emoteScale);
2018-08-06 21:17:03 +02:00
UniqueAccess<std::unordered_map<EmoteId, std::weak_ptr<Emote>>>
twitchEmotesCache_;
2019-08-13 13:02:11 +02:00
std::mutex mutex_;
};
} // namespace chatterino