diff --git a/Makefile b/Makefile index baa1f07..e2d5009 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ update-all: $(VIRTUAL_ENV)/bin/pip install --upgrade --force-reinstall . .PHONY: dev -dev: black type update +dev: style update tuxbot # Docker diff --git a/tuxbot/cogs/Crypto/crypto.py b/tuxbot/cogs/Crypto/crypto.py index 1df6fa9..e17ede4 100644 --- a/tuxbot/cogs/Crypto/crypto.py +++ b/tuxbot/cogs/Crypto/crypto.py @@ -1,15 +1,18 @@ -import functools +# import functools import logging -import discord + +# import discord from discord.ext import commands -from tuxbot.cogs.Crypto.functions.extractor import extract -from tuxbot.cogs.Crypto.functions.sync import encode +# +# from tuxbot.cogs.Crypto.functions.extractor import extract +# from tuxbot.cogs.Crypto.functions.sync import encode from tuxbot.core.bot import Tux from tuxbot.core.i18n import ( Translator, ) -from tuxbot.core.utils.functions.extra import group_extra, ContextPlus + +# from tuxbot.core.utils.functions.extra import group_extra, ContextPlus log = logging.getLogger("tuxbot.cogs.Crypto") @@ -20,41 +23,41 @@ class Crypto(commands.Cog): def __init__(self, bot: Tux): self.bot = bot - @group_extra(name="ralgo") - async def _ralgo(self, ctx: commands.Context): - if ctx.invoked_subcommand is None: - await ctx.send_help("ralgo") - - @_ralgo.command(name="encode") - async def _ralgo_encode(self, ctx: ContextPlus, *, data: str = None): - try: - params = await extract(ctx.message.attachments, data, 10000) - except ValueError: - return await ctx.send("Invalid data provided") - - async with ctx.typing(): - output = await self.bot.loop.run_in_executor( - None, functools.partial(encode, params) - ) - - if params["graphical"]: - return await ctx.send(file=output) - - await ctx.send(output) - - @_ralgo.command(name="decode") - async def _ralgo_decode(self, ctx: ContextPlus, *, data: str = None): - try: - params = await extract(ctx.message.attachments, data, 100000) - except ValueError: - return await ctx.send("Invalid data provided") - - async with ctx.typing(): - output = await self.bot.loop.run_in_executor( - None, functools.partial(encode, params) - ) - - if isinstance(output, discord.File): - return await ctx.send(file=output) - - await ctx.send(output) + # @group_extra(name="ralgo") + # async def _ralgo(self, ctx: commands.Context): + # if ctx.invoked_subcommand is None: + # await ctx.send_help("ralgo") + # + # @_ralgo.command(name="encode") + # async def _ralgo_encode(self, ctx: ContextPlus, *, data: str = None): + # try: + # params = await extract(ctx.message.attachments, data, 10000) + # except ValueError: + # return await ctx.send("Invalid data provided") + # + # async with ctx.typing(): + # output = await self.bot.loop.run_in_executor( + # None, functools.partial(encode, params) + # ) + # + # if params["graphical"]: + # return await ctx.send(file=output) + # + # await ctx.send(output) + # + # @_ralgo.command(name="decode") + # async def _ralgo_decode(self, ctx: ContextPlus, *, data: str = None): + # try: + # params = await extract(ctx.message.attachments, data, 100000) + # except ValueError: + # return await ctx.send("Invalid data provided") + # + # async with ctx.typing(): + # output = await self.bot.loop.run_in_executor( + # None, functools.partial(encode, params) + # ) + # + # if isinstance(output, discord.File): + # return await ctx.send(file=output) + # + # await ctx.send(output) diff --git a/tuxbot/cogs/Crypto/functions/extractor.py b/tuxbot/cogs/Crypto/functions/extractor.py index 58c978a..6980769 100644 --- a/tuxbot/cogs/Crypto/functions/extractor.py +++ b/tuxbot/cogs/Crypto/functions/extractor.py @@ -1,28 +1,28 @@ -from typing import Optional, NoReturn, Union - -from discord import Attachment -from tuxbot.cogs.Crypto.functions.parser import data_parser - - -async def extract( - attachments: list[Optional[Attachment]], data: Optional[str], max_size: int -) -> dict: - if not data and len(attachments) == 0: - raise ValueError - - kwargs = data_parser(data) - - if attachments and attachments[0]: - file: Attachment = attachments[0] - if file.size > max_size: - raise ValueError - - kwargs["message"] = await file.read() - - params = { - "compressed": "compressed" in kwargs.keys(), - "graphical": "graphical" in kwargs.keys(), - "chars": kwargs["chars"] if "chars" in kwargs.keys() else (".", ","), - } - - return {"message": kwargs["message"], "params": params} +# from typing import Optional, NoReturn, Union +# +# from discord import Attachment +# from tuxbot.cogs.Crypto.functions.parser import data_parser +# +# +# async def extract( +# attachments: list[Optional[Attachment]], data: Optional[str], max_size: int +# ) -> dict: +# if not data and len(attachments) == 0: +# raise ValueError +# +# kwargs = data_parser(data) +# +# if attachments and attachments[0]: +# file: Attachment = attachments[0] +# if file.size > max_size: +# raise ValueError +# +# kwargs["message"] = await file.read() +# +# params = { +# "compressed": "compressed" in kwargs.keys(), +# "graphical": "graphical" in kwargs.keys(), +# "chars": kwargs["chars"] if "chars" in kwargs.keys() else (".", ","), +# } +# +# return {"message": kwargs["message"], "params": params} diff --git a/tuxbot/cogs/Crypto/functions/sync.py b/tuxbot/cogs/Crypto/functions/sync.py index caddfea..2c4e66e 100644 --- a/tuxbot/cogs/Crypto/functions/sync.py +++ b/tuxbot/cogs/Crypto/functions/sync.py @@ -1,40 +1,40 @@ -from io import BytesIO -from typing import Union - -import discord -from ralgo.ralgo import Ralgo -from tuxbot.cogs.Crypto.functions.file import find_ext - - -def encode(params: dict) -> Union[str, discord.File]: - statement = Ralgo(params["message"]) - params = params["params"] - encoded = statement.encode(chars=params["chars"]) - - if params["compressed"]: - return str(encoded.compress()) - if params["graphical"]: - output = encoded.graphical().encode() - return discord.File(BytesIO(output.to_bytes()), "output.png") - - return str(encoded) - - -def decode(params: dict) -> Union[str, discord.File]: - statement = Ralgo(params["message"]) - params = params["params"] - - if params["graphical"]: - output = Ralgo(statement.graphical().decode()).decode() - elif params["compressed"]: - output = Ralgo(statement.decompress()).decode() - else: - output = statement.decode(chars=params["chars"]) - - if isinstance(output, bytes): - return discord.File(BytesIO(output), f"output.{find_ext(output)}") - - output = discord.utils.escape_markdown(str(output)) - output = discord.utils.escape_mentions(output) - - return output if len(output) > 0 else "no content..." +# from io import BytesIO +# from typing import Union +# +# import discord +# from ralgo.ralgo import Ralgo +# from tuxbot.cogs.Crypto.functions.file import find_ext +# +# +# def encode(params: dict) -> Union[str, discord.File]: +# statement = Ralgo(params["message"]) +# params = params["params"] +# encoded = statement.encode(chars=params["chars"]) +# +# if params["compressed"]: +# return str(encoded.compress()) +# if params["graphical"]: +# output = encoded.graphical().encode() +# return discord.File(BytesIO(output.to_bytes()), "output.png") +# +# return str(encoded) +# +# +# def decode(params: dict) -> Union[str, discord.File]: +# statement = Ralgo(params["message"]) +# params = params["params"] +# +# if params["graphical"]: +# output = Ralgo(statement.graphical().decode()).decode() +# elif params["compressed"]: +# output = Ralgo(statement.decompress()).decode() +# else: +# output = statement.decode(chars=params["chars"]) +# +# if isinstance(output, bytes): +# return discord.File(BytesIO(output), f"output.{find_ext(output)}") +# +# output = discord.utils.escape_markdown(str(output)) +# output = discord.utils.escape_mentions(output) +# +# return output if len(output) > 0 else "no content..." diff --git a/tuxbot/cogs/Logs/logs.py b/tuxbot/cogs/Logs/logs.py index 3dc2242..42d5445 100644 --- a/tuxbot/cogs/Logs/logs.py +++ b/tuxbot/cogs/Logs/logs.py @@ -69,6 +69,7 @@ class Logs(commands.Cog): bot.on_error = self.on_error if self.bot.instance_name != "dev": + # pylint: disable=abstract-class-instantiated sentry_sdk.init( dsn=self.__config.sentryKey, traces_sample_rate=1.0, diff --git a/tuxbot/cogs/Polls/polls.py b/tuxbot/cogs/Polls/polls.py index 29bb61d..ea5a56b 100644 --- a/tuxbot/cogs/Polls/polls.py +++ b/tuxbot/cogs/Polls/polls.py @@ -1,6 +1,6 @@ import json import logging -from typing import Union, Dict, Iterable, Any +from typing import Union, Dict import discord from discord.ext import commands