Skip to content

Commit

Permalink
Add verification_url property
Browse files Browse the repository at this point in the history
  • Loading branch information
Lekuruu committed Mar 14, 2024
1 parent c01d858 commit 275d5ff
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions osu/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ def __init__(self, game: Game) -> None:

self.url = f"https://osu.{self.game.server}"

@property
def verification_url(self) -> str:
return (
f"{self.url}/p/verify"
f'?u={self.game.username.replace(" ", "%20")}'
f"&reason=bancho"
f"&ch={self.game.client.hash}"
)

def connected_to_bancho(self, *args, **kwargs) -> Callable:
"""Can be used as a class wrapper to ensure that the client is connected"""

Expand Down Expand Up @@ -130,17 +139,15 @@ def connect(self, retry=False) -> bool:
)

if "verify" in response.text:
self.verify(str(self.game.client.hash))
self.verify()
return False

return True

def verify(self, hash: str, exit_after: bool = True) -> None:
def verify(self, exit_after: bool = True) -> None:
"""This will print out a url, where the user can verify this client."""
self.logger.info("Verification required.")
self.logger.info(
f'{self.url}/p/verify?u={self.game.username.replace(" ", "%20")}&reason=bancho&ch={hash}'
)
self.logger.info(self.verification_url)
self.logger.info("You only need to do this once.")

if exit_after:
Expand Down

0 comments on commit 275d5ff

Please sign in to comment.