tuxbot-bot/tuxbot/cogs/Network/functions/converters.py
2021-03-31 18:08:53 +02:00

37 lines
1 KiB
Python

from discord.ext import commands
def _(x):
return x
class IPConverter(commands.Converter):
async def convert(self, ctx, argument): # skipcq: PYL-W0613
argument = argument.replace("http://", "").replace("https://", "")
argument = argument.rstrip("/")
if argument.startswith("`") and argument.endswith("`"):
argument = argument.lstrip("`").rstrip("`")
return argument.lower()
class DomainConverter(commands.Converter):
async def convert(self, ctx, argument): # skipcq: PYL-W0613
if not argument.startswith("http"):
return f"http://{argument}"
return argument
class QueryTypeConverter(commands.Converter):
async def convert(self, ctx, argument): # skipcq: PYL-W0613
return argument.lower()
class IPVersionConverter(commands.Converter):
async def convert(self, ctx, argument): # skipcq: PYL-W0613
if not argument:
return argument
return argument.replace("-", "").replace("ip", "").replace("v", "")