Introduce a new command to toggle Skia-based image generation in the LevelUp cog, enhancing image quality and performance. Update the pyproject.toml file to include project metadata and dependencies, including skia-python. Modify the levelalert generator to support Skia, with fallback to the original implementation if necessary. Additionally, update the author list in info.json to include a new contributor.
107 lines
No EOL
3.4 KiB
Python
107 lines
No EOL
3.4 KiB
Python
"""Settings for the LevelUp cog."""
|
|
|
|
import typing as t
|
|
from pathlib import Path
|
|
|
|
from redbot.core import Config
|
|
from redbot.core.bot import Red
|
|
|
|
from ..generator import imgtools
|
|
|
|
Cog = t.TypeVar("Cog")
|
|
GuildSettings = t.TypeVar("GuildSettings")
|
|
|
|
|
|
class Settings:
|
|
"""Settings for the LevelUp cog."""
|
|
|
|
def __init__(self, bot: Red, cog: Cog) -> None:
|
|
self.bot = bot
|
|
self.cog = cog
|
|
self.data = Config.get_conf(cog, identifier=1234567890)
|
|
|
|
default_global = {
|
|
"render_gifs": True,
|
|
"use_skia": True, # New setting to control Skia usage
|
|
"external_api_url": None,
|
|
"internal_api_port": None,
|
|
}
|
|
|
|
default_guild = {
|
|
"active": False,
|
|
"message_xp": (3, 6), # Min/Max XP per message
|
|
"voice_xp": (3, 6), # Min/Max XP per minute in voice
|
|
"xp_cooldown": 60,
|
|
"ignore_voice_users": [],
|
|
"ignore_voice_channels": [],
|
|
"ignore_text_users": [],
|
|
"ignore_text_channels": [],
|
|
"ignored_roles": [],
|
|
"xp_roles": {},
|
|
"levelup_messages": [],
|
|
"levelup_channel": None,
|
|
"levelup_ping": False,
|
|
"mention": True,
|
|
"stacking": False,
|
|
"stack_roles": False,
|
|
"remove_role": False,
|
|
"test_message": None,
|
|
"show_prestige": False,
|
|
"prestige_level": 100,
|
|
"prestige_role": None,
|
|
"prestige_req": None,
|
|
"prestige_cost": 0,
|
|
"base_xp": 100,
|
|
"xp_per_level": 1.2,
|
|
"voice_prestige": 0,
|
|
"msg_prestige": 0,
|
|
"emoji": {},
|
|
"auto_remove": [],
|
|
"notify": True,
|
|
"level_algorithm": "flat",
|
|
"prestige_notify": True,
|
|
"prestige_channel": None,
|
|
"prestige_message": None,
|
|
"dm_levelup": False,
|
|
"dm_prestige": False,
|
|
"dm_message": None,
|
|
"dm_prestige_message": None,
|
|
"priority_roles": [],
|
|
"stream_bonus": 0.3,
|
|
"weekly_reset": False,
|
|
"weekly_timer": 0,
|
|
"weekly_message": None,
|
|
"weekly_channel": None,
|
|
"weekly_roles": {},
|
|
"weekly_role_persist": False,
|
|
"weekly_autoreset": True,
|
|
"weekly_bonus": 0.2,
|
|
"weekly_vc_only": False,
|
|
"weekly_vc_reset": False,
|
|
"weekly_vc_timer": 0,
|
|
"weekly_vc_message": None,
|
|
"weekly_vc_channel": None,
|
|
"weekly_vc_roles": {},
|
|
"weekly_vc_role_persist": False,
|
|
"weekly_vc_autoreset": True,
|
|
"weekly_vc_bonus": 0.2,
|
|
}
|
|
|
|
self.data.register_global(**default_global)
|
|
self.data.register_guild(**default_guild)
|
|
|
|
async def get_global(self) -> t.Dict[str, t.Any]:
|
|
"""Get the global settings."""
|
|
return await self.data.all()
|
|
|
|
async def get_guild(self, guild_id: int) -> t.Dict[str, t.Any]:
|
|
"""Get the guild settings."""
|
|
return await self.data.guild_from_id(guild_id).all()
|
|
|
|
async def set_use_skia(self, value: bool) -> None:
|
|
"""Set whether to use Skia for image generation."""
|
|
await self.data.use_skia.set(value)
|
|
|
|
async def get_use_skia(self) -> bool:
|
|
"""Get whether to use Skia for image generation."""
|
|
return await self.data.use_skia() |