mirror of
https://github.com/RGBCube/VReplBot
synced 2025-07-27 00:17:46 +00:00
Handle <> links
This commit is contained in:
parent
6d136df3dd
commit
3d4e14347e
1 changed files with 5 additions and 4 deletions
|
@ -28,7 +28,7 @@ class Playground(
|
||||||
async def get_code(self, ctx: Context, query: str) -> str:
|
async def get_code(self, ctx: Context, query: str) -> str:
|
||||||
async with await self.bot.session.post(
|
async with await self.bot.session.post(
|
||||||
f"https://play.vlang.io/query",
|
f"https://play.vlang.io/query",
|
||||||
data = { "hash": query.removesuffix(">") }
|
data = { "hash": query }
|
||||||
) as response:
|
) as response:
|
||||||
text = await response.text()
|
text = await response.text()
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class Playground(
|
||||||
if "play.vlang.io/?query=" not in content:
|
if "play.vlang.io/?query=" not in content:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
query = content.split("play.vlang.io/?query=", 1)[1].split(" ", 1)[0]
|
query = content.split("play.vlang.io/?query=", 1)[1].split(" ", 1)[0].removesuffix(">")
|
||||||
|
|
||||||
if not query: # Empty string.
|
if not query: # Empty string.
|
||||||
return None
|
return None
|
||||||
|
@ -92,10 +92,11 @@ class Playground(
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def extract_link_query(content: str) -> str | None:
|
def extract_link_query(content: str) -> str | None:
|
||||||
if (no_http_content := content.removeprefix("https://")).startswith(
|
if (no_http_content := content.removeprefix("<").removeprefix("https://")).startswith(
|
||||||
"play.vlang.io/?query="
|
"play.vlang.io/?query="
|
||||||
):
|
):
|
||||||
return no_http_content.removeprefix("play.vlang.io/?query=").split(" ", 1)[0]
|
return no_http_content.removeprefix("play.vlang.io/?query=").split(" ", 1)[
|
||||||
|
0].removesuffix(">")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def sanitize(string: str) -> str:
|
def sanitize(string: str) -> str:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue