Chatterino
TwitchEmotes.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <QColor>
4 #include <QRegularExpression>
5 #include <QString>
6 #include <unordered_map>
7 
8 #include "common/Aliases.hpp"
10 
11 #include <memory>
12 
13 // NB: "default" can be replaced with "static" to always get a non-animated
14 // variant
15 #define TWITCH_EMOTE_TEMPLATE \
16  "https://static-cdn.jtvnw.net/emoticons/v2/{id}/default/dark/{scale}"
17 
18 namespace chatterino {
19 struct Emote;
20 using EmotePtr = std::shared_ptr<const Emote>;
21 
22 struct CheerEmote {
23  QColor color;
24  int minBits;
25  QRegularExpression regex;
26 
29 };
30 
31 struct CheerEmoteSet {
32  QRegularExpression regex;
33  std::vector<CheerEmote> cheerEmotes;
34 };
35 
37 {
38 public:
39  virtual ~ITwitchEmotes() = default;
40 
41  virtual EmotePtr getOrCreateEmote(const EmoteId &id,
42  const EmoteName &name) = 0;
43 };
44 
46 {
47 public:
48  static QString cleanUpEmoteCode(const QString &dirtyEmoteCode);
49  TwitchEmotes() = default;
50 
51  EmotePtr getOrCreateEmote(const EmoteId &id,
52  const EmoteName &name) override;
53 
54 private:
55  Url getEmoteLink(const EmoteId &id, const QString &emoteScale);
57  twitchEmotesCache_;
58 };
59 
60 } // namespace chatterino
EmotePtr staticEmote
Definition: TwitchEmotes.hpp:28
Definition: TwitchEmotes.hpp:31
Definition: Application.cpp:48
int minBits
Definition: TwitchEmotes.hpp:24
QRegularExpression regex
Definition: TwitchEmotes.hpp:32
Definition: TwitchEmotes.hpp:22
std::shared_ptr< const Emote > EmotePtr
Definition: Emote.hpp:38
Definition: UniqueAccess.hpp:53
Definition: TwitchEmotes.hpp:45
Definition: TwitchEmotes.hpp:36
std::vector< CheerEmote > cheerEmotes
Definition: TwitchEmotes.hpp:33
QRegularExpression regex
Definition: TwitchEmotes.hpp:25
EmotePtr animatedEmote
Definition: TwitchEmotes.hpp:27
QColor color
Definition: TwitchEmotes.hpp:23
QString name
Definition: Credentials.cpp:94