This repository has been archived on 2025-03-15. You can view files and clone it, but cannot push or open issues or pull requests.
sparkle/libs/api/Channel.hpp

23 lines
636 B
C++
Raw Normal View History

2024-12-31 02:20:56 +05:00
#ifndef API_CHANNEL_HPP_
#define API_CHANNEL_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;
class Channel {
private:
json data;
WebSocket& web;
NetworkManager& req;
public:
2024-12-31 04:46:39 +05:00
Channel(const json& data) : data(data), web(*WebSocket::getInstance()), req(*NetworkManager::getInstance()) {}
2024-12-31 02:20:56 +05:00
string send(const json& msg) const {
2024-12-31 05:58:15 +05:00
return req.request("POST", dapi + "/channels/" + data["d"]["channel_id"].get<string>() + "/messages", msg.dump());
2024-12-31 02:20:56 +05:00
}
};
#endif