tux.utils.banner
¶
Banner creation and formatting utilities for Tux.
Classes:
Name | Description |
---|---|
BannerColors | Color scheme for banner elements. |
BannerConfig | Configuration for banner content and styling. |
BannerBuilder | Builder class for creating rich text banners. |
Functions:
Name | Description |
---|---|
create_banner | Create a banner panel with bot information. |
Classes¶
BannerColors
¶
BannerConfig(bot_name: str, version: str, bot_id: str | None = None, guild_count: int = 0, user_count: int = 0, prefix: str = '~', dev_mode: bool = False, colors: BannerColors = BannerColors())
dataclass
¶
Configuration for banner content and styling.
BannerBuilder(config: BannerConfig)
¶
Builder class for creating rich text banners.
Methods:
Name | Description |
---|---|
build | Build the complete banner panel. |
Source code in tux/utils/banner.py
Functions¶
_create_ascii_art() -> Text
¶
Create styled ASCII art text.
Source code in tux/utils/banner.py
_create_banner_table() -> Table
¶
Create the complete banner table.
Source code in tux/utils/banner.py
Python
def _create_banner_table(self) -> Table:
"""Create the complete banner table."""
# Create a grid-style table with minimal padding
table = Table.grid(padding=(0, 2))
# Add columns for ASCII art and info
table.add_column(width=12) # ASCII art
table.add_column(justify="left", style=f"bold {self.config.colors.primary}", width=8) # Labels
table.add_column(style=self.config.colors.secondary) # Values
# Create ASCII art
ascii_art = self._create_ascii_art()
ascii_lines = ascii_art.plain.splitlines()
# Create info data
mode_style = self.config.colors.warning if self.config.dev_mode else self.config.colors.success
mode_text = "Development" if self.config.dev_mode else "Production"
info_data = [
("", ""), # Empty row to shift content down
("Bot Name", f"{self.config.bot_name} (Tux)"),
("Version", self.config.version),
("Bot ID", str(self.config.bot_id or "Unknown")),
("Status", f"Watching {self.config.guild_count} servers with {self.config.user_count} users"),
("Prefix", self.config.prefix),
("Mode", Text(mode_text, style=mode_style)),
]
# Add rows, combining ASCII art with info
for i in range(max(len(ascii_lines), len(info_data))):
ascii_line = ascii_lines[i] if i < len(ascii_lines) else ""
label, value = info_data[i] if i < len(info_data) else ("", "")
table.add_row(Text(ascii_line, style=ascii_art.style), label, value)
return table
build() -> Panel
¶
Build the complete banner panel.
Functions¶
create_banner(bot_name: str, version: str, bot_id: str | None = None, guild_count: int = 0, user_count: int = 0, prefix: str = '~', dev_mode: bool = False) -> Panel
¶
Create a banner panel with bot information.
Source code in tux/utils/banner.py
Python
def create_banner(
bot_name: str,
version: str,
bot_id: str | None = None,
guild_count: int = 0,
user_count: int = 0,
prefix: str = "~",
dev_mode: bool = False,
) -> Panel:
"""Create a banner panel with bot information."""
config = BannerConfig(
bot_name=bot_name,
version=version,
bot_id=bot_id,
guild_count=guild_count,
user_count=user_count,
prefix=prefix,
dev_mode=dev_mode,
)
return BannerBuilder(config).build()