summaryrefslogtreecommitdiff
path: root/src/api/twitch/helix_client.cpp
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-05-02 00:11:09 +0500
committerilotterytea <iltsu@alright.party>2024-05-02 00:11:09 +0500
commit0e20d75f3dcd12cc0c66c321684eadbed1513a9f (patch)
treec5a2c511d6453fe493b667525d3ed625c03156d9 /src/api/twitch/helix_client.cpp
parent64ee8f8e7639c1e84a7e68d45e2aceec5299a4d6 (diff)
feat: method for getting chatter list
Diffstat (limited to 'src/api/twitch/helix_client.cpp')
-rw-r--r--src/api/twitch/helix_client.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/api/twitch/helix_client.cpp b/src/api/twitch/helix_client.cpp
index c5031f0..ceac720 100644
--- a/src/api/twitch/helix_client.cpp
+++ b/src/api/twitch/helix_client.cpp
@@ -75,4 +75,31 @@ namespace bot::api::twitch {
return users;
}
+
+ std::vector<schemas::User> HelixClient::get_chatters(
+ const int &broadcaster_id, const int &moderator_id) const {
+ cpr::Response response =
+ cpr::Get(cpr::Url{this->base_url + "/chat/chatters?broadcaster_id=" +
+ std::to_string(broadcaster_id) +
+ "&moderator_id=" + std::to_string(moderator_id)},
+ cpr::Bearer{this->token},
+ cpr::Header{{"Client-Id", this->client_id.c_str()}});
+
+ if (response.status_code != 200) {
+ return {};
+ }
+
+ std::vector<schemas::User> users;
+
+ nlohmann::json j = nlohmann::json::parse(response.text);
+
+ for (const auto &d : j["data"]) {
+ schemas::User u{std::stoi(d["user_id"].get<std::string>()),
+ d["user_login"]};
+
+ users.push_back(u);
+ }
+
+ return users;
+ }
}