Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions twitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,6 @@ static size_t CurlWriteCallback(void *contents, size_t size, size_t nmemb,
return size * nmemb;
}

bool Twitch::isOnline(std::string username, std::string channel) {
CURLcode res;
std::string channelUrl = "https://tmi.twitch.tv/group/user/";
channelUrl += channel;
channelUrl += "/chatters";

std::string response;

CURL *curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, channelUrl.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
res = curl_easy_perform(curl);
if (res != CURLE_OK) {
std::cerr << "Oh no! curl_easy_perform() failed: "
<< curl_easy_strerror(res) << std::endl;
}
curl_easy_cleanup(curl);
}

// This is a nasty hack.
return response.find(username) != response.npos;
}

std::set<std::string> Twitch::getOnlineUsers(const std::string& channel) {
CURLcode res;
std::string channelUrl = "https://tmi.twitch.tv/group/user/";
Expand Down
1 change: 0 additions & 1 deletion twitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

class Twitch {
public:
bool isOnline(std::string username, std::string channel);
std::set<std::string> getOnlineUsers(const std::string& channel);
void placeStreamMarker();

Expand Down