MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / AutoAccept

Method AutoAccept

KBotExt/GameTab.h:1306–1509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1304 }
1305
1306 static void AutoAccept()
1307 {
1308 while (true)
1309 {
1310 std::this_thread::sleep_for(std::chrono::milliseconds(1));
1311
1312 if (FindWindowA("RiotWindowClass", "League of Legends (TM) Client"))
1313 {
1314 // game is running, auto accept is not needed
1315 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
1316 continue;
1317 }
1318
1319 if (!FindWindowA("RCLIENT", "League of Legends"))
1320 {
1321 continue;
1322 }
1323
1324 if (S.gameTab.autoAcceptEnabled || (S.gameTab.autoBanEnabled && S.gameTab.autoBanId) ||
1325 (S.gameTab.dodgeOnBan && S.gameTab.instalockEnabled) ||
1326 (S.gameTab.instalockEnabled && S.gameTab.instalockId) ||
1327 !S.gameTab.instantMessage.empty())
1328 {
1329 Json::Value rootSearch;
1330 Json::Value rootChampSelect;
1331 Json::Value rootSession;
1332 Json::CharReaderBuilder builder;
1333 const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
1334 JSONCPP_STRING err;
1335
1336 cpr::Session session;
1337 session.SetVerifySsl(false);
1338 session.SetHeader(Utils::StringToHeader(LCU::league.header));
1339 session.SetUrl(std::format("https://127.0.0.1:{}/lol-lobby/v2/lobby/matchmaking/search-state", LCU::league.port));
1340
1341 std::string getSearchState = session.Get().text;
1342 if (!reader->parse(getSearchState.c_str(), getSearchState.c_str() + static_cast<int>(getSearchState.length()), &rootSearch, &err))
1343 {
1344 continue;
1345 }
1346
1347 static bool onChampSelect = true; //false when in champ select
1348 static int useBackupId = 0;
1349 static bool isPicked = false;
1350
1351 if (rootSearch["searchState"].asString() != "Found") // not found, not in champ select
1352 {
1353 onChampSelect = true;
1354 useBackupId = 0;
1355 isPicked = false;
1356 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
1357 continue;
1358 }
1359
1360 session.SetUrl(std::format("https://127.0.0.1:{}/lol-champ-select/v1/session", LCU::league.port));
1361 std::string getChampSelect = session.Get().text;
1362 if (getChampSelect.find("RPC_ERROR") != std::string::npos) // game found but champ select error means queue pop
1363 {

Callers

nothing calls this directly

Calls 3

c_strMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected