-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from Its-Haze/fix/broken-riot-id-change-patch-…
…14-10 Fix leagueRPC to work on patch 14.10 API
- Loading branch information
Showing
4 changed files
with
23 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,33 @@ | ||
from typing import Any | ||
|
||
import urllib3 | ||
|
||
from league_rpc.utils.polling import wait_until_exists | ||
|
||
urllib3.disable_warnings() | ||
|
||
|
||
def get_summoner_name(with_discriminator: bool = False) -> str: | ||
def get_riot_id(without_discriminator: bool = False) -> str: | ||
""" | ||
Gets the current summoner name. | ||
if with_discriminator is True, the function will return a summoners name with #EUW / #EUNE etc | ||
Defaults to not include it. | ||
if without_discriminator is True, the function will not return a summoners name with #EUW / #EUNE etc | ||
Defaults to include it. | ||
""" | ||
url = "https://127.0.0.1:2999/liveclientdata/activeplayername" | ||
|
||
url = "https://127.0.0.1:2999/liveclientdata/playerlist" | ||
if response := wait_until_exists( | ||
url=url, | ||
custom_message=""" | ||
Summoner name could not be found. | ||
Contact @haze.dev on discord, or submit a ticket on Github. | ||
""", | ||
): | ||
name = str(response.json()) | ||
return name if with_discriminator else name.split("#", maxsplit=1)[0] | ||
_response: list[dict[str, Any]] = response.json() | ||
name_without_discriminator = _response[0]["riotIdGameName"] | ||
riot_id = _response[0]["riotId"] | ||
|
||
return name_without_discriminator if without_discriminator else riot_id | ||
|
||
return "" |