sparkle/libs/api/User.hpp

34 lines
764 B
C++
Raw Normal View History

2024-12-31 02:20:56 +05:00
#ifndef API_USER_HPP_
#define API_USER_HPP_
2025-01-06 21:57:27 +05:00
#include <utils/types.hpp>
2024-12-31 02:20:56 +05:00
#include <string>
#include <exception>
#include <iostream>
#include <tls/network.hpp>
#include <gateway/websocket.hpp>
using std::string;
using std::cout;
using std::endl;
class User {
private:
json data;
WebSocket& web;
NetworkManager& req;
public:
2024-12-31 04:46:39 +05:00
User(const json& data) : data(data), web(*WebSocket::getInstance()), req(*NetworkManager::getInstance()) {}
2024-12-31 02:20:56 +05:00
string id() {
return data["d"]["author"]["id"];
}
string me() const {
2024-12-31 05:58:15 +05:00
return req.request("GET", dapi + "/users/@me", "");
2024-12-31 02:20:56 +05:00
}
bool isBot() {
try {
return data["d"]["author"]["bot"];
}
2025-01-06 21:57:27 +05:00
catch (...) {
2024-12-31 02:20:56 +05:00
return false;
}
}
};
#endif