feat(repo): added help formatters for version numbers to cogs that have them and migrated to using red's inbuilt loggers instead of logging.getLogger
Some checks failed
Actions / Lint Code (Ruff & Pylint) (push) Failing after 31s
Actions / Build Documentation (MkDocs) (push) Successful in 26s

This commit is contained in:
Seaswimmer 2024-03-07 03:38:34 -05:00
parent ae31a61436
commit 178a92559c
Signed by: cswimr
GPG key ID: B8953EC01E5C4063
6 changed files with 62 additions and 30 deletions

View file

@ -19,7 +19,8 @@ from pytimeparse2 import disable_dateutil, parse
from redbot.core import app_commands, commands, data_manager from redbot.core import app_commands, commands, data_manager
from redbot.core.app_commands import Choice from redbot.core.app_commands import Choice
from redbot.core.bot import Red from redbot.core.bot import Red
from redbot.core.utils.chat_formatting import box, error, warning from redbot.core.utils.chat_formatting import (box, error, humanize_list,
warning)
from aurora.importers.aurora import ImportAuroraView from aurora.importers.aurora import ImportAuroraView
from aurora.importers.galacticbot import ImportGalacticBotView from aurora.importers.galacticbot import ImportGalacticBotView
@ -46,8 +47,8 @@ class Aurora(commands.Cog):
It is heavily inspired by GalacticBot, and is designed to be a more user-friendly alternative to Red's core Mod cogs. It is heavily inspired by GalacticBot, and is designed to be a more user-friendly alternative to Red's core Mod cogs.
This cog stores all of its data in an SQLite database.""" This cog stores all of its data in an SQLite database."""
__author__ = "SeaswimmerTheFsh" __author__ = ["SeaswimmerTheFsh"]
__version__ = "2.0.5" __version__ = "2.0.6"
async def red_delete_data_for_user(self, *, requester, user_id: int): async def red_delete_data_for_user(self, *, requester, user_id: int):
if requester == "discord_deleted_user": if requester == "discord_deleted_user":
@ -86,6 +87,16 @@ class Aurora(commands.Cog):
disable_dateutil() disable_dateutil()
self.handle_expiry.start() self.handle_expiry.start()
def format_help_for_context(self, ctx: commands.Context) -> str:
pre_processed = super().format_help_for_context(ctx) or ""
n = "\n" if "\n\n" not in pre_processed else ""
text = [
f"{pre_processed}{n}",
f"Cog Version: **{self.__version__}**",
f"Author: {humanize_list(self.__author__)}",
]
return "\n".join(text)
async def cog_load(self): async def cog_load(self):
"""This method prepares the database schema for all of the guilds the bot is currently in.""" """This method prepares the database schema for all of the guilds the bot is currently in."""
guilds: list[discord.Guild] = self.bot.guilds guilds: list[discord.Guild] = self.bot.guilds

View file

@ -1,3 +1,3 @@
import logging from red_commons.logging import getLogger
logger = logging.getLogger("red.seacogs.aurora") logger = getLogger("red.seacogs.aurora")

View file

@ -7,27 +7,38 @@
import contextlib import contextlib
import json import json
import logging
import re import re
from red_commons.logging import getLogger
from redbot.cogs.downloader import errors from redbot.cogs.downloader import errors
from redbot.cogs.downloader.converters import InstalledCog from redbot.cogs.downloader.converters import InstalledCog
from redbot.core import commands from redbot.core import commands
from redbot.core.bot import Red from redbot.core.bot import Red
from redbot.core.utils.chat_formatting import error, text_to_file from redbot.core.utils.chat_formatting import (error, humanize_list,
text_to_file)
# pylint: disable=protected-access # pylint: disable=protected-access
class Backup(commands.Cog): class Backup(commands.Cog):
"""A utility to make reinstalling repositories and cogs after migrating the bot far easier.""" """A utility to make reinstalling repositories and cogs after migrating the bot far easier."""
__author__ = "SeaswimmerTheFsh" __author__ = ["SeaswimmerTheFsh"]
__version__ = "1.0.0" __version__ = "1.0.1"
def __init__(self, bot: Red): def __init__(self, bot: Red):
super().__init__() super().__init__()
self.bot = bot self.bot = bot
self.logger = logging.getLogger("red.seacogs.backup") self.logger = getLogger("red.seacogs.backup")
def format_help_for_context(self, ctx: commands.Context) -> str:
pre_processed = super().format_help_for_context(ctx) or ""
n = "\n" if "\n\n" not in pre_processed else ""
text = [
f"{pre_processed}{n}",
f"Cog Version: **{self.__version__}**",
f"Author: {humanize_list(self.__author__)}",
]
return "\n".join(text)
@commands.group(autohelp=True) @commands.group(autohelp=True)
@commands.is_owner() @commands.is_owner()

View file

@ -5,14 +5,14 @@
# ____) | __/ (_| \__ \\ V V /| | | | | | | | | | | | __/ | # ____) | __/ (_| \__ \\ V V /| | | | | | | | | | | | __/ |
# |_____/ \___|\__,_|___/ \_/\_/ |_|_| |_| |_|_| |_| |_|\___|_| # |_____/ \___|\__,_|___/ \_/\_/ |_|_| |_| |_|_| |_| |_|\___|_|
import logging
import random import random
import aiohttp import aiohttp
from discord import Embed from discord import Embed
from red_commons.logging import getLogger
from redbot.core import Config, commands from redbot.core import Config, commands
from redbot.core.bot import Red from redbot.core.bot import Red
from redbot.core.utils.chat_formatting import error from redbot.core.utils.chat_formatting import error, humanize_list
import bible.errors import bible.errors
from bible.models import Version from bible.models import Version
@ -21,8 +21,8 @@ from bible.models import Version
class Bible(commands.Cog): class Bible(commands.Cog):
"""Retrieve Bible verses from the API.bible API.""" """Retrieve Bible verses from the API.bible API."""
__author__ = "SeaswimmerTheFsh" __author__ = ["SeaswimmerTheFsh"]
__version__ = "1.0.0" __version__ = "1.0.1"
def __init__(self, bot: Red): def __init__(self, bot: Red):
super().__init__() super().__init__()
@ -31,10 +31,20 @@ class Bible(commands.Cog):
self.config = Config.get_conf( self.config = Config.get_conf(
self, identifier=481923957134912, force_registration=True self, identifier=481923957134912, force_registration=True
) )
self.logger = logging.getLogger("red.seacogs.bible") self.logger = getLogger("red.seacogs.bible")
self.config.register_global(bible="de4e12af7f28f599-02") self.config.register_global(bible="de4e12af7f28f599-02")
self.config.register_user(bible=None) self.config.register_user(bible=None)
def format_help_for_context(self, ctx: commands.Context) -> str:
pre_processed = super().format_help_for_context(ctx) or ""
n = "\n" if "\n\n" not in pre_processed else ""
text = [
f"{pre_processed}{n}",
f"Cog Version: **{self.__version__}**",
f"Author: {humanize_list(self.__author__)}",
]
return "\n".join(text)
async def translate_book_name(self, bible_id: str, book_name: str) -> str: async def translate_book_name(self, bible_id: str, book_name: str) -> str:
"""Translate a book name to a book ID.""" """Translate a book name to a book ID."""
book_name_list = [ book_name_list = [

View file

@ -17,12 +17,22 @@ from redbot.core.utils import chat_formatting, common_filters
class Nerdify(commands.Cog): class Nerdify(commands.Cog):
"""Nerdify your text.""" """Nerdify your text."""
__author__ = "SeaswimmerTheFsh" __author__ = ["SeaswimmerTheFsh"]
__version__ = "1.3.2" __version__ = "1.3.3"
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
def format_help_for_context(self, ctx: commands.Context) -> str:
pre_processed = super().format_help_for_context(ctx) or ""
n = "\n" if "\n\n" not in pre_processed else ""
text = [
f"{pre_processed}{n}",
f"Cog Version: **{self.__version__}**",
f"Author: {chat_formatting.humanize_list(self.__author__)}",
]
return "\n".join(text)
@commands.command(aliases=["nerd"]) @commands.command(aliases=["nerd"])
async def nerdify( async def nerdify(
self, ctx: commands.Context, *, text: Optional[str] = None self, ctx: commands.Context, *, text: Optional[str] = None

View file

@ -1,14 +1,4 @@
import logging from red_commons.logging import getLogger
logger = logging.getLogger('red.seacogs.pterodactyl') logger = getLogger('red.seacogs.pterodactyl')
class WebsocketLogger(logging.Logger): websocket_logger = getLogger('red.seacogs.pterodactyl.websocket')
def __init__(self, name, level=logging.NOTSET):
super().__init__(name, level)
def debug(self, msg, *args, **kwargs):
self.log(logging.VERBOSE, msg, *args, **kwargs)
logging.setLoggerClass(WebsocketLogger)
websocket_logger = logging.getLogger('red.seacogs.pterodactyl.websocket')
logging.VERBOSE = 5
logging.addLevelName(logging.VERBOSE, "VERBOSE")