Compare commits
2 Commits
master
...
isitdown_i
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7c5f0bcf9b | ||
![]() |
da31d69f70 |
@ -2,6 +2,7 @@ import logging
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
import discord
|
||||||
from redbot.core import Config, commands
|
from redbot.core import Config, commands
|
||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
|
|
||||||
@ -46,6 +47,43 @@ class IsItDown(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
await ctx.maybe_send_embed(f"{url_to_check} is UP!")
|
await ctx.maybe_send_embed(f"{url_to_check} is UP!")
|
||||||
|
|
||||||
|
@commands.admin()
|
||||||
|
@commands.command(alias=["iidmonitor"])
|
||||||
|
async def isitdownmonitor(self, ctx: commands.Context, announce_channel: discord.TextChannel,
|
||||||
|
url_to_check):
|
||||||
|
"""
|
||||||
|
Add a continuous monitoring for a url and a channel to post updates in.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
resp = await self._check_if_down(url_to_check)
|
||||||
|
except AssertionError:
|
||||||
|
await ctx.maybe_send_embed("Invalid URL provided. Make sure not to include `http://`")
|
||||||
|
return
|
||||||
|
|
||||||
|
async with self.config.guild(ctx.guild).iids() as iids:
|
||||||
|
iids.append((announce_channel.id, url_to_check))
|
||||||
|
|
||||||
|
await ctx.maybe_send_embed(
|
||||||
|
f"{announce_channel.mention} will now receive alerts when the status of {url_to_check} changes")
|
||||||
|
|
||||||
|
@commands.admin()
|
||||||
|
@commands.command(alias=["iidlist"])
|
||||||
|
async def isitdownlist(self, ctx: commands.Context):
|
||||||
|
"""
|
||||||
|
List all checks that have been setup across all guilds
|
||||||
|
"""
|
||||||
|
if not await self.config.guild(ctx.guild).iids():
|
||||||
|
await ctx.maybe_send_embed("No urls are configured to be checked")
|
||||||
|
|
||||||
|
em = discord.Embed("")
|
||||||
|
|
||||||
|
@commands.admin()
|
||||||
|
@commands.command(alias=["iidclear"])
|
||||||
|
async def isitdownclear(self, ctx: commands.Context):
|
||||||
|
"""
|
||||||
|
Clear all checks that have been setup across all guilds
|
||||||
|
"""
|
||||||
|
|
||||||
async def _check_if_down(self, url_to_check):
|
async def _check_if_down(self, url_to_check):
|
||||||
url = re.compile(r"https?://(www\.)?")
|
url = re.compile(r"https?://(www\.)?")
|
||||||
url.sub("", url_to_check).strip().strip("/")
|
url.sub("", url_to_check).strip().strip("/")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user