Chatterino
SeventvEmotes.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "boost/optional.hpp"
4 #include "common/Aliases.hpp"
5 #include "common/Atomic.hpp"
8 
9 #include <memory>
10 
11 namespace chatterino {
12 
13 // https://github.com/SevenTV/API/blob/a84e884b5590dbb5d91a5c6b3548afabb228f385/data/model/emote-set.model.go#L29-L36
14 enum class SeventvActiveEmoteFlag : int64_t {
15  None = 0LL,
16 
17  // Emote is zero-width
18  ZeroWidth = (1LL << 0),
19 
20  // Overrides Twitch Global emotes with the same name
21  OverrideTwitchGlobal = (1 << 16),
22  // Overrides Twitch Subscriber emotes with the same name
23  OverrideTwitchSubscriber = (1 << 17),
24  // Overrides BetterTTV emotes with the same name
25  OverrideBetterTTV = (1 << 18),
26 };
27 
28 // https://github.com/SevenTV/API/blob/a84e884b5590dbb5d91a5c6b3548afabb228f385/data/model/emote.model.go#L57-L70
29 enum class SeventvEmoteFlag : int64_t {
30  None = 0LL,
31  // The emote is private and can only be accessed by its owner, editors and moderators
32  Private = 1 << 0,
33  // The emote was verified to be an original creation by the uploader
34  Authentic = (1LL << 1),
35  // The emote is recommended to be enabled as Zero-Width
36  ZeroWidth = (1LL << 8),
37 
38  // Content Flags
39 
40  // Sexually Suggesive
41  ContentSexual = (1LL << 16),
42  // Rapid flashing
43  ContentEpilepsy = (1LL << 17),
44  // Edgy or distasteful, may be offensive to some users
45  ContentEdgy = (1 << 18),
46  // Not allowed specifically on the Twitch platform
47  ContentTwitchDisallowed = (1LL << 24),
48 };
49 
52 
53 struct Emote;
54 using EmotePtr = std::shared_ptr<const Emote>;
55 class EmoteMap;
56 
57 class SeventvEmotes final
58 {
59 public:
60  struct ChannelInfo {
61  QString userID;
62  QString emoteSetID;
64  };
65 
66  SeventvEmotes();
67 
68  std::shared_ptr<const EmoteMap> globalEmotes() const;
69  boost::optional<EmotePtr> globalEmote(const EmoteName &name) const;
70  void loadGlobalEmotes();
71  static void loadChannelEmotes(
72  const std::weak_ptr<Channel> &channel, const QString &channelId,
73  std::function<void(EmoteMap &&, ChannelInfo)> callback,
74  bool manualRefresh);
75 
83  static boost::optional<EmotePtr> addEmote(
84  Atomic<std::shared_ptr<const EmoteMap>> &map,
85  const SeventvEventAPIEmoteAddDispatch &dispatch);
86 
94  static boost::optional<EmotePtr> updateEmote(
95  Atomic<std::shared_ptr<const EmoteMap>> &map,
96  const SeventvEventAPIEmoteUpdateDispatch &dispatch);
97 
105  static boost::optional<EmotePtr> removeEmote(
106  Atomic<std::shared_ptr<const EmoteMap>> &map,
107  const SeventvEventAPIEmoteRemoveDispatch &dispatch);
108 
110  static void getEmoteSet(
111  const QString &emoteSetId,
112  std::function<void(EmoteMap &&, QString)> successCallback,
113  std::function<void(QString)> errorCallback);
114 
115 private:
117 };
118 
119 } // namespace chatterino
SeventvEmoteFlag
Definition: SeventvEmotes.hpp:29
Definition: Emote.hpp:14
Definition: Application.cpp:48
Definition: SeventvEventAPIDispatch.hpp:21
QString emoteSetID
Definition: SeventvEmotes.hpp:62
Definition: SeventvEmotes.hpp:57
std::shared_ptr< const Emote > EmotePtr
Definition: Emote.hpp:38
Definition: Emote.hpp:40
Definition: FlagsEnum.hpp:9
QString userID
Definition: SeventvEmotes.hpp:61
Definition: SeventvEventAPIDispatch.hpp:45
size_t twitchConnectionIndex
Definition: SeventvEmotes.hpp:63
QString name
Definition: Credentials.cpp:94
Definition: SeventvEmotes.hpp:60
Definition: SeventvEventAPIDispatch.hpp:33
Definition: Atomic.hpp:9
SeventvActiveEmoteFlag
Definition: SeventvEmotes.hpp:14