Skip to content

Commit

Permalink
fixes for riot id changes
Browse files Browse the repository at this point in the history
  • Loading branch information
KebsCS committed Nov 21, 2023
1 parent c6543ee commit b85865e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 20 deletions.
1 change: 1 addition & 0 deletions KBotExt/Definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ enum QueueID
BlindPick = 430,
Flex = 440,
ARAM = 450,
Quickplay = 490,
Clash = 700,
IntroBots = 830,
BeginnerBots = 840,
Expand Down
23 changes: 6 additions & 17 deletions KBotExt/GameTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class GameTab

ImGui::Columns(4, nullptr, false);

if (ImGui::Button("Blind pick"))
gameID = BlindPick;
if (ImGui::Button("Quickplay"))
gameID = Quickplay;

if (ImGui::Button("Draft pick"))
gameID = DraftPick;
Expand Down Expand Up @@ -293,9 +293,10 @@ class GameTab
body = custom;
custom = "";
}
if (gameID == DraftPick || gameID == SoloDuo || gameID == Flex)
if (gameID == DraftPick || gameID == SoloDuo || gameID == Flex || gameID == Quickplay)
{
result = LCU::Request("POST", "https://127.0.0.1/lol-lobby/v2/lobby", body);

LCU::Request("PUT", "/lol-lobby/v1/lobby/members/localMember/position-preferences",
R"({"firstPreference":")" + firstPosition[S.gameTab.indexFirstRole]
+ R"(","secondPreference":")" + secondPosition[S.gameTab.indexSecondRole] + "\"}");
Expand All @@ -305,18 +306,6 @@ class GameTab
result = LCU::Request("POST", "https://127.0.0.1/lol-lobby/v2/lobby", body);
}

//for (int i = 0; i < 10001; i++)
//{
// std::string res =
// R"({"customGameLobby":{"configuration":{"gameMode":"CLASSIC","gameMutator":"","gameServerRegion":"","mapId":11,"mutators":{"id":)"
// + std::to_string(i) +
// R"(},"spectatorPolicy":"AllAllowed","teamSize":5},"lobbyName":"KBot","lobbyPassword":null},"isCustom":true})";
// if (std::string xdd = http.Request("POST", "https://127.0.0.1/lol-lobby/v2/lobby", res, auth->leagueHeader, "", "", clientPort);
// xdd.find("errorCode") == std::string::npos)
// std::cout << i << std::endl;
// std::this_thread::sleep_for(std::chrono::milliseconds(10));
//}

gameID = 0;
}

Expand Down Expand Up @@ -1461,7 +1450,7 @@ class GameTab
std::string summoner = LCU::Request("GET", "https://127.0.0.1/lol-summoner/v1/summoners/" + summId);
if (reader->parse(summoner.c_str(), summoner.c_str() + static_cast<int>(summoner.length()), &rootSummoner, &err))
{
summNames += Utils::StringToWstring(rootSummoner["internalName"].asString()) + L",";
summNames += Utils::StringToWstring(rootSummoner["gameName"].asString()) + L"%23" + Utils::StringToWstring(rootSummoner["tagLine"].asString()) + L",";
}
}
}
Expand All @@ -1483,7 +1472,7 @@ class GameTab
{
for (auto& i : participantsArr)
{
summNames += Utils::StringToWstring(i["name"].asString()) + L",";
summNames += Utils::StringToWstring(i["game_name"].asString()) + L"%23" + Utils::StringToWstring(i["game_tag"].asString()) + L",";
}
}
}
Expand Down
36 changes: 34 additions & 2 deletions KBotExt/InfoTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class InfoTab
static std::string accID;
static std::string summID;
static std::string summName;
static std::string gameName;
static std::string tagLine;

static char playerName[50];
if (once)
Expand All @@ -37,7 +39,35 @@ class InfoTab
std::string tempName = std::string(playerName);
tempName.erase(std::remove_if(tempName.begin(), tempName.end(),
[](unsigned char x) { return std::isspace(x); }), tempName.end());

size_t found;
while ((found = tempName.find("#")) != std::string::npos)
{
tempName.replace(found, 1, "%23");
}

result = LCU::Request("GET", "https://127.0.0.1/lol-summoner/v1/summoners?name=" + tempName);

// 2nd method
/*auto riotId = Utils::StringSplit(tempName, "#");
if (riotId.size() > 1)
{
result = LCU::Request("GET", "https://127.0.0.1/lol-summoner/v1/alias/lookup?gameName=" + riotId[0] + "&tagLine=" + riotId[1]);
Json::CharReaderBuilder builder;
const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
JSONCPP_STRING err;
Json::Value root;
if (reader->parse(result.c_str(), result.c_str() + static_cast<int>(result.length()), &root, &err))
{
std::string puuid = root["puuid"].asString();
if (puuid != "")
{
result = LCU::Request("GET", "https://127.0.0.1/lol-summoner/v1/summoners-by-puuid-cached/" + puuid);
}
}
}*/

bPressed = true;
}

Expand Down Expand Up @@ -90,6 +120,8 @@ class InfoTab
accID = std::to_string(root["accountId"].asUInt64());
summID = std::to_string(root["summonerId"].asUInt64());
summName = root["internalName"].asString();
gameName = root["gameName"].asString();
tagLine = root["tagLine"].asString();

sResultJson = Json::writeString(wBuilder, root); // "CppRedundantQualifier"
}
Expand Down Expand Up @@ -134,8 +166,8 @@ class InfoTab
ImGui::SameLine();
if (ImGui::Button("Invite to friends##infoTab"))
{
std::string invite = R"({"name":")" + summName + R"("})";
LCU::Request("POST", "https://127.0.0.1/lol-chat/v1/friend-requests", invite);
std::string invite = R"({"gameName":")" + gameName + R"(","tagLine":")" + tagLine + R"("})";
LCU::Request("POST", "https://127.0.0.1/lol-chat/v2/friend-requests", invite);
}
ImGui::SameLine();
if (ImGui::Button("Add to block list##infoTab"))
Expand Down
2 changes: 1 addition & 1 deletion KBotExt/LCU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void LCU::GetLeagueProcesses()

if (reader->parse(currentSummoner.c_str(), currentSummoner.c_str() + static_cast<int>(currentSummoner.length()), &root, &err))
{
leagueProcesses[currentIndex].second = std::string(root["displayName"].asString().substr(0, 25));
leagueProcesses[currentIndex].second = std::string(root["gameName"].asString().substr(0, 25)) + "#" + std::string(root["tagLine"].asString());
break;
}
}
Expand Down

0 comments on commit b85865e

Please sign in to comment.