From 4a508b1851af05ca4e3bf003ba8595a0a6434766 Mon Sep 17 00:00:00 2001 From: Romain J Date: Wed, 21 Apr 2021 18:00:43 +0200 Subject: [PATCH] delete(commands:*|Crypto): remove unused cog --- tuxbot/cogs/Crypto/__init__.py | 19 ------- tuxbot/cogs/Crypto/config.py | 12 ----- tuxbot/cogs/Crypto/crypto.py | 63 ----------------------- tuxbot/cogs/Crypto/functions/__init__.py | 0 tuxbot/cogs/Crypto/functions/extractor.py | 28 ---------- tuxbot/cogs/Crypto/functions/file.py | 10 ---- tuxbot/cogs/Crypto/functions/parser.py | 36 ------------- tuxbot/cogs/Crypto/functions/sync.py | 40 -------------- tuxbot/cogs/Crypto/locales/en-US.po | 57 -------------------- tuxbot/cogs/Crypto/locales/fr-FR.po | 58 --------------------- tuxbot/cogs/Crypto/locales/messages.pot | 56 -------------------- tuxbot/cogs/Crypto/models/__init__.py | 0 tuxbot/core/bot.py | 1 - 13 files changed, 380 deletions(-) delete mode 100644 tuxbot/cogs/Crypto/__init__.py delete mode 100644 tuxbot/cogs/Crypto/config.py delete mode 100644 tuxbot/cogs/Crypto/crypto.py delete mode 100644 tuxbot/cogs/Crypto/functions/__init__.py delete mode 100644 tuxbot/cogs/Crypto/functions/extractor.py delete mode 100644 tuxbot/cogs/Crypto/functions/file.py delete mode 100644 tuxbot/cogs/Crypto/functions/parser.py delete mode 100644 tuxbot/cogs/Crypto/functions/sync.py delete mode 100644 tuxbot/cogs/Crypto/locales/en-US.po delete mode 100644 tuxbot/cogs/Crypto/locales/fr-FR.po delete mode 100644 tuxbot/cogs/Crypto/locales/messages.pot delete mode 100644 tuxbot/cogs/Crypto/models/__init__.py diff --git a/tuxbot/cogs/Crypto/__init__.py b/tuxbot/cogs/Crypto/__init__.py deleted file mode 100644 index 0c2f110..0000000 --- a/tuxbot/cogs/Crypto/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -from collections import namedtuple - -from tuxbot.core.bot import Tux -from .crypto import Crypto -from .config import CryptoConfig, HAS_MODELS - -VersionInfo = namedtuple("VersionInfo", "major minor micro release_level") -version_info = VersionInfo(major=1, minor=0, micro=0, release_level="alpha") - -__version__ = "v{}.{}.{}-{}".format( - version_info.major, - version_info.minor, - version_info.micro, - version_info.release_level, -).replace("\n", "") - - -def setup(bot: Tux): - bot.add_cog(Crypto(bot)) diff --git a/tuxbot/cogs/Crypto/config.py b/tuxbot/cogs/Crypto/config.py deleted file mode 100644 index 1663bb8..0000000 --- a/tuxbot/cogs/Crypto/config.py +++ /dev/null @@ -1,12 +0,0 @@ -from typing import Dict - -from structured_config import Structure - -HAS_MODELS = False - - -class CryptoConfig(Structure): - pass - - -extra: Dict[str, Dict] = {} diff --git a/tuxbot/cogs/Crypto/crypto.py b/tuxbot/cogs/Crypto/crypto.py deleted file mode 100644 index e17ede4..0000000 --- a/tuxbot/cogs/Crypto/crypto.py +++ /dev/null @@ -1,63 +0,0 @@ -# import functools -import logging - -# 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.core.bot import Tux -from tuxbot.core.i18n import ( - Translator, -) - -# from tuxbot.core.utils.functions.extra import group_extra, ContextPlus - - -log = logging.getLogger("tuxbot.cogs.Crypto") -_ = Translator("Crypto", __file__) - - -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) diff --git a/tuxbot/cogs/Crypto/functions/__init__.py b/tuxbot/cogs/Crypto/functions/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tuxbot/cogs/Crypto/functions/extractor.py b/tuxbot/cogs/Crypto/functions/extractor.py deleted file mode 100644 index 6980769..0000000 --- a/tuxbot/cogs/Crypto/functions/extractor.py +++ /dev/null @@ -1,28 +0,0 @@ -# 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/file.py b/tuxbot/cogs/Crypto/functions/file.py deleted file mode 100644 index f87b46a..0000000 --- a/tuxbot/cogs/Crypto/functions/file.py +++ /dev/null @@ -1,10 +0,0 @@ -# https://python-forum.io/Thread-read-a-binary-file-to-find-its-type -def find_ext(content: bytes) -> str: - magic_numbers = { - "png": bytes([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]) - } - - if content.startswith(magic_numbers["png"]): - return "png" - - return "txt" diff --git a/tuxbot/cogs/Crypto/functions/parser.py b/tuxbot/cogs/Crypto/functions/parser.py deleted file mode 100644 index e0d89b1..0000000 --- a/tuxbot/cogs/Crypto/functions/parser.py +++ /dev/null @@ -1,36 +0,0 @@ -import re -from typing import Optional - - -def data_parser(data: Optional[str]) -> dict: - output = { - "message": "", - "compressed": False, - "graphical": False, - "chars": tuple, - } - - if not data: - return output - - if "--compressed" in data: - output["compressed"] = True - data = "".join(data.rsplit("--compressed", 1)) - - if "--graphical" in data: - output["graphical"] = True - data = "".join(data.rsplit("--graphical", 1)) - - if "compressed" in output.keys(): - del output["compressed"] - - if "--chars" in data: - regex = r"--chars=(\S\S)" - - if match := re.search(regex, data): - output["chars"] = tuple(match.group()[-2:]) - data = "".join(data.rsplit(match.group(), 1)) - - output["message"] = data.strip() - - return output diff --git a/tuxbot/cogs/Crypto/functions/sync.py b/tuxbot/cogs/Crypto/functions/sync.py deleted file mode 100644 index 2c4e66e..0000000 --- a/tuxbot/cogs/Crypto/functions/sync.py +++ /dev/null @@ -1,40 +0,0 @@ -# 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/Crypto/locales/en-US.po b/tuxbot/cogs/Crypto/locales/en-US.po deleted file mode 100644 index dec6d18..0000000 --- a/tuxbot/cogs/Crypto/locales/en-US.po +++ /dev/null @@ -1,57 +0,0 @@ -# French translations for Tuxbot-bot package -# Traductions françaises du paquet Tuxbot-bot. -# Copyright (C) 2020 THE Tuxbot-bot'S COPYRIGHT HOLDER -# This file is distributed under the same license as the Tuxbot-bot package. -# Automatically generated, 2020. -# -msgid "" -msgstr "" -"Project-Id-Version: Tuxbot-bot\n" -"Report-Msgid-Bugs-To: rick@gnous.eu\n" -"POT-Creation-Date: 2020-10-21 01:15+0200\n" -"PO-Revision-Date: 2020-10-21 01:15+0200\n" -"Last-Translator: Automatically generated\n" -"Language-Team: none\n" -"Language: en_US\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#: tuxbot/cogs/Polls/polls.py:55 tuxbot/cogs/Polls/polls.py:176 -msgid "**Preparation**" -msgstr "" - -#: tuxbot/cogs/Polls/polls.py:204 -#, python-brace-format -msgid "Proposed addition for poll #{id}" -msgstr "" - -#: tuxbot/cogs/Polls/polls.py:209 -msgid "Poll" -msgstr "" - -#: tuxbot/cogs/Polls/polls.py:211 -msgid "here" -msgstr "" - -#: tuxbot/cogs/Polls/polls.py:215 -#, python-brace-format -msgid "Requested by {author}" -msgstr "" - -#: tuxbot/cogs/Polls/functions/converters.py:21 -#: tuxbot/cogs/Polls/functions/converters.py:49 -msgid "Please provide a message in this channel" -msgstr "" - -#: tuxbot/cogs/Polls/functions/converters.py:30 -#: tuxbot/cogs/Polls/functions/converters.py:36 -#: tuxbot/cogs/Polls/functions/converters.py:41 -#: tuxbot/cogs/Polls/functions/converters.py:46 -msgid "Unable to find this poll" -msgstr "" - -#: tuxbot/cogs/Polls/functions/converters.py:58 -msgid "Your proposal must be smaller than 30" -msgstr "" diff --git a/tuxbot/cogs/Crypto/locales/fr-FR.po b/tuxbot/cogs/Crypto/locales/fr-FR.po deleted file mode 100644 index a9be5d3..0000000 --- a/tuxbot/cogs/Crypto/locales/fr-FR.po +++ /dev/null @@ -1,58 +0,0 @@ -# French translations for Tuxbot-bot package -# Traductions françaises du paquet Tuxbot-bot. -# Copyright (C) 2020 THE Tuxbot-bot'S COPYRIGHT HOLDER -# This file is distributed under the same license as the Tuxbot-bot package. -# Automatically generated, 2020. -# -msgid "" -msgstr "" -"Project-Id-Version: Tuxbot-bot\n" -"Report-Msgid-Bugs-To: rick@gnous.eu\n" -"POT-Creation-Date: 2020-10-21 01:15+0200\n" -"PO-Revision-Date: 2020-10-21 01:15+0200\n" -"Last-Translator: Automatically generated\n" -"Language-Team: none\n" -"Language: fr\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n > 1);\n" - -#: tuxbot/cogs/Polls/polls.py:55 tuxbot/cogs/Polls/polls.py:176 -msgid "**Preparation**" -msgstr "**Préparation**" - -#: tuxbot/cogs/Polls/polls.py:204 -#, python-brace-format -msgid "Proposed addition for poll #{id}" -msgstr "Proposition d'ajout pour le sondage #{id}" - -#: tuxbot/cogs/Polls/polls.py:209 -msgid "Poll" -msgstr "Sondage" - -#: tuxbot/cogs/Polls/polls.py:211 -msgid "here" -msgstr "ici" - -#: tuxbot/cogs/Polls/polls.py:215 -#, python-brace-format -msgid "Requested by {author}" -msgstr "Demandée par {author}" - -#: tuxbot/cogs/Polls/functions/converters.py:21 -#: tuxbot/cogs/Polls/functions/converters.py:49 -msgid "Please provide a message in this channel" -msgstr "Veuillez fournir un message dans ce salon" - -#: tuxbot/cogs/Polls/functions/converters.py:30 -#: tuxbot/cogs/Polls/functions/converters.py:36 -#: tuxbot/cogs/Polls/functions/converters.py:41 -#: tuxbot/cogs/Polls/functions/converters.py:46 -msgid "Unable to find this poll" -msgstr "Impossible de trouver ce sondage" - -#: tuxbot/cogs/Polls/functions/converters.py:58 -msgid "Your proposal must be smaller than 30" -msgstr "Votre proposition doit être inférieure à 30" - diff --git a/tuxbot/cogs/Crypto/locales/messages.pot b/tuxbot/cogs/Crypto/locales/messages.pot deleted file mode 100644 index f6bd62b..0000000 --- a/tuxbot/cogs/Crypto/locales/messages.pot +++ /dev/null @@ -1,56 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the Tuxbot-bot package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: Tuxbot-bot\n" -"Report-Msgid-Bugs-To: rick@gnous.eu\n" -"POT-Creation-Date: 2021-01-26 16:12+0100\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -#: tuxbot/cogs/Polls/polls.py:55 tuxbot/cogs/Polls/polls.py:176 -msgid "**Preparation**" -msgstr "" - -#: tuxbot/cogs/Polls/polls.py:204 -#, python-brace-format -msgid "Proposed addition for poll #{id}" -msgstr "" - -#: tuxbot/cogs/Polls/polls.py:209 -msgid "Poll" -msgstr "" - -#: tuxbot/cogs/Polls/polls.py:211 -msgid "here" -msgstr "" - -#: tuxbot/cogs/Polls/polls.py:215 -#, python-brace-format -msgid "Requested by {author}" -msgstr "" - -#: tuxbot/cogs/Polls/functions/converters.py:21 -#: tuxbot/cogs/Polls/functions/converters.py:49 -msgid "Please provide a message in this channel" -msgstr "" - -#: tuxbot/cogs/Polls/functions/converters.py:30 -#: tuxbot/cogs/Polls/functions/converters.py:36 -#: tuxbot/cogs/Polls/functions/converters.py:41 -#: tuxbot/cogs/Polls/functions/converters.py:46 -msgid "Unable to find this poll" -msgstr "" - -#: tuxbot/cogs/Polls/functions/converters.py:58 -msgid "Your proposal must be smaller than 30" -msgstr "" diff --git a/tuxbot/cogs/Crypto/models/__init__.py b/tuxbot/cogs/Crypto/models/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tuxbot/core/bot.py b/tuxbot/core/bot.py index 07b009f..2bc450a 100644 --- a/tuxbot/core/bot.py +++ b/tuxbot/core/bot.py @@ -42,7 +42,6 @@ packages: List[str] = [ "tuxbot.cogs.Polls", "tuxbot.cogs.Custom", "tuxbot.cogs.Network", - # "tuxbot.cogs.Crypto", ]