summaryrefslogtreecommitdiff
path: root/bot/src/schemas/stream.cpp
blob: d4f769bc9ab9f218ce8f5c1d146ebc922b374f1f (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "stream.hpp"

namespace bot::schemas {
  EventType string_to_event_type(const std::string &type) {
    if (type == "live") {
      return EventType::LIVE;
    } else if (type == "offline") {
      return EventType::OFFLINE;
    } else if (type == "title") {
      return EventType::TITLE;
    } else if (type == "game") {
      return EventType::GAME;
    } else if (type == "github") {
      return EventType::GITHUB;
    } else if (type == "7tv_emote_add") {
      return EventType::STV_EMOTE_CREATE;
    } else if (type == "7tv_emote_delete") {
      return EventType::STV_EMOTE_DELETE;
    } else if (type == "7tv_emote_update") {
      return EventType::STV_EMOTE_UPDATE;
    } else {
      return EventType::CUSTOM;
    }
  }

  std::string event_type_to_string(const int &type) {
    if (type == LIVE) {
      return "live";
    } else if (type == OFFLINE) {
      return "offline";
    } else if (type == TITLE) {
      return "title";
    } else if (type == GAME) {
      return "game";
    } else if (type == GITHUB) {
      return "github";
    } else if (type == STV_EMOTE_CREATE) {
      return "7tv_emote_add";
    } else if (type == STV_EMOTE_DELETE) {
      return "7tv_emote_delete";
    } else if (type == STV_EMOTE_UPDATE) {
      return "7tv_emote_update";
    } else {
      return "custom";
    }
  }

  std::optional<int> string_to_event_flag(const std::string &type) {
    if (type == "massping") {
      return MASSPING;
    }

    return std::nullopt;
  }

  std::optional<std::string> event_flag_to_string(const int &type) {
    if (type == MASSPING) {
      return "massping";
    }

    return std::nullopt;
  }
}