2021-01-25 16:28:59 +00:00
|
|
|
from discord.ext import commands
|
|
|
|
|
|
|
|
|
|
|
|
def _(x):
|
|
|
|
return x
|
|
|
|
|
|
|
|
|
|
|
|
class IPConverter(commands.Converter):
|
2021-01-26 08:43:25 +00:00
|
|
|
async def convert(self, ctx, argument): # 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-01-26 14:24:10 +00:00
|
|
|
async def convert(self, ctx, argument): # 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):
|
|
|
|
async def convert(self, ctx, argument): # skipcq: PYL-W0613
|
2021-03-02 18:00:08 +00:00
|
|
|
return argument.lower()
|
2021-01-26 14:24:10 +00:00
|
|
|
|
|
|
|
|
2021-01-25 16:28:59 +00:00
|
|
|
class IPVersionConverter(commands.Converter):
|
2021-01-26 08:43:25 +00:00
|
|
|
async def convert(self, ctx, argument): # skipcq: PYL-W0613
|
2021-01-25 16:28:59 +00:00
|
|
|
if not argument:
|
|
|
|
return argument
|
|
|
|
|
2021-03-02 18:00:08 +00:00
|
|
|
return argument.replace("-", "").replace("ip", "").replace("v", "")
|