forked from rcxpony/sparkle
36 lines
827 B
C++
36 lines
827 B
C++
#ifndef API_USER_HPP_
|
|
#define API_USER_HPP_
|
|
#include <json.hpp>
|
|
#include <string>
|
|
#include <exception>
|
|
#include <iostream>
|
|
#include <tls/network.hpp>
|
|
#include <gateway/websocket.hpp>
|
|
#include <utils/types.hpp>
|
|
using std::string;
|
|
using std::cout;
|
|
using std::endl;
|
|
using json = nlohmann::json;
|
|
class User {
|
|
private:
|
|
json data;
|
|
WebSocket& web;
|
|
NetworkManager& req;
|
|
public:
|
|
User(const json& data) : data(data), web(*WebSocket::getInstance()), req(*NetworkManager::getInstance()) {}
|
|
string id() {
|
|
return data["d"]["author"]["id"];
|
|
}
|
|
string me() const {
|
|
return req.request("GET", dapi + "/users/@me", "");
|
|
}
|
|
bool isBot() {
|
|
try {
|
|
return data["d"]["author"]["bot"];
|
|
}
|
|
catch (std::exception& e) {
|
|
return false;
|
|
}
|
|
}
|
|
};
|
|
#endif |