2021-01-25 17:28:59 +01:00
|
|
|
from discord.ext import commands
|
2021-04-22 18:11:55 +02:00
|
|
|
from discord.ext.commands import Context
|
2021-01-25 17:28:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
def _(x):
|
|
|
|
return x
|
|
|
|
|
|
|
|
|
|
|
|
class IPConverter(commands.Converter):
|
2021-04-22 18:11:55 +02:00
|
|
|
async def convert(self, ctx: Context, argument: str): # skipcq: PYL-W0613
|
2021-01-25 17:28:59 +01:00
|
|
|
argument = argument.replace("http://", "").replace("https://", "")
|
2021-02-11 18:21:50 +01:00
|
|
|
argument = argument.rstrip("/")
|
2021-01-25 17:28:59 +01:00
|
|
|
|
2021-03-02 19:00:08 +01:00
|
|
|
if argument.startswith("`") and argument.endswith("`"):
|
|
|
|
argument = argument.lstrip("`").rstrip("`")
|
2021-01-25 17:28:59 +01:00
|
|
|
|
2021-03-02 19:00:08 +01:00
|
|
|
return argument.lower()
|
2021-01-25 17:28:59 +01:00
|
|
|
|
|
|
|
|
2021-03-02 19:00:08 +01:00
|
|
|
class DomainConverter(commands.Converter):
|
2021-04-22 18:11:55 +02:00
|
|
|
async def convert(self, ctx: Context, argument: str): # skipcq: PYL-W0613
|
2021-01-26 17:11:30 +01:00
|
|
|
if not argument.startswith("http"):
|
|
|
|
return f"http://{argument}"
|
|
|
|
|
|
|
|
return argument
|
|
|
|
|
|
|
|
|
|
|
|
class QueryTypeConverter(commands.Converter):
|
2021-04-22 18:11:55 +02:00
|
|
|
async def convert(self, ctx: Context, argument: str): # skipcq: PYL-W0613
|
2021-03-02 19:00:08 +01:00
|
|
|
return argument.lower()
|
2021-01-26 15:24:10 +01:00
|
|
|
|
|
|
|
|
2021-01-25 17:28:59 +01:00
|
|
|
class IPVersionConverter(commands.Converter):
|
2021-04-22 18:11:55 +02:00
|
|
|
async def convert(self, ctx: Context, argument: str): # skipcq: PYL-W0613
|
2021-01-25 17:28:59 +01:00
|
|
|
if not argument:
|
|
|
|
return argument
|
|
|
|
|
2021-03-02 19:00:08 +01:00
|
|
|
return argument.replace("-", "").replace("ip", "").replace("v", "")
|
2021-04-22 18:11:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ASConverter(commands.Converter):
|
|
|
|
async def convert(self, ctx: Context, argument: str): # skipcq: PYL-W0613
|
|
|
|
return argument.lower().lstrip("as")
|