Skip to content

Commit b85865e

Browse files
committed
fixes for riot id changes
1 parent c6543ee commit b85865e

File tree

4 files changed

+42
-20
lines changed

4 files changed

+42
-20
lines changed

KBotExt/Definitions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ enum QueueID
7777
BlindPick = 430,
7878
Flex = 440,
7979
ARAM = 450,
80+
Quickplay = 490,
8081
Clash = 700,
8182
IntroBots = 830,
8283
BeginnerBots = 840,

KBotExt/GameTab.h

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ class GameTab
6262

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

65-
if (ImGui::Button("Blind pick"))
66-
gameID = BlindPick;
65+
if (ImGui::Button("Quickplay"))
66+
gameID = Quickplay;
6767

6868
if (ImGui::Button("Draft pick"))
6969
gameID = DraftPick;
@@ -293,9 +293,10 @@ class GameTab
293293
body = custom;
294294
custom = "";
295295
}
296-
if (gameID == DraftPick || gameID == SoloDuo || gameID == Flex)
296+
if (gameID == DraftPick || gameID == SoloDuo || gameID == Flex || gameID == Quickplay)
297297
{
298298
result = LCU::Request("POST", "https://127.0.0.1/lol-lobby/v2/lobby", body);
299+
299300
LCU::Request("PUT", "/lol-lobby/v1/lobby/members/localMember/position-preferences",
300301
R"({"firstPreference":")" + firstPosition[S.gameTab.indexFirstRole]
301302
+ R"(","secondPreference":")" + secondPosition[S.gameTab.indexSecondRole] + "\"}");
@@ -305,18 +306,6 @@ class GameTab
305306
result = LCU::Request("POST", "https://127.0.0.1/lol-lobby/v2/lobby", body);
306307
}
307308

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

@@ -1461,7 +1450,7 @@ class GameTab
14611450
std::string summoner = LCU::Request("GET", "https://127.0.0.1/lol-summoner/v1/summoners/" + summId);
14621451
if (reader->parse(summoner.c_str(), summoner.c_str() + static_cast<int>(summoner.length()), &rootSummoner, &err))
14631452
{
1464-
summNames += Utils::StringToWstring(rootSummoner["internalName"].asString()) + L",";
1453+
summNames += Utils::StringToWstring(rootSummoner["gameName"].asString()) + L"%23" + Utils::StringToWstring(rootSummoner["tagLine"].asString()) + L",";
14651454
}
14661455
}
14671456
}
@@ -1483,7 +1472,7 @@ class GameTab
14831472
{
14841473
for (auto& i : participantsArr)
14851474
{
1486-
summNames += Utils::StringToWstring(i["name"].asString()) + L",";
1475+
summNames += Utils::StringToWstring(i["game_name"].asString()) + L"%23" + Utils::StringToWstring(i["game_tag"].asString()) + L",";
14871476
}
14881477
}
14891478
}

KBotExt/InfoTab.h

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class InfoTab
1919
static std::string accID;
2020
static std::string summID;
2121
static std::string summName;
22+
static std::string gameName;
23+
static std::string tagLine;
2224

2325
static char playerName[50];
2426
if (once)
@@ -37,7 +39,35 @@ class InfoTab
3739
std::string tempName = std::string(playerName);
3840
tempName.erase(std::remove_if(tempName.begin(), tempName.end(),
3941
[](unsigned char x) { return std::isspace(x); }), tempName.end());
42+
43+
size_t found;
44+
while ((found = tempName.find("#")) != std::string::npos)
45+
{
46+
tempName.replace(found, 1, "%23");
47+
}
48+
4049
result = LCU::Request("GET", "https://127.0.0.1/lol-summoner/v1/summoners?name=" + tempName);
50+
51+
// 2nd method
52+
/*auto riotId = Utils::StringSplit(tempName, "#");
53+
if (riotId.size() > 1)
54+
{
55+
result = LCU::Request("GET", "https://127.0.0.1/lol-summoner/v1/alias/lookup?gameName=" + riotId[0] + "&tagLine=" + riotId[1]);
56+
57+
Json::CharReaderBuilder builder;
58+
const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
59+
JSONCPP_STRING err;
60+
Json::Value root;
61+
if (reader->parse(result.c_str(), result.c_str() + static_cast<int>(result.length()), &root, &err))
62+
{
63+
std::string puuid = root["puuid"].asString();
64+
if (puuid != "")
65+
{
66+
result = LCU::Request("GET", "https://127.0.0.1/lol-summoner/v1/summoners-by-puuid-cached/" + puuid);
67+
}
68+
}
69+
}*/
70+
4171
bPressed = true;
4272
}
4373

@@ -90,6 +120,8 @@ class InfoTab
90120
accID = std::to_string(root["accountId"].asUInt64());
91121
summID = std::to_string(root["summonerId"].asUInt64());
92122
summName = root["internalName"].asString();
123+
gameName = root["gameName"].asString();
124+
tagLine = root["tagLine"].asString();
93125

94126
sResultJson = Json::writeString(wBuilder, root); // "CppRedundantQualifier"
95127
}
@@ -134,8 +166,8 @@ class InfoTab
134166
ImGui::SameLine();
135167
if (ImGui::Button("Invite to friends##infoTab"))
136168
{
137-
std::string invite = R"({"name":")" + summName + R"("})";
138-
LCU::Request("POST", "https://127.0.0.1/lol-chat/v1/friend-requests", invite);
169+
std::string invite = R"({"gameName":")" + gameName + R"(","tagLine":")" + tagLine + R"("})";
170+
LCU::Request("POST", "https://127.0.0.1/lol-chat/v2/friend-requests", invite);
139171
}
140172
ImGui::SameLine();
141173
if (ImGui::Button("Add to block list##infoTab"))

KBotExt/LCU.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void LCU::GetLeagueProcesses()
210210

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

0 commit comments

Comments
 (0)