summaryrefslogtreecommitdiff
path: root/bot/src/github.hpp
blob: 80147068a1d78219d5974d860470f279e10b85eb (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
#pragma once

#include <string>
#include <unordered_map>
#include <vector>

#include "config.hpp"
#include "irc/client.hpp"

namespace bot {
  struct Commit {
      std::string sha;
      std::string commiter_name;
      std::string message;
  };

  class GithubListener {
    public:
      GithubListener(const Configuration &configuration,
                     irc::Client &irc_client)
          : configuration(configuration), irc_client(irc_client){};
      ~GithubListener(){};

      void run();

    private:
      void check_for_listeners();
      std::unordered_map<std::string, std::vector<Commit>> check_new_commits();
      void notify_about_commits(
          const std::unordered_map<std::string, std::vector<Commit>>
              &new_commits);

      std::vector<std::string> ids;
      std::unordered_map<std::string, std::vector<std::string>> commits;

      irc::Client &irc_client;
      const Configuration &configuration;
  };
}