summaryrefslogtreecommitdiff
path: root/src/stream.hpp
blob: 7701cb3a7a6b1798d54faf4a4679fbe1c92b8d9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once

#include <set>
#include <vector>

#include "api/twitch/helix_client.hpp"
#include "api/twitch/schemas/stream.hpp"
#include "config.hpp"
#include "irc/client.hpp"
#include "schemas/stream.hpp"

namespace bot::stream {
  class StreamListenerClient {
    public:
      StreamListenerClient(const api::twitch::HelixClient &helix_client,
                           irc::Client &irc_client,
                           const Configuration &configuration)
          : helix_client(helix_client),
            irc_client(irc_client),
            configuration(configuration){};
      ~StreamListenerClient() = default;

      void run_thread();

      void listen_channel(const int &id);
      void unlisten_channel(const int &id);

    private:
      void run();
      void check();
      void handler(const schemas::EventType &type,
                   const api::twitch::schemas::Stream &stream);

      const api::twitch::HelixClient &helix_client;
      irc::Client &irc_client;
      const Configuration &configuration;

      std::vector<int> ids;

      std::set<int> online_ids;
  };
}