2025-01-15 13:34:41 +05:00
|
|
|
#include <api.h>
|
|
|
|
#include <includes.h>
|
2024-12-31 04:46:39 +05:00
|
|
|
int main(int argc, char* argv[]) {
|
2025-01-13 14:40:21 +05:00
|
|
|
if (argc != 3) return -1;
|
2025-01-18 05:42:08 +05:00
|
|
|
WebSocket* bot = &WebSocket::getInstance(argv[2], GatewayIntents::AllIntents, false);
|
2025-01-18 01:01:19 +05:00
|
|
|
bot->on(GatewayEvents::READY, [](const Bot<Message, User, Author>& msg) {
|
2025-01-18 05:42:08 +05:00
|
|
|
std::string lastID = "1292591828888977589";
|
|
|
|
while (true) {
|
|
|
|
std::vector<std::string> ids;
|
|
|
|
std::cout << "Last ID: " << lastID << std::endl;
|
|
|
|
json js = json::parse(g(0, msg.net)->getMessages("956854968260890654", "100", lastID));
|
|
|
|
if (js.is_array() && !js.empty()) {
|
|
|
|
for (const auto& message : js) {
|
|
|
|
if (message["author"]["id"] == "956790566463614986") {
|
|
|
|
std::cout << "My message ID: " << message["id"].get<std::string>() << std::endl;
|
|
|
|
ids.push_back(message["id"].get<std::string>());
|
|
|
|
}
|
|
|
|
lastID = message["id"].get<std::string>();
|
|
|
|
}
|
|
|
|
if (ids.size() > 1) {
|
|
|
|
for (size_t x = 0; x < ids.size(); x++) {
|
|
|
|
try {
|
|
|
|
json jss = json::parse(g(0, msg.net)->deleteMessage("956854968260890654", ids[x]));
|
|
|
|
if (jss["code"].get<string>() == "20028") {
|
|
|
|
std::this_thread::sleep_for(10s);
|
|
|
|
}
|
|
|
|
std::cout << "Delete response: " << jss["message"] << ":" << jss["code"] << std::endl;
|
|
|
|
}
|
|
|
|
catch (...) {
|
|
|
|
std::cout << "DELETED" << std::endl;
|
|
|
|
}
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
std::cout << "No messages found or error in response." << std::endl;
|
|
|
|
}
|
|
|
|
//std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
2025-01-18 00:13:18 +05:00
|
|
|
}
|
|
|
|
});
|
2024-12-31 02:20:56 +05:00
|
|
|
bot->start();
|
|
|
|
return 0;
|
2025-01-18 05:42:08 +05:00
|
|
|
}
|