Skip to content

Commit

Permalink
Switch to isitup.org API
Browse files Browse the repository at this point in the history
  • Loading branch information
bobloy committed Jun 22, 2023
1 parent bc9937b commit c608927
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion isitdown/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Bobloy"
],
"min_bot_version": "3.4.0",
"description": "Check if a website/url is down using the https://isitdown.site/ api",
"description": "Check if a website/url is down using the https://isitup.org// api",
"hidden": false,
"install_msg": "Thank you for installing IsItDown.\nGet started with `[p]load isitdown`, then `[p]help IsItDown`",
"short": "Check if a website/url is down",
Expand Down
10 changes: 6 additions & 4 deletions isitdown/isitdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,21 @@ async def isitdown(self, ctx: commands.Context, url_to_check):
return

# log.debug(resp)
if resp["isitdown"]:
if resp["status_code"] == 2:
await ctx.maybe_send_embed(f"{url} is DOWN!")
else:
elif resp["status_code"] == 1:
await ctx.maybe_send_embed(f"{url} is UP!")
else:
await ctx.maybe_send_embed("Invalid URL provided. Make sure not to include `http://`")

async def _check_if_down(self, url_to_check):
re_compiled = re.compile(r"https?://(www\.)?")
url = re_compiled.sub("", url_to_check).strip().strip("/")

url = f"https://isitdown.site/api/v3/{url}"
url = f"https://isitup.org/{url}"
# log.debug(url)
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
async with session.get(f"{url}.json") as response:
assert response.status == 200
resp = await response.json()
return resp, url

0 comments on commit c608927

Please sign in to comment.