test
This commit is contained in:
parent
eb239115d1
commit
209f2134ae
@ -24,15 +24,18 @@ public:
|
||||
Bot(const json& data) : data(data) {
|
||||
initializeNets(data);
|
||||
}
|
||||
auto& use(const int number) {
|
||||
return *std::get<number>(net);
|
||||
}
|
||||
};
|
||||
class BotHandler : Bot<> {
|
||||
private:
|
||||
json data;
|
||||
public:
|
||||
BotHandler(const json& data) : data(data), Bot(data) {};
|
||||
string id() {
|
||||
return data["d"]["user"]["id"];
|
||||
return data["d"]["id"];
|
||||
}
|
||||
bool isBot() {
|
||||
try {
|
||||
return data["d"]["user"]["bot"];
|
||||
return data["d"]["bot"];
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
return false;
|
||||
|
@ -128,11 +128,10 @@ private:
|
||||
}}
|
||||
}}
|
||||
};
|
||||
using namespace ix;
|
||||
initNetSystem();
|
||||
ix::initNetSystem();
|
||||
webSocket.setUrl("wss://gateway.discord.gg/?v=10&encoding=json");
|
||||
webSocket.setOnMessageCallback([this](const WebSocketMessagePtr& msg) {
|
||||
if (msg->type == WebSocketMessageType::Message) {
|
||||
webSocket.setOnMessageCallback([this](const ix::WebSocketMessagePtr& msg) {
|
||||
if (msg->type == ix::WebSocketMessageType::Message) {
|
||||
res = json::parse(msg->str);
|
||||
res["s"].is_number() ? lastS = res["s"] : false;
|
||||
chngcol(std::string("WEBSOCKET: " + std::to_string(lastS) + " " + res["op"].dump() + " " + res["t"].dump()), 0, 0, 120);
|
||||
|
@ -17,12 +17,12 @@ int main(int argc, char* argv[]) {
|
||||
bot->on(GatewayEvents::READY, [](const Bot<Message>& b) {
|
||||
cout << "started" << endl;
|
||||
});
|
||||
bot->on(GatewayEvents::MESSAGE_CREATE, [bot](const Bot<json, Message, Author, EmbedBuilder>& msg) {
|
||||
if (g(2, msg.net)->isBot() == false) {
|
||||
g(1, msg.net)->send("939957962972229634", j("content", g(2, msg.net)->content()));
|
||||
bot->on(GatewayEvents::MESSAGE_CREATE, [](const Bot<Message, Author, EmbedBuilder>& msg) {
|
||||
if (g(1, msg.net)->isBot() == false) {
|
||||
g(0, msg.net)->send("939957962972229634", j("content", g(1, msg.net)->content()));
|
||||
}
|
||||
});
|
||||
bot->on(GatewayEvents::MESSAGE_REACTION_REMOVE, [bot](const Bot<Message>& msg) {
|
||||
bot->on(GatewayEvents::MESSAGE_REACTION_REMOVE, [](const Bot<Message>& msg) {
|
||||
g(0, msg.net)->send("939957962972229634",
|
||||
j("content", "bye"));
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user