2021-01-25 16:28:59 +00:00
|
|
|
from discord.ext import commands
|
2021-04-22 16:11:55 +00:00
|
|
|
from discord.ext.commands import Context
|
2021-01-25 16:28:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
def _(x):
|
|
|
|
return x
|
|
|
|
|
|
|
|
|
|
|
|
class IPConverter(commands.Converter):
|
2021-04-22 16:11:55 +00:00
|
|
|
async def convert(self, ctx: Context, argument: str): # skipcq: PYL-W0613
|
2021-01-25 16:28:59 +00:00
|
|
|
argument = argument.replace("http://", "").replace("https://", "")
|
2021-02-11 17:21:50 +00:00
|
|
|
argument = argument.rstrip("/")
|
2021-01-25 16:28:59 +00:00
|
|
|
|
2021-03-02 18:00:08 +00:00
|
|
|
if argument.startswith("`") and argument.endswith("`"):
|
|
|
|
argument = argument.lstrip("`").rstrip("`")
|
2021-01-25 16:28:59 +00:00
|
|
|
|
2021-03-02 18:00:08 +00:00
|
|
|
return argument.lower()
|
2021-01-25 16:28:59 +00:00
|
|
|
|
|
|
|
|
2021-03-02 18:00:08 +00:00
|
|
|
class DomainConverter(commands.Converter):
|
2021-04-22 16:11:55 +00:00
|
|
|
async def convert(self, ctx: Context, argument: str): # skipcq: PYL-W0613
|
2021-01-26 16:11:30 +00:00
|
|
|
if not argument.startswith("http"):
|
|
|
|
return f"http://{argument}"
|
|
|
|
|
|
|
|
return argument
|
|
|
|
|
|
|
|
|
|
|
|
class QueryTypeConverter(commands.Converter):
|
2021-04-22 16:11:55 +00:00
|
|
|
async def convert(self, ctx: Context, argument: str): # skipcq: PYL-W0613
|
2021-03-02 18:00:08 +00:00
|
|
|
return argument.lower()
|
2021-01-26 14:24:10 +00:00
|
|
|
|
|
|
|
|
2021-04-24 20:34:53 +00:00
|
|
|
class IPParamsConverter(commands.Converter):
|
2021-04-22 16:11:55 +00:00
|
|
|
async def convert(self, ctx: Context, argument: str): # skipcq: PYL-W0613
|
2021-01-25 16:28:59 +00:00
|
|
|
if not argument:
|
2021-04-24 20:34:53 +00:00
|
|
|
return None
|
2021-01-25 16:28:59 +00:00
|
|
|
|
2021-04-24 20:34:53 +00:00
|
|
|
params = {
|
|
|
|
"inet": "",
|
|
|
|
"map": "map" in argument.lower(),
|
|
|
|
}
|
|
|
|
|
|
|
|
if "4" in argument:
|
|
|
|
params["inet"] = "4"
|
|
|
|
elif "6" in argument:
|
|
|
|
params["inet"] = "6"
|
|
|
|
elif len(arg := argument.split(" ")) >= 2:
|
|
|
|
params["inet"] = arg[0]
|
|
|
|
|
|
|
|
return params
|
2021-04-22 16:11:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ASConverter(commands.Converter):
|
|
|
|
async def convert(self, ctx: Context, argument: str): # skipcq: PYL-W0613
|
|
|
|
return argument.lower().lstrip("as")
|